{"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\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-05-23T07:44:45.367168Z","iopub.execute_input":"2021-05-23T07:44:45.367553Z","iopub.status.idle":"2021-05-23T07:44:58.997955Z","shell.execute_reply.started":"2021-05-23T07:44:45.367466Z","shell.execute_reply":"2021-05-23T07:44:58.978594Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"This notebook gives a simple combination of literal matching and Named Entity Recognition using BERT (base model from huggingface).\n\nTraining of ner Bert model is done in \n\nInspiration for this notebook - https://www.kaggle.com/tungmphung/coleridge-matching-bert-ner \n\n\n","metadata":{}},{"cell_type":"markdown","source":"# The training code can be found at - https://www.kaggle.com/ash1706/train-bert-base-ner","metadata":{}},{"cell_type":"code","source":"MAX_SAMPLE = None # set a small number for experimentation, set None for production.","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:44:58.999407Z","iopub.execute_input":"2021-05-23T07:44:58.999746Z","iopub.status.idle":"2021-05-23T07:44:59.004551Z","shell.execute_reply.started":"2021-05-23T07:44:58.99971Z","shell.execute_reply":"2021-05-23T07:44:59.003638Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install datasets --no-index --find-links=file:///kaggle/input/coleridge-packages/packages/datasets\n!pip install ../input/coleridge-packages/seqeval-1.2.2-py3-none-any.whl\n!pip install ../input/coleridge-packages/tokenizers-0.10.1-cp37-cp37m-manylinux1_x86_64.whl\n!pip install ../input/coleridge-packages/transformers-4.5.0.dev0-py3-none-any.whl","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2021-05-23T07:44:59.006628Z","iopub.execute_input":"2021-05-23T07:44:59.007006Z","iopub.status.idle":"2021-05-23T07:46:26.341483Z","shell.execute_reply.started":"2021-05-23T07:44:59.006954Z","shell.execute_reply":"2021-05-23T07:46:26.340531Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport re\nimport json\nimport time\nimport datetime\nimport random\nimport glob\nimport importlib\n\nimport numpy as np\nimport pandas as pd\n\nfrom tqdm import tqdm\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nrandom.seed(123)\nnp.random.seed(456)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:46:26.3434Z","iopub.execute_input":"2021-05-23T07:46:26.34374Z","iopub.status.idle":"2021-05-23T07:46:27.045606Z","shell.execute_reply.started":"2021-05-23T07:46:26.3437Z","shell.execute_reply":"2021-05-23T07:46:27.044739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_path = '../input/coleridgeinitiative-show-us-the-data/train.csv'\ntrain = pd.read_csv(train_path)\ntrain = train[:MAX_SAMPLE]\n\npaper_train_folder = '../input/coleridgeinitiative-show-us-the-data/train'\npapers = {}\nfor paper_id in train['Id'].unique():\n    with open(f'{paper_train_folder}/{paper_id}.json', 'r') as f:\n        paper = json.load(f)\n        papers[paper_id] = paper","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:46:27.046848Z","iopub.execute_input":"2021-05-23T07:46:27.047278Z","iopub.status.idle":"2021-05-23T07:47:20.488793Z","shell.execute_reply.started":"2021-05-23T07:46:27.047241Z","shell.execute_reply":"2021-05-23T07:47:20.487876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission_path = '../input/coleridgeinitiative-show-us-the-data/sample_submission.csv'\nsample_submission = pd.read_csv(sample_submission_path)\n\npaper_test_folder = '../input/coleridgeinitiative-show-us-the-data/test'\nfor paper_id in sample_submission['Id']:\n    with open(f'{paper_test_folder}/{paper_id}.json', 'r') as f:\n        paper = json.load(f)\n        papers[paper_id] = paper","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:20.490142Z","iopub.execute_input":"2021-05-23T07:47:20.490487Z","iopub.status.idle":"2021-05-23T07:47:20.516737Z","shell.execute_reply.started":"2021-05-23T07:47:20.49045Z","shell.execute_reply":"2021-05-23T07:47:20.51601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"extra_labels = pd.read_csv('../input/bigger-govt-dataset-list/data_set_26897.csv')","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:20.51791Z","iopub.execute_input":"2021-05-23T07:47:20.518268Z","iopub.status.idle":"2021-05-23T07:47:20.594511Z","shell.execute_reply.started":"2021-05-23T07:47:20.518233Z","shell.execute_reply":"2021-05-23T07:47:20.593711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"extra_labels.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:20.597226Z","iopub.execute_input":"2021-05-23T07:47:20.597606Z","iopub.status.idle":"2021-05-23T07:47:20.613405Z","shell.execute_reply.started":"2021-05-23T07:47:20.59757Z","shell.execute_reply":"2021-05-23T07:47:20.612359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Litral Matching with some external dataset (Checkout the input folder for more info) ","metadata":{}},{"cell_type":"code","source":"all_labels = set()\n\nfor label_1, label_2, label_3 in train[['dataset_title', 'dataset_label', 'cleaned_label']].itertuples(index=False):\n    all_labels.add(str(label_1).lower())\n    all_labels.add(str(label_2).lower())\n    all_labels.add(str(label_3).lower())\n\nfor label_1 in extra_labels[['title']].itertuples(index=False):\n    all_labels.add(str(label_1).lower())\nprint(f'No. different labels: {len(all_labels)}')\n","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:20.615494Z","iopub.execute_input":"2021-05-23T07:47:20.615912Z","iopub.status.idle":"2021-05-23T07:47:20.746085Z","shell.execute_reply.started":"2021-05-23T07:47:20.615873Z","shell.execute_reply":"2021-05-23T07:47:20.745081Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def clean_text(txt):\n    return re.sub('[^A-Za-z0-9]+', ' ', str(txt).lower()).strip()\n\ndef totally_clean_text(txt):\n    txt = clean_text(txt)\n    txt = re.sub(' +', ' ', txt)\n    return txt","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:20.747348Z","iopub.execute_input":"2021-05-23T07:47:20.74772Z","iopub.status.idle":"2021-05-23T07:47:20.752769Z","shell.execute_reply.started":"2021-05-23T07:47:20.747682Z","shell.execute_reply":"2021-05-23T07:47:20.751755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"literal_preds = []\n\nfor paper_id in sample_submission['Id']:\n    paper = papers[paper_id]\n    text_1 = '. '.join(section['text'] for section in paper).lower()\n    text_2 = totally_clean_text(text_1)\n    \n    labels = set()\n    for label in all_labels:\n        if label in text_1 or label in text_2:\n            labels.add(clean_text(label))\n    \n    literal_preds.append('|'.join(labels))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:20.754008Z","iopub.execute_input":"2021-05-23T07:47:20.754393Z","iopub.status.idle":"2021-05-23T07:47:26.654933Z","shell.execute_reply.started":"2021-05-23T07:47:20.754347Z","shell.execute_reply":"2021-05-23T07:47:26.654066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"literal_preds[:5]","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:26.656154Z","iopub.execute_input":"2021-05-23T07:47:26.656529Z","iopub.status.idle":"2021-05-23T07:47:26.662558Z","shell.execute_reply.started":"2021-05-23T07:47:26.656493Z","shell.execute_reply":"2021-05-23T07:47:26.661569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Bert Model\nsome more work could be done in bert model (ner-model i input dir) it seems to overfit","metadata":{}},{"cell_type":"code","source":"MAX_LENGTH = 64 # max no. words for each sentence.\nOVERLAP = 20 # if a sentence exceeds MAX_LENGTH, we split it to multiple sentences with overlapping\n\nPREDICT_BATCH = 64000 \n\nPRETRAINED_PATH = '../input/ner-model/output'\nTEST_INPUT_SAVE_PATH = './input_data'\nTEST_NER_DATA_FILE = 'test_ner_input.json'\nTRAIN_PATH = '../input/ner-model/train_ner.json'\nVAL_PATH = '../input/ner-model/train_ner.json'\n\nPREDICTION_SAVE_PATH = './pred'\nPREDICTION_FILE = 'test_predictions.txt'","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:26.664068Z","iopub.execute_input":"2021-05-23T07:47:26.664453Z","iopub.status.idle":"2021-05-23T07:47:26.672186Z","shell.execute_reply.started":"2021-05-23T07:47:26.664416Z","shell.execute_reply":"2021-05-23T07:47:26.671147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = train.groupby('Id').agg({\n    'pub_title': 'first',\n    'dataset_title': '|'.join,\n    'dataset_label': '|'.join,\n    'cleaned_label': '|'.join\n}).reset_index()\n\nprint(f'No. grouped training rows: {len(train)}')","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:26.673419Z","iopub.execute_input":"2021-05-23T07:47:26.673851Z","iopub.status.idle":"2021-05-23T07:47:27.035343Z","shell.execute_reply.started":"2021-05-23T07:47:26.673818Z","shell.execute_reply":"2021-05-23T07:47:27.034253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def clean_training_text(txt):\n    \"\"\"\n    similar to the default clean_text function but without lowercasing.\n    \"\"\"\n    return re.sub('[^A-Za-z0-9]+', ' ', str(txt)).strip()\n\ndef shorten_sentences(sentences):\n    short_sentences = []\n    for sentence in sentences:\n        words = sentence.split()\n        if len(words) > MAX_LENGTH:\n            for p in range(0, len(words), MAX_LENGTH - OVERLAP):\n                short_sentences.append(' '.join(words[p:p+MAX_LENGTH]))\n        else:\n            short_sentences.append(sentence)\n    return short_sentences","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:27.036838Z","iopub.execute_input":"2021-05-23T07:47:27.037212Z","iopub.status.idle":"2021-05-23T07:47:27.04383Z","shell.execute_reply.started":"2021-05-23T07:47:27.037171Z","shell.execute_reply":"2021-05-23T07:47:27.042731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_rows = [] # test data in NER format\npaper_length = [] # store the number of sentences each paper has\n\nfor paper_id in sample_submission['Id']:\n    # load paper\n    paper = papers[paper_id]\n    \n    # extract sentences\n    sentences = [clean_training_text(sentence) for section in paper \n                 for sentence in section['text'].split('.')\n                ]\n    sentences = shorten_sentences(sentences) # make sentences short\n    sentences = [sentence for sentence in sentences if len(sentence) > 10] # only accept sentences with length > 10 chars\n    sentences = [sentence for sentence in sentences if any(word in sentence.lower() for word in ['data', 'study'])]\n        \n    # collect all sentences in json\n    for sentence in sentences:\n        sentence_words = sentence.split()\n        dummy_tags = ['O']*len(sentence_words)\n        test_rows.append({'tokens' : sentence_words, 'tags' : dummy_tags})\n    \n    # track which sentence belongs to which data point\n    paper_length.append(len(sentences))\n    \nprint(f'total number of sentences: {len(test_rows)}')","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:27.045346Z","iopub.execute_input":"2021-05-23T07:47:27.045736Z","iopub.status.idle":"2021-05-23T07:47:27.094314Z","shell.execute_reply.started":"2021-05-23T07:47:27.0457Z","shell.execute_reply":"2021-05-23T07:47:27.093487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.environ[\"MODEL_PATH\"] = f\"{PRETRAINED_PATH}\"\nos.environ[\"TRAIN_FILE\"] = f\"{TRAIN_PATH}\"\nos.environ[\"VALIDATION_FILE\"] = f\"{VAL_PATH}\"\nos.environ[\"TEST_FILE\"] = f\"{TEST_INPUT_SAVE_PATH}/{TEST_NER_DATA_FILE}\"\nos.environ[\"OUTPUT_DIR\"] = f\"{PREDICTION_SAVE_PATH}\"","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:27.09547Z","iopub.execute_input":"2021-05-23T07:47:27.095794Z","iopub.status.idle":"2021-05-23T07:47:27.100748Z","shell.execute_reply.started":"2021-05-23T07:47:27.09576Z","shell.execute_reply":"2021-05-23T07:47:27.099815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# copy my_seqeval.py to the working directory because the input directory is non-writable\n!cp /kaggle/input/coleridge-packages/my_seqeval.py ./\n\n# make necessart directories and files\nos.makedirs(TEST_INPUT_SAVE_PATH, exist_ok=True)\n","metadata":{"execution":{"iopub.status.busy":"2021-05-23T07:47:27.102108Z","iopub.execute_input":"2021-05-23T07:47:27.102488Z","iopub.status.idle":"2021-05-23T07:47:27.762897Z","shell.execute_reply.started":"2021-05-23T07:47:27.102453Z","shell.execute_reply":"2021-05-23T07:47:27.761833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def bert_predict():\n    !python ../input/kaggle-ner-utils/kaggle_run_ner.py \\\n    --model_name_or_path \"$MODEL_PATH\" \\\n    --train_file \"$TRAIN_FILE\" \\\n    --validation_file \"$VALIDATION_FILE\" \\\n    --test_file \"$TEST_FILE\" \\\n    --output_dir \"$OUTPUT_DIR\" \\\n    --report_to 'none' \\\n    --seed 123 \\\n    --do_predict","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:01:22.666739Z","iopub.execute_input":"2021-05-23T08:01:22.667114Z","iopub.status.idle":"2021-05-23T08:01:22.67258Z","shell.execute_reply.started":"2021-05-23T08:01:22.667081Z","shell.execute_reply":"2021-05-23T08:01:22.671491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install --upgrade git+https://github.com/intake/filesystem_spec","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:02:17.098397Z","iopub.execute_input":"2021-05-23T08:02:17.098749Z","iopub.status.idle":"2021-05-23T08:02:33.761918Z","shell.execute_reply.started":"2021-05-23T08:02:17.09872Z","shell.execute_reply":"2021-05-23T08:02:33.760957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bert_outputs = []\nfor batch_begin in range(0, len(test_rows), PREDICT_BATCH):\n    # write data rows to input file\n    with open(f'{TEST_INPUT_SAVE_PATH}/{TEST_NER_DATA_FILE}', 'w') as f:\n        for row in test_rows[batch_begin:batch_begin+PREDICT_BATCH]:\n            json.dump(row, f)\n            f.write('\\n')\n    \n    # remove output dir\n    !rm -r \"$OUTPUT_DIR\"\n    \n    # do predict\n    bert_predict()\n    \n    # read predictions\n    with open(f'{PREDICTION_SAVE_PATH}/{PREDICTION_FILE}') as f:\n        this_preds = f.read().split('\\n')[:-1]\n        bert_outputs += [pred.split() for pred in this_preds]","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:02:33.765388Z","iopub.execute_input":"2021-05-23T08:02:33.765654Z","iopub.status.idle":"2021-05-23T08:03:09.073338Z","shell.execute_reply.started":"2021-05-23T08:02:33.765625Z","shell.execute_reply":"2021-05-23T08:03:09.072436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Restore Dataset labels from predictions","metadata":{}},{"cell_type":"code","source":"# get test sentences\ntest_sentences = [row['tokens'] for row in test_rows]\n\ndel test_rows","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.07529Z","iopub.execute_input":"2021-05-23T08:03:09.075607Z","iopub.status.idle":"2021-05-23T08:03:09.083688Z","shell.execute_reply.started":"2021-05-23T08:03:09.075576Z","shell.execute_reply":"2021-05-23T08:03:09.082867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bert_dataset_labels = [] # store all dataset labels for each publication\n\nfor length in paper_length:\n    labels = set()\n    for sentence, pred in zip(test_sentences[:length], bert_outputs[:length]):\n        curr_phrase = ''\n        for word, tag in zip(sentence, pred):\n            if tag == 'B': # start a new phrase\n                if curr_phrase:\n                    labels.add(curr_phrase)\n                    curr_phrase = ''\n                curr_phrase = word\n            elif tag == 'I' and curr_phrase: # continue the phrase\n                curr_phrase += ' ' + word\n            else: # end last phrase (if any)\n                if curr_phrase:\n                    labels.add(curr_phrase)\n                    curr_phrase = ''\n        # check if the label is the suffix of the sentence\n        if curr_phrase:\n            labels.add(curr_phrase)\n            curr_phrase = ''\n    \n    # record dataset labels for this publication\n    bert_dataset_labels.append(labels)\n    \n    del test_sentences[:length], bert_outputs[:length]\n","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.085491Z","iopub.execute_input":"2021-05-23T08:03:09.085787Z","iopub.status.idle":"2021-05-23T08:03:09.101715Z","shell.execute_reply.started":"2021-05-23T08:03:09.085732Z","shell.execute_reply":"2021-05-23T08:03:09.100866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bert_dataset_labels[:5]","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.103152Z","iopub.execute_input":"2021-05-23T08:03:09.10351Z","iopub.status.idle":"2021-05-23T08:03:09.111629Z","shell.execute_reply.started":"2021-05-23T08:03:09.103477Z","shell.execute_reply":"2021-05-23T08:03:09.110768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Filter based on Jaccard score and clean","metadata":{}},{"cell_type":"code","source":"def jaccard_similarity(s1, s2):\n    l1 = s1.split(\" \")\n    l2 = s2.split(\" \")    \n    intersection = len(list(set(l1).intersection(l2)))\n    union = (len(l1) + len(l2)) - intersection\n    return float(intersection) / union\n\nfiltered_bert_labels = []\n\nfor labels in bert_dataset_labels:\n    filtered = []\n    \n    for label in sorted(labels, key=len):\n        label = clean_text(label)\n        if len(filtered) == 0 or all(jaccard_similarity(label, got_label) < 0.75 for got_label in filtered):\n            filtered.append(label)\n    \n    filtered_bert_labels.append('|'.join(filtered))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.113053Z","iopub.execute_input":"2021-05-23T08:03:09.113444Z","iopub.status.idle":"2021-05-23T08:03:09.121492Z","shell.execute_reply.started":"2021-05-23T08:03:09.113409Z","shell.execute_reply":"2021-05-23T08:03:09.120594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"filtered_bert_labels[:5]","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.122663Z","iopub.execute_input":"2021-05-23T08:03:09.12314Z","iopub.status.idle":"2021-05-23T08:03:09.13519Z","shell.execute_reply.started":"2021-05-23T08:03:09.123105Z","shell.execute_reply":"2021-05-23T08:03:09.134424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_predictions = []\nfor literal_match, bert_pred in zip(literal_preds, filtered_bert_labels):\n    if literal_match:\n        final_predictions.append(literal_match)\n    else:\n        final_predictions.append(bert_pred)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.138677Z","iopub.execute_input":"2021-05-23T08:03:09.13896Z","iopub.status.idle":"2021-05-23T08:03:09.143314Z","shell.execute_reply.started":"2021-05-23T08:03:09.138936Z","shell.execute_reply":"2021-05-23T08:03:09.142464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission['PredictionString'] = final_predictions\nsample_submission.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.144799Z","iopub.execute_input":"2021-05-23T08:03:09.145386Z","iopub.status.idle":"2021-05-23T08:03:09.158583Z","shell.execute_reply.started":"2021-05-23T08:03:09.145335Z","shell.execute_reply":"2021-05-23T08:03:09.157538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.to_csv(f'submission.csv', index=False)\n","metadata":{"execution":{"iopub.status.busy":"2021-05-23T08:03:09.16024Z","iopub.execute_input":"2021-05-23T08:03:09.160633Z","iopub.status.idle":"2021-05-23T08:03:09.377999Z","shell.execute_reply.started":"2021-05-23T08:03:09.160597Z","shell.execute_reply":"2021-05-23T08:03:09.377223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"raw","source":"turn off the internet while submiting","metadata":{}},{"cell_type":"markdown","source":"# Thanks for reading !!!!\n#  If this helped please consider leaving a upvote !!!!!!!!","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}