{"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-06-04T22:19:30.181256Z","iopub.execute_input":"2021-06-04T22:19:30.181605Z","iopub.status.idle":"2021-06-04T22:19:31.748271Z","shell.execute_reply.started":"2021-06-04T22:19:30.181570Z","shell.execute_reply":"2021-06-04T22:19:31.747210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Competition Objective**\nThis competition (The Coleridge Competition) seeks to predict the mentioning of datasets in scientific articles. The use of these predictions is to tie it to policymaking driven by data. \n\nSubmissions for this competition need to include the id of the article and a string justifying the prediction (cleaned using the clean_text() function that is provided. Our model needs to predict this string.","metadata":{}},{"cell_type":"code","source":"# Imports\nimport json\nimport os\nimport glob\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom nltk.corpus import stopwords\n\nimport re\nimport string\n\nfrom wordcloud import WordCloud, STOPWORDS","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:19:31.752047Z","iopub.execute_input":"2021-06-04T22:19:31.752313Z","iopub.status.idle":"2021-06-04T22:19:33.474686Z","shell.execute_reply.started":"2021-06-04T22:19:31.752280Z","shell.execute_reply":"2021-06-04T22:19:33.473942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Take a look at the training data\ntrain_0 = pd.read_json('/kaggle/input/coleridgeinitiative-show-us-the-data/train/f8b03c87-9d1a-4f20-b76b-cb6c69d447b2.json')\ntrain_csv = pd.read_csv('/kaggle/input/coleridgeinitiative-show-us-the-data/train.csv')","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:19:33.475887Z","iopub.execute_input":"2021-06-04T22:19:33.476292Z","iopub.status.idle":"2021-06-04T22:19:33.728872Z","shell.execute_reply.started":"2021-06-04T22:19:33.476255Z","shell.execute_reply":"2021-06-04T22:19:33.727861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_csv","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:19:33.730125Z","iopub.execute_input":"2021-06-04T22:19:33.730398Z","iopub.status.idle":"2021-06-04T22:19:33.754132Z","shell.execute_reply.started":"2021-06-04T22:19:33.730350Z","shell.execute_reply":"2021-06-04T22:19:33.753205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Take a look at the title of the first document\ntrain_csv.pub_title[0]","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:22:13.841912Z","iopub.execute_input":"2021-06-04T22:22:13.842488Z","iopub.status.idle":"2021-06-04T22:22:13.846906Z","shell.execute_reply.started":"2021-06-04T22:22:13.842452Z","shell.execute_reply":"2021-06-04T22:22:13.846306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Notes about the Training data**\n**train.csv** is a file linking the publication and datasets referenced. We find the publication texts in the individual .json files. As for the test data, we have 4 articles to parse and link to datasets. From what I understand now, we have to find strings within the articles' text that we find are likely to be references to datasets.","metadata":{}},{"cell_type":"markdown","source":"# **Exploratory Data Analysis (EDA)**","metadata":{}},{"cell_type":"code","source":"# Show how many different articles are in the training set, and how many datasets are referenced.\nprint(f'There are {len(train_csv.Id.unique())} different articles and {len(train_csv.cleaned_label.unique())} different datasets.')","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:24:32.226544Z","iopub.execute_input":"2021-06-04T22:24:32.226925Z","iopub.status.idle":"2021-06-04T22:24:32.236489Z","shell.execute_reply.started":"2021-06-04T22:24:32.226892Z","shell.execute_reply":"2021-06-04T22:24:32.235473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Distribution of publications and datasets","metadata":{}},{"cell_type":"code","source":"sns.countplot(x=train_csv.Id.value_counts())","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:26:14.287636Z","iopub.execute_input":"2021-06-04T22:26:14.287981Z","iopub.status.idle":"2021-06-04T22:26:14.491961Z","shell.execute_reply.started":"2021-06-04T22:26:14.287951Z","shell.execute_reply":"2021-06-04T22:26:14.491296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(13, 6))\nfig.suptitle('Distribution of articles and datasets', fontsize=20)\n\nax0 = plt.subplot2grid((1, 2), (0, 0))\nax1 = plt.subplot2grid((1, 2), (0, 1))\n\nax0.hist(train_csv.Id.value_counts())\nax0.set_xlabel(\"# of linked datasets by article\")\nax0.set_ylabel(\"# of articles\")\n\nax1.hist(train_csv.cleaned_label.value_counts())\nax1.set_xlabel(\"# of occurences of datasets in articles\")\nax1.set_ylabel(\"# of datasets\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:26:40.723183Z","iopub.execute_input":"2021-06-04T22:26:40.723671Z","iopub.status.idle":"2021-06-04T22:26:41.007047Z","shell.execute_reply.started":"2021-06-04T22:26:40.723640Z","shell.execute_reply":"2021-06-04T22:26:41.006237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(x=train_csv.Id.value_counts())","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:27:02.430311Z","iopub.execute_input":"2021-06-04T22:27:02.430660Z","iopub.status.idle":"2021-06-04T22:27:02.799071Z","shell.execute_reply.started":"2021-06-04T22:27:02.430632Z","shell.execute_reply":"2021-06-04T22:27:02.798447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(x=train_csv.cleaned_label.value_counts())","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:27:19.182920Z","iopub.execute_input":"2021-06-04T22:27:19.183565Z","iopub.status.idle":"2021-06-04T22:27:19.326734Z","shell.execute_reply.started":"2021-06-04T22:27:19.183515Z","shell.execute_reply":"2021-06-04T22:27:19.325716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Conclusion:** The distribution of linked datasets by articles is much less smoother than that of articles by datasets.","metadata":{}},{"cell_type":"markdown","source":"Let's look at the format of the articles","metadata":{}},{"cell_type":"code","source":"article0 = pd.read_json('/kaggle/input/coleridgeinitiative-show-us-the-data/train/d0fa7568-7d8e-4db9-870f-f9c6f668c17b.json')","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:29:02.522247Z","iopub.execute_input":"2021-06-04T22:29:02.522820Z","iopub.status.idle":"2021-06-04T22:29:02.542313Z","shell.execute_reply.started":"2021-06-04T22:29:02.522788Z","shell.execute_reply":"2021-06-04T22:29:02.541433Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article0","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:29:15.974898Z","iopub.execute_input":"2021-06-04T22:29:15.975219Z","iopub.status.idle":"2021-06-04T22:29:15.985180Z","shell.execute_reply.started":"2021-06-04T22:29:15.975189Z","shell.execute_reply":"2021-06-04T22:29:15.984464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We can see above that this first article has 18 \"section titles\". The text from that section title is listed above to left of each section title.","metadata":{}},{"cell_type":"code","source":"# Display text of the first article\narticle0.text[0]","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:31:37.022940Z","iopub.execute_input":"2021-06-04T22:31:37.023258Z","iopub.status.idle":"2021-06-04T22:31:37.029062Z","shell.execute_reply.started":"2021-06-04T22:31:37.023231Z","shell.execute_reply":"2021-06-04T22:31:37.028299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Display the paragraph titles in a different way than above\nfor sentence in article0.section_title:\n    print(''.join(sentence))","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:32:07.870318Z","iopub.execute_input":"2021-06-04T22:32:07.870800Z","iopub.status.idle":"2021-06-04T22:32:07.878038Z","shell.execute_reply.started":"2021-06-04T22:32:07.870771Z","shell.execute_reply":"2021-06-04T22:32:07.876814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Let's visualize the training data","metadata":{}},{"cell_type":"code","source":"train_csv = pd.read_csv('../input/coleridgeinitiative-show-us-the-data/train.csv')","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:33:00.398696Z","iopub.execute_input":"2021-06-04T22:33:00.399008Z","iopub.status.idle":"2021-06-04T22:33:00.475630Z","shell.execute_reply.started":"2021-06-04T22:33:00.398980Z","shell.execute_reply":"2021-06-04T22:33:00.474894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stopwords = set(STOPWORDS)\n\nwordcloud = WordCloud(background_color='white',\n                      stopwords=stopwords,\n                      max_words=200,\n                      max_font_size=30,\n                      scale=3,\n                      random_state=1)\n   \ncloud = wordcloud.generate(str(train_csv['dataset_title'].unique()))\n\nfig = plt.figure(figsize=(15, 15))\nplt.axis('off')\nplt.imshow(cloud)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:39:25.590504Z","iopub.execute_input":"2021-06-04T22:39:25.590949Z","iopub.status.idle":"2021-06-04T22:39:26.145654Z","shell.execute_reply.started":"2021-06-04T22:39:25.590917Z","shell.execute_reply":"2021-06-04T22:39:26.144764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The above wordcloud looks at the top 200 words in the corpus after stopwords (placeholder words) have been removed. We can see that there is a depth of various kinds of words, both in the frequency and the topics. This is what we might expect to find.","metadata":{}},{"cell_type":"markdown","source":"# Data Retrieval and Cleaning","metadata":{}},{"cell_type":"code","source":"# Imports, which repeats some of the previous imports, in case we remove that section\nimport json\nimport os\nimport re\n\nimport numpy\nimport pandas\nfrom fuzzywuzzy import fuzz\nfrom sklearn.model_selection import train_test_split\nfrom nltk.corpus import stopwords","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:52:03.272520Z","iopub.execute_input":"2021-06-04T22:52:03.272844Z","iopub.status.idle":"2021-06-04T22:52:03.278034Z","shell.execute_reply.started":"2021-06-04T22:52:03.272817Z","shell.execute_reply":"2021-06-04T22:52:03.277364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Retrieve the training data and sample submission\ndirectory = r\"../input/coleridgeinitiative-show-us-the-data/\"\n\ntrain_csv = pandas.read_csv(directory + \"/train.csv\")\nsample_submission = pandas.read_csv(directory + \"/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:52:05.202787Z","iopub.execute_input":"2021-06-04T22:52:05.203309Z","iopub.status.idle":"2021-06-04T22:52:05.275310Z","shell.execute_reply.started":"2021-06-04T22:52:05.203274Z","shell.execute_reply":"2021-06-04T22:52:05.274558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def retrieve_text(filename, type):\n    json_path = os.path.join(directory, type, filename + \".json\")\n\n    section_title = []\n    contents = []\n    with open(json_path, mode='r') as recurse:\n        json_contents = json.load(recurse)\n\n        for data in json_contents:\n            contents.append(data.get('section_title'))\n            contents.append(data.get('text'))\n\n        # section_title = data_cleaning(\" \".join(section_title))\n        contents = data_cleaning(\" \".join(contents))\n\n    return contents","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:52:09.951452Z","iopub.execute_input":"2021-06-04T22:52:09.951764Z","iopub.status.idle":"2021-06-04T22:52:09.958031Z","shell.execute_reply.started":"2021-06-04T22:52:09.951735Z","shell.execute_reply":"2021-06-04T22:52:09.956798Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def data_cleaning(text):\n    text = re.sub('[^A-Za-z0-9]+', \" \", text)\n    text = re.sub(' +', ' ', text)\n    emoji_pattern = re.compile(\"[\"\n                               u\"\\U0001F600-\\U0001F64F\"  # emoticons\n                               u\"\\U0001F300-\\U0001F5FF\"  # symbols & pictographs\n                               u\"\\U0001F680-\\U0001F6FF\"  # transport & map symbols\n                               u\"\\U0001F1E0-\\U0001F1FF\"  # flags (iOS)\n                               \"]+\", flags=re.UNICODE)\n    cleaned_text = emoji_pattern.sub(r'', text)\n\n    return cleaned_text.lower()","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:52:20.461963Z","iopub.execute_input":"2021-06-04T22:52:20.462279Z","iopub.status.idle":"2021-06-04T22:52:20.466833Z","shell.execute_reply.started":"2021-06-04T22:52:20.462253Z","shell.execute_reply":"2021-06-04T22:52:20.466166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def load_json():\n    train_csv['json-content'] = train_csv['Id'].apply(retrieve_text, args=('train',))\n    test_set['json-content'] = sample_submission['Id'].apply(retrieve_text, args=('test',))\n    # train_csv['acronym'] = train_csv['dataset_title'].progress_apply(create_patterns)\n    # train_csv['fuzzy-ratio'] = train_csv.progress_apply(get_fuzzy_score, axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:52:25.549672Z","iopub.execute_input":"2021-06-04T22:52:25.550248Z","iopub.status.idle":"2021-06-04T22:52:25.554629Z","shell.execute_reply.started":"2021-06-04T22:52:25.550213Z","shell.execute_reply":"2021-06-04T22:52:25.553585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_set = pandas.DataFrame()\ntest_set['Id'] = sample_submission['Id']\nload_json()","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:52:58.882738Z","iopub.execute_input":"2021-06-04T22:52:58.883039Z","iopub.status.idle":"2021-06-04T22:55:38.112699Z","shell.execute_reply.started":"2021-06-04T22:52:58.883011Z","shell.execute_reply":"2021-06-04T22:55:38.111999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Preprocess the data for NLP","metadata":{}},{"cell_type":"code","source":"# Define the preprocessing function\ndef preprocess_data(dataframe):\n    unique_dataset_titles = dataframe['dataset_title'].unique()\n\n    for dataset_title in unique_dataset_titles:\n        try:\n            if '(' in str(dataset_title):\n                tmp_title = str(dataset_title).split(\" \")\n                \n                tmp_title_without_braces = str(dataset_title).replace(\"(\", \"\")\n                tmp_title_without_braces = tmp_title_without_braces.replace(\")\", \"\").lower()\n                tmp_title_without_braces = re.sub('[^A-Za-z]+', \" \", tmp_title_without_braces)\n                    \n                for word in tmp_title:\n                    if '(' in word:\n                        acronyms_dict[str(word[1: -1]).lower()] = tmp_title_without_braces\n\n            else:\n                text = re.sub('[^A-Za-z]+', \" \", str(dataset_title))\n                clean_text = text.lower().split()\n                clean_text = [clean_word for clean_word in clean_text if not clean_word in set(stop_words)]\n\n                acronym_text = []\n                for word in clean_text:\n                    acronym_text.append(word[0: 1])\n\n                acronyms_dict[\"\".join(acronym_text)] = str(dataset_title).lower()\n\n            tmp_title = str(dataset_title)\n            tmp_title_without_braces = str(dataset_title).lower().split(\" \")\n            tmp_title = re.sub('[^A-Za-z0-9]+', \" \", tmp_title).lower()\n            tmp_title_without_braces = [word for word in tmp_title_without_braces\nif not '(' in word]\n            tmp_title_without_braces = re.sub('[^A-Za-z0-9]+', \" \", str(tmp_title_without_braces)).lower()\n\n            titles_prior1.add(tmp_title.strip())\n            \n            if tmp_title_without_braces.strip() not in titles_prior1:\n                titles_prior2.add(tmp_title_without_braces.strip())\n                titles_dict[tmp_title_without_braces.strip()] = tmp_title.strip()\n\n        except:\n            print(\"exception occurred for title: \", dataset_title)\n            continue\n\n    return acronyms_dict, titles_dict, titles_prior1, titles_prior2                                        ","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:56:27.256765Z","iopub.execute_input":"2021-06-04T22:56:27.257205Z","iopub.status.idle":"2021-06-04T22:56:27.266050Z","shell.execute_reply.started":"2021-06-04T22:56:27.257175Z","shell.execute_reply":"2021-06-04T22:56:27.265023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stop_words = stopwords.words('english')\nacronyms = set()\ntitles_prior1 = set()\ntitles_prior2 = set()\nacronyms_dict = {}\ntitles_dict = {}\nacronyms_dict, titles_dict, titles_prior1, titles_prior2 = preprocess_data(train_csv)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:56:33.026349Z","iopub.execute_input":"2021-06-04T22:56:33.026692Z","iopub.status.idle":"2021-06-04T22:56:33.042455Z","shell.execute_reply.started":"2021-06-04T22:56:33.026656Z","shell.execute_reply":"2021-06-04T22:56:33.041711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Display the acronyms dictionary\nacronyms_dict","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:56:35.323231Z","iopub.execute_input":"2021-06-04T22:56:35.323550Z","iopub.status.idle":"2021-06-04T22:56:35.329587Z","shell.execute_reply.started":"2021-06-04T22:56:35.323523Z","shell.execute_reply":"2021-06-04T22:56:35.328783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titles_prior1 = list(sorted(titles_prior1, key=len, reverse=True))\ntitles_prior2 = list(sorted(titles_prior2, key=len, reverse=True))\nunique_cleaned_matches = train_csv['cleaned_label'].unique()","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:56:44.192037Z","iopub.execute_input":"2021-06-04T22:56:44.192620Z","iopub.status.idle":"2021-06-04T22:56:44.200139Z","shell.execute_reply.started":"2021-06-04T22:56:44.192574Z","shell.execute_reply":"2021-06-04T22:56:44.199235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(titles_prior1)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T22:56:46.823509Z","iopub.execute_input":"2021-06-04T22:56:46.824036Z","iopub.status.idle":"2021-06-04T22:56:46.828847Z","shell.execute_reply.started":"2021-06-04T22:56:46.824006Z","shell.execute_reply":"2021-06-04T22:56:46.827906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"# Predict the results, and save it to a submission file","metadata":{}},{"cell_type":"code","source":"acronyms = acronyms_dict.keys()\nmatch_out = []\nfor json_data in test_set['json-content']:\n    match = ''\n    tmp_set = set()\n\n    for word in json_data.split():\n        tmp_set.add(word)\n    \n    for clean_text in unique_cleaned_matches:\n        if clean_text in str(json_data) and clean_text not in match:\n            match += ('|' + clean_text if len(match) > 0 else clean_text)\n            \n    for query_prior1 in titles_prior1:\n        query_text = str(query_prior1).lower()\n\n        if query_text in str(json_data) and query_text not in match:\n            match += ('|' + query_text if len(match) > 0 else query_text)\n\n    for query_prior2 in titles_prior2:\n        query_text = str(query_prior2).lower()\n\n        if query_text in str(json_data) and query_text not in match:\n            match += ('|' + query_text if len(match) > 0 else query_text)\n\n    for query_text in acronyms:\n        if len(query_text) > 3 and query_text in tmp_set and query_text not in match:\n            match += ('|' + query_text if len(match) > 0 else query_text)\n\n    match_out.append(match)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T23:15:53.131451Z","iopub.execute_input":"2021-06-04T23:15:53.132004Z","iopub.status.idle":"2021-06-04T23:15:53.196109Z","shell.execute_reply.started":"2021-06-04T23:15:53.131966Z","shell.execute_reply":"2021-06-04T23:15:53.195114Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(match_out)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T23:16:18.164489Z","iopub.execute_input":"2021-06-04T23:16:18.164986Z","iopub.status.idle":"2021-06-04T23:16:18.169477Z","shell.execute_reply.started":"2021-06-04T23:16:18.164957Z","shell.execute_reply":"2021-06-04T23:16:18.168589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Test set results\nresult = pandas.DataFrame()\nresult['Id'] = test_set['Id']\nresult['PredictionString'] = match_out\nresult.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T23:16:49.859880Z","iopub.execute_input":"2021-06-04T23:16:49.860186Z","iopub.status.idle":"2021-06-04T23:16:49.872550Z","shell.execute_reply.started":"2021-06-04T23:16:49.860161Z","shell.execute_reply":"2021-06-04T23:16:49.871841Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Training set results, not required for this competition\n# result = pandas.DataFrame()\n# result['Id'] = train_csv['Id']\n# result['title'] = train_csv['dataset_title']\n# result['clean'] = train_csv['cleaned_label']\n# result['PredictionString'] = match_out\n# result.to_csv('submission.csv', index=False)","metadata":{},"execution_count":null,"outputs":[]}]}