{"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":"import numpy as np\nimport pandas as pd\nimport os\nfrom tqdm import tqdm\nimport matplotlib.pyplot as plt\nfrom datetime import datetime\nfrom PIL import Image","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:02:54.552806Z","iopub.execute_input":"2022-02-25T15:02:54.553181Z","iopub.status.idle":"2022-02-25T15:02:54.558892Z","shell.execute_reply.started":"2022-02-25T15:02:54.553142Z","shell.execute_reply":"2022-02-25T15:02:54.557860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Read Data","metadata":{}},{"cell_type":"code","source":"articles_df = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/articles.csv\")\ncustomers_df = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/customers.csv\")\nsample_submission_df = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:02:55.468631Z","iopub.execute_input":"2022-02-25T15:02:55.469166Z","iopub.status.idle":"2022-02-25T15:03:09.632540Z","shell.execute_reply.started":"2022-02-25T15:02:55.469125Z","shell.execute_reply":"2022-02-25T15:03:09.631183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactions_train_df = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:03:09.634572Z","iopub.execute_input":"2022-02-25T15:03:09.634827Z","iopub.status.idle":"2022-02-25T15:04:24.490792Z","shell.execute_reply.started":"2022-02-25T15:03:09.634798Z","shell.execute_reply":"2022-02-25T15:04:24.489939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactions_train_df['t_dat'] = pd.to_datetime(transactions_train_df['t_dat'])","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:30.570818Z","iopub.execute_input":"2022-02-25T15:04:30.571168Z","iopub.status.idle":"2022-02-25T15:04:31.646729Z","shell.execute_reply.started":"2022-02-25T15:04:30.571123Z","shell.execute_reply":"2022-02-25T15:04:31.645563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Watch Data","metadata":{}},{"cell_type":"code","source":"last_date = transactions_train_df.t_dat.max()\nstart_date = transactions_train_df.t_dat.min()\nprint(last_date)\nprint(start_date)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:30.360314Z","iopub.execute_input":"2022-02-25T15:04:30.360974Z","iopub.status.idle":"2022-02-25T15:04:30.569428Z","shell.execute_reply.started":"2022-02-25T15:04:30.360925Z","shell.execute_reply":"2022-02-25T15:04:30.568225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(transactions_train_df))","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:34.519915Z","iopub.execute_input":"2022-02-25T15:04:34.520290Z","iopub.status.idle":"2022-02-25T15:04:34.525896Z","shell.execute_reply.started":"2022-02-25T15:04:34.520253Z","shell.execute_reply":"2022-02-25T15:04:34.525040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Lighten transictions data\n\nThe data is so big...\n\nMy MacBook CPU is on fire.","metadata":{}},{"cell_type":"code","source":"# delete duplicate customer ID\nsimple_transictions_df = transactions_train_df.drop_duplicates(keep='first', subset='customer_id')","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:37.953975Z","iopub.execute_input":"2022-02-25T15:04:37.954276Z","iopub.status.idle":"2022-02-25T15:04:48.309632Z","shell.execute_reply.started":"2022-02-25T15:04:37.954243Z","shell.execute_reply":"2022-02-25T15:04:48.308598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(simple_transictions_df)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:49.906205Z","iopub.execute_input":"2022-02-25T15:04:49.906524Z","iopub.status.idle":"2022-02-25T15:04:49.912516Z","shell.execute_reply.started":"2022-02-25T15:04:49.906487Z","shell.execute_reply":"2022-02-25T15:04:49.911651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(customers_df)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:51.136191Z","iopub.execute_input":"2022-02-25T15:04:51.136485Z","iopub.status.idle":"2022-02-25T15:04:51.142442Z","shell.execute_reply.started":"2022-02-25T15:04:51.136452Z","shell.execute_reply":"2022-02-25T15:04:51.141375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:52.465546Z","iopub.execute_input":"2022-02-25T15:04:52.466095Z","iopub.status.idle":"2022-02-25T15:04:52.493663Z","shell.execute_reply.started":"2022-02-25T15:04:52.466037Z","shell.execute_reply":"2022-02-25T15:04:52.492806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Add feature \"index_group_name\" to transictions_df ","metadata":{}},{"cell_type":"code","source":"easy_articles_df = articles_df[['article_id', 'index_group_name']]","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:04:55.733915Z","iopub.execute_input":"2022-02-25T15:04:55.734257Z","iopub.status.idle":"2022-02-25T15:04:55.741562Z","shell.execute_reply.started":"2022-02-25T15:04:55.734210Z","shell.execute_reply":"2022-02-25T15:04:55.740826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"easy_articles_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:21:33.865935Z","iopub.execute_input":"2022-02-25T15:21:33.866237Z","iopub.status.idle":"2022-02-25T15:21:33.876894Z","shell.execute_reply.started":"2022-02-25T15:21:33.866208Z","shell.execute_reply":"2022-02-25T15:21:33.876142Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"group_labeled_df = simple_transictions_df.merge(easy_articles_df, on=\"article_id\")\ngroup_labeled_df = group_labeled_df[[\"customer_id\", \"index_group_name\"]]\ngroup_labeled_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:42:43.453640Z","iopub.execute_input":"2022-02-25T15:42:43.453958Z","iopub.status.idle":"2022-02-25T15:42:44.466378Z","shell.execute_reply.started":"2022-02-25T15:42:43.453912Z","shell.execute_reply":"2022-02-25T15:42:44.465312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"group_labeled_df[\"index_group_name\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:43:20.561863Z","iopub.execute_input":"2022-02-25T15:43:20.562752Z","iopub.status.idle":"2022-02-25T15:43:20.764444Z","shell.execute_reply.started":"2022-02-25T15:43:20.562708Z","shell.execute_reply":"2022-02-25T15:43:20.763633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Create prediction","metadata":{}},{"cell_type":"code","source":"df_3w = transactions_train_df[transactions_train_df['t_dat'] >= pd.to_datetime('2019-08-31')].copy()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:22:02.023975Z","iopub.execute_input":"2022-02-25T15:22:02.024899Z","iopub.status.idle":"2022-02-25T15:22:04.304889Z","shell.execute_reply.started":"2022-02-25T15:22:02.024849Z","shell.execute_reply":"2022-02-25T15:22:04.304010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"add_group_name_df = df_3w.merge(easy_articles_df, on=\"article_id\")","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:22:06.385393Z","iopub.execute_input":"2022-02-25T15:22:06.385668Z","iopub.status.idle":"2022-02-25T15:22:16.727992Z","shell.execute_reply.started":"2022-02-25T15:22:06.385639Z","shell.execute_reply":"2022-02-25T15:22:16.726914Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"add_group_name_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:22:23.369570Z","iopub.execute_input":"2022-02-25T15:22:23.369878Z","iopub.status.idle":"2022-02-25T15:22:23.384649Z","shell.execute_reply.started":"2022-02-25T15:22:23.369848Z","shell.execute_reply":"2022-02-25T15:22:23.383787Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_frequent_articles_list_group_name(group_name:str):\n    output_dict = {}\n    df = add_group_name_df[add_group_name_df.index_group_name == group_name]\n    frequent_articles_list = list((df['article_id'].value_counts()).index)[:12]\n    frequent_articles_list = [(\"0\" + str(article_id))[-10:] for article_id in frequent_articles_list]\n    return frequent_articles_list\n","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:23:20.899953Z","iopub.execute_input":"2022-02-25T15:23:20.900299Z","iopub.status.idle":"2022-02-25T15:23:20.907705Z","shell.execute_reply.started":"2022-02-25T15:23:20.900265Z","shell.execute_reply":"2022-02-25T15:23:20.906484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ladies_list = get_frequent_articles_list_group_name(group_name=\"Ladieswear\")\nprint(ladies_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:23:25.238613Z","iopub.execute_input":"2022-02-25T15:23:25.239360Z","iopub.status.idle":"2022-02-25T15:23:31.811509Z","shell.execute_reply.started":"2022-02-25T15:23:25.239310Z","shell.execute_reply":"2022-02-25T15:23:31.810245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Divided_list = get_frequent_articles_list_group_name(group_name=\"Divided\")\nprint(Divided_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:23:42.616827Z","iopub.execute_input":"2022-02-25T15:23:42.617630Z","iopub.status.idle":"2022-02-25T15:23:45.386870Z","shell.execute_reply.started":"2022-02-25T15:23:42.617586Z","shell.execute_reply":"2022-02-25T15:23:45.386136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Sport_list = get_frequent_articles_list_group_name(group_name=\"Sport\")\nprint(Sport_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:23:47.333161Z","iopub.execute_input":"2022-02-25T15:23:47.333478Z","iopub.status.idle":"2022-02-25T15:23:49.679549Z","shell.execute_reply.started":"2022-02-25T15:23:47.333443Z","shell.execute_reply":"2022-02-25T15:23:49.678428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Menswear_list = get_frequent_articles_list_group_name(group_name=\"Menswear\")\nprint(Menswear_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:23:50.478454Z","iopub.execute_input":"2022-02-25T15:23:50.478732Z","iopub.status.idle":"2022-02-25T15:23:52.870810Z","shell.execute_reply.started":"2022-02-25T15:23:50.478703Z","shell.execute_reply":"2022-02-25T15:23:52.869889Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"baby_list = get_frequent_articles_list_group_name(group_name=\"Baby/Children\")\nprint(baby_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:23:54.293433Z","iopub.execute_input":"2022-02-25T15:23:54.293728Z","iopub.status.idle":"2022-02-25T15:23:56.602110Z","shell.execute_reply.started":"2022-02-25T15:23:54.293697Z","shell.execute_reply":"2022-02-25T15:23:56.600798Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Show Prediction images","metadata":{}},{"cell_type":"code","source":"images_names = []\nfor _, _, files in tqdm(os.walk('/kaggle/input/h-and-m-personalized-fashion-recommendations/')):\n    for _files in files:\n        if len(_files.split(\".jpg\"))==2:\n            images_names.append(_files.split(\".jpg\")[0])","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:23:58.008989Z","iopub.execute_input":"2022-02-25T15:23:58.009301Z","iopub.status.idle":"2022-02-25T15:24:17.999230Z","shell.execute_reply.started":"2022-02-25T15:23:58.009272Z","shell.execute_reply":"2022-02-25T15:24:17.998366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_name_df = pd.DataFrame(images_names, columns = [\"image_name\"])\nimage_name_df[\"article_id\"] = image_name_df[\"image_name\"].apply(lambda x: int(x[1:]))","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:25:17.416497Z","iopub.execute_input":"2022-02-25T15:25:17.417094Z","iopub.status.idle":"2022-02-25T15:25:17.527462Z","shell.execute_reply.started":"2022-02-25T15:25:17.417042Z","shell.execute_reply":"2022-02-25T15:25:17.526199Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_article_df = articles_df[[\"article_id\", \"product_code\", \"product_group_name\", \"product_type_name\", \"index_group_name\", \"index_group_no\", \"colour_group_code\"]].merge(image_name_df, on=[\"article_id\"], how=\"left\")\nprint(image_article_df.shape)\nimage_article_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:25:18.000217Z","iopub.execute_input":"2022-02-25T15:25:18.000530Z","iopub.status.idle":"2022-02-25T15:25:18.073765Z","shell.execute_reply.started":"2022-02-25T15:25:18.000499Z","shell.execute_reply":"2022-02-25T15:25:18.072548Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(articles_df)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:25:20.122894Z","iopub.execute_input":"2022-02-25T15:25:20.123213Z","iopub.status.idle":"2022-02-25T15:25:20.128966Z","shell.execute_reply.started":"2022-02-25T15:25:20.123180Z","shell.execute_reply":"2022-02-25T15:25:20.128327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\n\n# art_listから可視化を行う\ndef plot_image_art_list(art_list, cols=4, rows=3):\n    image_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/images/\"\n    plt.figure(figsize=(2 + 3 * cols, 2 + 4 * rows))\n    for i, article_id in enumerate(art_list):\n#         index_group_name = image_article_df.loc[image_article_df.image_name==article_id][\"index_group_name\"]\n#         index_group_name = index_group_name.to_list()[0]\n#         print(index_group_name)\n        plt.subplot(rows, cols, i + 1)\n        plt.axis('off')\n        plt.title(f\"{article_id[:3]}\\n{article_id}.jpg\")\n        try:\n            image = Image.open(f\"{image_path}{article_id[:3]}/{article_id}.jpg\")\n        except FileNotFoundError:\n            print('!!! FileNotFoundError !!!')\n            continue\n        \n        plt.imshow(image)\n","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:31:19.629651Z","iopub.execute_input":"2022-02-25T15:31:19.630286Z","iopub.status.idle":"2022-02-25T15:31:19.638896Z","shell.execute_reply.started":"2022-02-25T15:31:19.630241Z","shell.execute_reply":"2022-02-25T15:31:19.637892Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_image_art_list(ladies_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:31:21.164576Z","iopub.execute_input":"2022-02-25T15:31:21.164974Z","iopub.status.idle":"2022-02-25T15:31:25.166318Z","shell.execute_reply.started":"2022-02-25T15:31:21.164924Z","shell.execute_reply":"2022-02-25T15:31:25.165299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_image_art_list(Sport_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:28:58.670214Z","iopub.execute_input":"2022-02-25T15:28:58.670732Z","iopub.status.idle":"2022-02-25T15:29:03.325333Z","shell.execute_reply.started":"2022-02-25T15:28:58.670684Z","shell.execute_reply":"2022-02-25T15:29:03.324331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_image_art_list(Divided_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:29:11.807865Z","iopub.execute_input":"2022-02-25T15:29:11.808161Z","iopub.status.idle":"2022-02-25T15:29:16.852692Z","shell.execute_reply.started":"2022-02-25T15:29:11.808131Z","shell.execute_reply":"2022-02-25T15:29:16.851727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_image_art_list(Menswear_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:31:42.267555Z","iopub.execute_input":"2022-02-25T15:31:42.267868Z","iopub.status.idle":"2022-02-25T15:31:47.149941Z","shell.execute_reply.started":"2022-02-25T15:31:42.267836Z","shell.execute_reply":"2022-02-25T15:31:47.146487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_image_art_list(baby_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:31:59.884568Z","iopub.execute_input":"2022-02-25T15:31:59.884859Z","iopub.status.idle":"2022-02-25T15:32:04.712374Z","shell.execute_reply.started":"2022-02-25T15:31:59.884830Z","shell.execute_reply":"2022-02-25T15:32:04.711380Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dummy_list = list((simple_transictions_df['article_id'].value_counts()).index)[:12]\ndummy_list = [(\"0\" + str(article_id))[-10:] for article_id in dummy_list]","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:32:09.128151Z","iopub.execute_input":"2022-02-25T15:32:09.128565Z","iopub.status.idle":"2022-02-25T15:32:09.179118Z","shell.execute_reply.started":"2022-02-25T15:32:09.128535Z","shell.execute_reply":"2022-02-25T15:32:09.178188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_image_art_list(dummy_list)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:32:21.423809Z","iopub.execute_input":"2022-02-25T15:32:21.424151Z","iopub.status.idle":"2022-02-25T15:32:25.921106Z","shell.execute_reply.started":"2022-02-25T15:32:21.424112Z","shell.execute_reply":"2022-02-25T15:32:25.920124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df = sample_submission_df.merge(group_labeled_df, on=[\"customer_id\"], how=\"left\")","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:43:34.288376Z","iopub.execute_input":"2022-02-25T15:43:34.288681Z","iopub.status.idle":"2022-02-25T15:43:36.676808Z","shell.execute_reply.started":"2022-02-25T15:43:34.288651Z","shell.execute_reply":"2022-02-25T15:43:36.675631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:50:46.107383Z","iopub.execute_input":"2022-02-25T15:50:46.107694Z","iopub.status.idle":"2022-02-25T15:50:46.119483Z","shell.execute_reply.started":"2022-02-25T15:50:46.107665Z","shell.execute_reply":"2022-02-25T15:50:46.118384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def update_prediction(row):\n    group_label = row[\"index_group_name\"]\n    if group_label == \"Ladieswear\":\n        return \" \".join(ladies_list)\n    elif group_label == \"Menswear\":\n        return \" \".join(Menswear_list)\n    elif group_label == \"Divided\":\n        return \" \".join(Divided_list)\n    elif group_label == \"Sport\":\n        return \" \".join(Sport_list)\n    elif group_label == \"Baby/Children\":\n        return \" \".join(baby_list)\n    else:\n        return \" \".join(dummy_list)\n","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:51:15.108278Z","iopub.execute_input":"2022-02-25T15:51:15.108985Z","iopub.status.idle":"2022-02-25T15:51:15.118830Z","shell.execute_reply.started":"2022-02-25T15:51:15.108936Z","shell.execute_reply":"2022-02-25T15:51:15.117896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df[\"prediction\"] = submission_df.apply(update_prediction, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:51:16.948177Z","iopub.execute_input":"2022-02-25T15:51:16.948793Z","iopub.status.idle":"2022-02-25T15:51:36.824333Z","shell.execute_reply.started":"2022-02-25T15:51:16.948743Z","shell.execute_reply":"2022-02-25T15:51:36.823374Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:51:39.447330Z","iopub.execute_input":"2022-02-25T15:51:39.447610Z","iopub.status.idle":"2022-02-25T15:51:39.459110Z","shell.execute_reply.started":"2022-02-25T15:51:39.447581Z","shell.execute_reply":"2022-02-25T15:51:39.458487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Rows with missing data in submission: \", submission_df.loc[submission_df.prediction.isna()].shape[0])","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:51:41.871305Z","iopub.execute_input":"2022-02-25T15:51:41.872003Z","iopub.status.idle":"2022-02-25T15:51:42.039410Z","shell.execute_reply.started":"2022-02-25T15:51:41.871932Z","shell.execute_reply":"2022-02-25T15:51:42.038666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df = submission_df[[\"customer_id\", \"prediction\"]]","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:33:16.865374Z","iopub.execute_input":"2022-02-25T15:33:16.865658Z","iopub.status.idle":"2022-02-25T15:33:16.927151Z","shell.execute_reply.started":"2022-02-25T15:33:16.865625Z","shell.execute_reply":"2022-02-25T15:33:16.926346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T15:33:18.070169Z","iopub.execute_input":"2022-02-25T15:33:18.070787Z","iopub.status.idle":"2022-02-25T15:33:18.080381Z","shell.execute_reply.started":"2022-02-25T15:33:18.070746Z","shell.execute_reply":"2022-02-25T15:33:18.079721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T14:27:52.692395Z","iopub.execute_input":"2022-02-25T14:27:52.692838Z","iopub.status.idle":"2022-02-25T14:28:06.056050Z","shell.execute_reply.started":"2022-02-25T14:27:52.692805Z","shell.execute_reply":"2022-02-25T14:28:06.055106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}