{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport os\n\nfrom sklearn.model_selection import train_test_split\n\nfrom transformers import AutoTokenizer\nfrom transformers import DataCollatorWithPadding\nfrom transformers import AutoModelForSequenceClassification, TrainingArguments, Trainer\nfrom datasets import Dataset\n\nfrom scipy.special import softmax\n\nimport torch\nfrom transformers import AutoConfig, AutoModel\n\nos.environ[\"WANDB_DISABLED\"] = \"true\"\n\n!pip install -q bitsandbytes-cuda110\nimport bitsandbytes as bnb\nfrom torch import nn\nfrom transformers.trainer_pt_utils import get_parameter_names\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-20T08:46:00.852631Z","iopub.execute_input":"2022-07-20T08:46:00.853208Z","iopub.status.idle":"2022-07-20T08:46:10.482274Z","shell.execute_reply.started":"2022-07-20T08:46:00.853164Z","shell.execute_reply":"2022-07-20T08:46:10.481064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission = pd.read_csv(\"/kaggle/input/feedback-prize-effectiveness/sample_submission.csv\")\ntrain = pd.read_csv(\"/kaggle/input/feedback-prize-effectiveness/train.csv\")\ntest = pd.read_csv(\"/kaggle/input/feedback-prize-effectiveness/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.484592Z","iopub.execute_input":"2022-07-20T08:46:10.485459Z","iopub.status.idle":"2022-07-20T08:46:10.782938Z","shell.execute_reply.started":"2022-07-20T08:46:10.485416Z","shell.execute_reply":"2022-07-20T08:46:10.781648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()\nprint(train.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.785136Z","iopub.execute_input":"2022-07-20T08:46:10.785868Z","iopub.status.idle":"2022-07-20T08:46:10.793371Z","shell.execute_reply.started":"2022-07-20T08:46:10.785790Z","shell.execute_reply":"2022-07-20T08:46:10.792109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()\nprint(test.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.797078Z","iopub.execute_input":"2022-07-20T08:46:10.798027Z","iopub.status.idle":"2022-07-20T08:46:10.807539Z","shell.execute_reply.started":"2022-07-20T08:46:10.797966Z","shell.execute_reply":"2022-07-20T08:46:10.806019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.head()\nprint(sample_submission.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.809820Z","iopub.execute_input":"2022-07-20T08:46:10.810792Z","iopub.status.idle":"2022-07-20T08:46:10.819923Z","shell.execute_reply.started":"2022-07-20T08:46:10.810747Z","shell.execute_reply":"2022-07-20T08:46:10.818277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.discourse_id.value_counts().max()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.822024Z","iopub.execute_input":"2022-07-20T08:46:10.822620Z","iopub.status.idle":"2022-07-20T08:46:10.866970Z","shell.execute_reply.started":"2022-07-20T08:46:10.822560Z","shell.execute_reply":"2022-07-20T08:46:10.865208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.discourse_id.value_counts().max()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.868677Z","iopub.execute_input":"2022-07-20T08:46:10.869935Z","iopub.status.idle":"2022-07-20T08:46:10.880712Z","shell.execute_reply.started":"2022-07-20T08:46:10.869893Z","shell.execute_reply":"2022-07-20T08:46:10.878969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.essay_id.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.883483Z","iopub.execute_input":"2022-07-20T08:46:10.883993Z","iopub.status.idle":"2022-07-20T08:46:10.894173Z","shell.execute_reply.started":"2022-07-20T08:46:10.883934Z","shell.execute_reply":"2022-07-20T08:46:10.892702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.essay_id.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.896517Z","iopub.execute_input":"2022-07-20T08:46:10.897544Z","iopub.status.idle":"2022-07-20T08:46:10.919470Z","shell.execute_reply.started":"2022-07-20T08:46:10.897499Z","shell.execute_reply":"2022-07-20T08:46:10.918091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def add_essay(row, train_test=\"train\"):\n    essay_filename = row[\"essay_id\"]\n    complete_filename = f\"/kaggle/input/feedback-prize-effectiveness/{train_test}/{essay_filename}.txt\"\n    with open(complete_filename, \"r\") as fp:\n        text = fp.read()\n    return text","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.924984Z","iopub.execute_input":"2022-07-20T08:46:10.925617Z","iopub.status.idle":"2022-07-20T08:46:10.932671Z","shell.execute_reply.started":"2022-07-20T08:46:10.925576Z","shell.execute_reply":"2022-07-20T08:46:10.930580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"essay_text\"] = train.apply(lambda x: add_essay(x, train_test=\"train\"), axis=1)\ntest[\"essay_text\"] = test.apply(lambda x: add_essay(x, train_test=\"test\"), axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:10.934677Z","iopub.execute_input":"2022-07-20T08:46:10.935450Z","iopub.status.idle":"2022-07-20T08:46:44.833843Z","shell.execute_reply.started":"2022-07-20T08:46:10.935361Z","shell.execute_reply":"2022-07-20T08:46:44.832334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def create_complete_text(row):\n    complete_text = row[\"discourse_type\"] + \" [SEP] \" + row[\"discourse_text\"] + \" [SEP] \" + row[\"essay_text\"] \n    return complete_text\n\ntrain[\"complete_text\"] = train.apply(lambda x: create_complete_text(x), axis=1)\ntest[\"complete_text\"] = test.apply(lambda x: create_complete_text(x), axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:44.837025Z","iopub.execute_input":"2022-07-20T08:46:44.837436Z","iopub.status.idle":"2022-07-20T08:46:45.924491Z","shell.execute_reply.started":"2022-07-20T08:46:44.837392Z","shell.execute_reply":"2022-07-20T08:46:45.923265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:45.926312Z","iopub.execute_input":"2022-07-20T08:46:45.926987Z","iopub.status.idle":"2022-07-20T08:46:45.950646Z","shell.execute_reply.started":"2022-07-20T08:46:45.926943Z","shell.execute_reply":"2022-07-20T08:46:45.949421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"complete_text_num_words\"] = train.complete_text.apply(lambda x: len(x.split()))","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:45.952079Z","iopub.execute_input":"2022-07-20T08:46:45.952624Z","iopub.status.idle":"2022-07-20T08:46:47.050662Z","shell.execute_reply.started":"2022-07-20T08:46:45.952565Z","shell.execute_reply":"2022-07-20T08:46:47.049466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(train[\"complete_text_num_words\"], bins=100)\nplt.title('Histogram of Train Word Counts',size=16)\nplt.xlabel('Train Word Count',size=14)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.052260Z","iopub.execute_input":"2022-07-20T08:46:47.052768Z","iopub.status.idle":"2022-07-20T08:46:47.515151Z","shell.execute_reply.started":"2022-07-20T08:46:47.052728Z","shell.execute_reply":"2022-07-20T08:46:47.513796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"label\"] = train[\"discourse_effectiveness\"].replace({\"Ineffective\": 0, \"Adequate\": 1, \"Effective\": 2})","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.517347Z","iopub.execute_input":"2022-07-20T08:46:47.518318Z","iopub.status.idle":"2022-07-20T08:46:47.550108Z","shell.execute_reply.started":"2022-07-20T08:46:47.518270Z","shell.execute_reply":"2022-07-20T08:46:47.548887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.552005Z","iopub.execute_input":"2022-07-20T08:46:47.552449Z","iopub.status.idle":"2022-07-20T08:46:47.571243Z","shell.execute_reply.started":"2022-07-20T08:46:47.552407Z","shell.execute_reply":"2022-07-20T08:46:47.569967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_val, y_train, y_val = train_test_split(train['complete_text'], train['label'], test_size=0.1, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.573173Z","iopub.execute_input":"2022-07-20T08:46:47.574327Z","iopub.status.idle":"2022-07-20T08:46:47.589909Z","shell.execute_reply.started":"2022-07-20T08:46:47.574276Z","shell.execute_reply":"2022-07-20T08:46:47.588532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.591516Z","iopub.execute_input":"2022-07-20T08:46:47.592483Z","iopub.status.idle":"2022-07-20T08:46:47.605121Z","shell.execute_reply.started":"2022-07-20T08:46:47.592439Z","shell.execute_reply":"2022-07-20T08:46:47.603848Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_val.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.607863Z","iopub.execute_input":"2022-07-20T08:46:47.608553Z","iopub.status.idle":"2022-07-20T08:46:47.619771Z","shell.execute_reply.started":"2022-07-20T08:46:47.608510Z","shell.execute_reply":"2022-07-20T08:46:47.617875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.DataFrame({\"complete_text\": X_train, \"label\": y_train})\ndf_val = pd.DataFrame({\"complete_text\": X_val, \"label\": y_val})","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.621476Z","iopub.execute_input":"2022-07-20T08:46:47.622451Z","iopub.status.idle":"2022-07-20T08:46:47.633755Z","shell.execute_reply.started":"2022-07-20T08:46:47.622409Z","shell.execute_reply":"2022-07-20T08:46:47.632504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# LOAD TRANSFORMERS MODEL","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.637031Z","iopub.execute_input":"2022-07-20T08:46:47.637722Z","iopub.status.idle":"2022-07-20T08:46:47.644042Z","shell.execute_reply.started":"2022-07-20T08:46:47.637678Z","shell.execute_reply":"2022-07-20T08:46:47.642260Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_path = \"microsoft/deberta-v3-large\"","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.651495Z","iopub.execute_input":"2022-07-20T08:46:47.651812Z","iopub.status.idle":"2022-07-20T08:46:47.657130Z","shell.execute_reply.started":"2022-07-20T08:46:47.651780Z","shell.execute_reply":"2022-07-20T08:46:47.655605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=True)\ndata_collator = DataCollatorWithPadding(tokenizer=tokenizer)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:46:47.659099Z","iopub.execute_input":"2022-07-20T08:46:47.660074Z","iopub.status.idle":"2022-07-20T08:46:54.996120Z","shell.execute_reply.started":"2022-07-20T08:46:47.660028Z","shell.execute_reply":"2022-07-20T08:46:54.994719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def tokenize_function(examples):\n    return tokenizer(examples[\"complete_text\"], padding=\"max_length\", truncation=True, max_length=512)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:48:11.029209Z","iopub.execute_input":"2022-07-20T08:48:11.030160Z","iopub.status.idle":"2022-07-20T08:48:11.042404Z","shell.execute_reply.started":"2022-07-20T08:48:11.030086Z","shell.execute_reply":"2022-07-20T08:48:11.040718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset = Dataset.from_pandas(df_train)\nval_dataset = Dataset.from_pandas(df_val)\n\ntokenized_train = train_dataset.map(tokenize_function, batched=True)\ntokenized_val = val_dataset.map(tokenize_function, batched=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:48:11.653893Z","iopub.execute_input":"2022-07-20T08:48:11.654911Z","iopub.status.idle":"2022-07-20T08:51:54.017420Z","shell.execute_reply.started":"2022-07-20T08:48:11.654859Z","shell.execute_reply":"2022-07-20T08:51:54.016212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def freeze(module):\n    \"\"\"\n    Freezes module's parameters.\n    \"\"\"\n    \n    for parameter in module.parameters():\n        parameter.requires_grad = False\n        \ndef get_freezed_parameters(module):\n    \"\"\"\n    Returns names of freezed parameters of the given module.\n    \"\"\"\n    \n    freezed_parameters = []\n    for name, parameter in module.named_parameters():\n        if not parameter.requires_grad:\n            freezed_parameters.append(name)\n            \n    return freezed_parameters\n\nconfig = AutoConfig.from_pretrained(model_path)\nconfig.num_labels = 3\nmodel = AutoModelForSequenceClassification.from_pretrained(model_path,config=config)\n\nfreeze(model.deberta.embeddings)\n#freeze(model.deberta.encoder.layer[:4])\n\nfreezed_parameters = get_freezed_parameters(model)\nprint(f\"Freezed parameters: {freezed_parameters}\")\n","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:54:19.915760Z","iopub.execute_input":"2022-07-20T08:54:19.916425Z","iopub.status.idle":"2022-07-20T08:54:26.673121Z","shell.execute_reply.started":"2022-07-20T08:54:19.916381Z","shell.execute_reply":"2022-07-20T08:54:26.671575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_args = TrainingArguments(\n    output_dir=\"./results\",\n    learning_rate=2e-5,\n    per_device_train_batch_size=4,\n    gradient_accumulation_steps=16,\n    gradient_checkpointing=True,\n    fp16=True,\n    per_device_eval_batch_size=4,\n    num_train_epochs=3,\n    weight_decay=0.01,\n)\n\ndecay_parameters = get_parameter_names(model, [nn.LayerNorm])\ndecay_parameters = [name for name in decay_parameters if \"bias\" not in name]\noptimizer_grouped_parameters = [\n    {\n        \"params\": [p for n, p in model.named_parameters() if n in decay_parameters],\n        \"weight_decay\": training_args.weight_decay,\n    },\n    {\n        \"params\": [p for n, p in model.named_parameters() if n not in decay_parameters],\n        \"weight_decay\": 0.0,\n    },\n]\n\noptimizer_kwargs = {\n    \"betas\": (training_args.adam_beta1, training_args.adam_beta2),\n    \"eps\": training_args.adam_epsilon,\n}\noptimizer_kwargs[\"lr\"] = training_args.learning_rate\nadam_bnb_optim = bnb.optim.Adam8bit(\n    optimizer_grouped_parameters,\n    betas=(training_args.adam_beta1, training_args.adam_beta2),\n    eps=training_args.adam_epsilon,\n    lr=training_args.learning_rate,\n)\n","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainer = Trainer(\n    model=model,\n    args=training_args,\n    train_dataset=tokenized_train,\n    eval_dataset=tokenized_val,\n    tokenizer=tokenizer,\n    data_collator=data_collator,\n    optimizers=(adam_bnb_optim, None)\n)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:53:17.544813Z","iopub.status.idle":"2022-07-20T08:53:17.545745Z","shell.execute_reply.started":"2022-07-20T08:53:17.545365Z","shell.execute_reply":"2022-07-20T08:53:17.545404Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainer.train()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:53:17.548519Z","iopub.status.idle":"2022-07-20T08:53:17.549438Z","shell.execute_reply.started":"2022-07-20T08:53:17.548935Z","shell.execute_reply":"2022-07-20T08:53:17.548982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainer.evaluate()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T08:53:17.551913Z","iopub.status.idle":"2022-07-20T08:53:17.553140Z","shell.execute_reply.started":"2022-07-20T08:53:17.552771Z","shell.execute_reply":"2022-07-20T08:53:17.552825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainer.save_model(\"./results/trained_model\")","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:25:12.23671Z","iopub.execute_input":"2022-07-19T14:25:12.237386Z","iopub.status.idle":"2022-07-19T14:25:12.80167Z","shell.execute_reply.started":"2022-07-19T14:25:12.237349Z","shell.execute_reply":"2022-07-19T14:25:12.800724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# INFERENCE","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:04:26.147246Z","iopub.execute_input":"2022-07-19T14:04:26.147602Z","iopub.status.idle":"2022-07-19T14:04:26.152303Z","shell.execute_reply.started":"2022-07-19T14:04:26.147571Z","shell.execute_reply":"2022-07-19T14:04:26.150942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trained_tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=True)\ntrained_data_collator = DataCollatorWithPadding(tokenizer=trained_tokenizer)\ntrained_model = AutoModelForSequenceClassification.from_pretrained(\"./results/trained_model\")","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:30:48.335438Z","iopub.execute_input":"2022-07-19T14:30:48.335845Z","iopub.status.idle":"2022-07-19T14:30:58.231947Z","shell.execute_reply.started":"2022-07-19T14:30:48.335814Z","shell.execute_reply":"2022-07-19T14:30:58.231015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def tokenize_test_function(examples):\n    return trained_tokenizer(examples[\"complete_text\"], padding=\"max_length\", truncation=True, max_length=512)\n\ntest_dataset = Dataset.from_pandas(test)\n\ntokenized_test = test_dataset.map(tokenize_function, batched=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:31:01.11444Z","iopub.execute_input":"2022-07-19T14:31:01.115465Z","iopub.status.idle":"2022-07-19T14:31:01.188647Z","shell.execute_reply.started":"2022-07-19T14:31:01.115418Z","shell.execute_reply":"2022-07-19T14:31:01.187683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_args = TrainingArguments(\n    output_dir=\"./results\",\n    learning_rate=2e-5,\n    per_device_train_batch_size=4,\n    per_device_eval_batch_size=4,\n    num_train_epochs=3,\n    weight_decay=0.01,\n    save_strategy=\"no\"\n)\n\ntrainer = Trainer(\n    model=trained_model,\n    args=training_args,\n    tokenizer=trained_tokenizer,\n    data_collator=trained_data_collator,\n)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:31:04.335523Z","iopub.execute_input":"2022-07-19T14:31:04.336571Z","iopub.status.idle":"2022-07-19T14:31:04.421011Z","shell.execute_reply.started":"2022-07-19T14:31:04.336523Z","shell.execute_reply":"2022-07-19T14:31:04.420065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"outputs = trainer.predict(tokenized_test)\nsoftmax_outputs = softmax(outputs.predictions, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:33:33.554859Z","iopub.execute_input":"2022-07-19T14:33:33.555885Z","iopub.status.idle":"2022-07-19T14:33:33.687581Z","shell.execute_reply.started":"2022-07-19T14:33:33.555835Z","shell.execute_reply":"2022-07-19T14:33:33.686536Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"softmax_outputs","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:33:37.186893Z","iopub.execute_input":"2022-07-19T14:33:37.187372Z","iopub.status.idle":"2022-07-19T14:33:37.196581Z","shell.execute_reply.started":"2022-07-19T14:33:37.187326Z","shell.execute_reply":"2022-07-19T14:33:37.195457Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels = [\"Ineffective\", \"Adequate\", \"Effective\"]\noutput_df = pd.concat([test[['discourse_id']], pd.DataFrame(softmax_outputs, columns=labels)], axis=1)\noutput_df.to_csv('submission.csv', index=False)\npd.read_csv('submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:35:03.939415Z","iopub.execute_input":"2022-07-19T14:35:03.940045Z","iopub.status.idle":"2022-07-19T14:35:03.975907Z","shell.execute_reply.started":"2022-07-19T14:35:03.93999Z","shell.execute_reply":"2022-07-19T14:35:03.974878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from IPython.display import FileLink\nFileLink(r'submission.csv')\n","metadata":{"execution":{"iopub.status.busy":"2022-07-19T14:35:58.138174Z","iopub.execute_input":"2022-07-19T14:35:58.138768Z","iopub.status.idle":"2022-07-19T14:35:58.146748Z","shell.execute_reply.started":"2022-07-19T14:35:58.138724Z","shell.execute_reply":"2022-07-19T14:35:58.145669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}