{"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 # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nimport glob\nimport seaborn as sns\n\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport matplotlib.image as mpimg","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-02-10T12:34:24.356641Z","iopub.execute_input":"2022-02-10T12:34:24.357004Z","iopub.status.idle":"2022-02-10T12:34:25.585998Z","shell.execute_reply.started":"2022-02-10T12:34:24.356912Z","shell.execute_reply":"2022-02-10T12:34:25.584967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/articles.csv')\ncustomers = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/customers.csv')\ntrain = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv')\nsubmission = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:34:25.587960Z","iopub.execute_input":"2022-02-10T12:34:25.588277Z","iopub.status.idle":"2022-02-10T12:35:51.851403Z","shell.execute_reply.started":"2022-02-10T12:34:25.588235Z","shell.execute_reply":"2022-02-10T12:35:51.850696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 1. Train ","metadata":{}},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:35:51.865944Z","iopub.execute_input":"2022-02-10T12:35:51.866650Z","iopub.status.idle":"2022-02-10T12:35:51.890935Z","shell.execute_reply.started":"2022-02-10T12:35:51.866596Z","shell.execute_reply":"2022-02-10T12:35:51.889732Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:35:51.893476Z","iopub.execute_input":"2022-02-10T12:35:51.893760Z","iopub.status.idle":"2022-02-10T12:35:51.899954Z","shell.execute_reply.started":"2022-02-10T12:35:51.893729Z","shell.execute_reply":"2022-02-10T12:35:51.898966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(train.price,color=\"blue\", kde=True,bins=100, label='price')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:35:51.910748Z","iopub.execute_input":"2022-02-10T12:35:51.911220Z","iopub.status.idle":"2022-02-10T12:38:05.598905Z","shell.execute_reply.started":"2022-02-10T12:35:51.911178Z","shell.execute_reply":"2022-02-10T12:38:05.597735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pie, ax = plt.subplots(figsize=[16,8])\ntrain.groupby('sales_channel_id').size().plot(kind='pie',autopct='%.2f',ax=ax,title='sales_channel_id distibution')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:05.600422Z","iopub.execute_input":"2022-02-10T12:38:05.600676Z","iopub.status.idle":"2022-02-10T12:38:06.468828Z","shell.execute_reply.started":"2022-02-10T12:38:05.600646Z","shell.execute_reply":"2022-02-10T12:38:06.467839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 2. Customers","metadata":{}},{"cell_type":"code","source":"customers.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:06.472773Z","iopub.execute_input":"2022-02-10T12:38:06.473157Z","iopub.status.idle":"2022-02-10T12:38:06.500878Z","shell.execute_reply.started":"2022-02-10T12:38:06.473109Z","shell.execute_reply":"2022-02-10T12:38:06.499106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:06.505608Z","iopub.execute_input":"2022-02-10T12:38:06.506282Z","iopub.status.idle":"2022-02-10T12:38:06.522914Z","shell.execute_reply.started":"2022-02-10T12:38:06.506228Z","shell.execute_reply":"2022-02-10T12:38:06.522059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers.Active.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:06.524506Z","iopub.execute_input":"2022-02-10T12:38:06.525028Z","iopub.status.idle":"2022-02-10T12:38:06.559478Z","shell.execute_reply.started":"2022-02-10T12:38:06.524977Z","shell.execute_reply":"2022-02-10T12:38:06.557722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers.FN.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:06.562092Z","iopub.execute_input":"2022-02-10T12:38:06.562505Z","iopub.status.idle":"2022-02-10T12:38:06.588711Z","shell.execute_reply.started":"2022-02-10T12:38:06.562459Z","shell.execute_reply":"2022-02-10T12:38:06.587801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers.club_member_status.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:06.590507Z","iopub.execute_input":"2022-02-10T12:38:06.591060Z","iopub.status.idle":"2022-02-10T12:38:06.844825Z","shell.execute_reply.started":"2022-02-10T12:38:06.591011Z","shell.execute_reply":"2022-02-10T12:38:06.843773Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"_ , ax = plt.subplots(figsize=[14,6])\nsns.countplot(x=\"club_member_status\", data=customers, ax=ax)","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:06.846347Z","iopub.execute_input":"2022-02-10T12:38:06.846982Z","iopub.status.idle":"2022-02-10T12:38:08.768252Z","shell.execute_reply.started":"2022-02-10T12:38:06.846819Z","shell.execute_reply":"2022-02-10T12:38:08.767391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pie, ax = plt.subplots(figsize=[16,8])\ncustomers.groupby('club_member_status').size().plot(kind='pie',autopct='%.2f',ax=ax,title='club_member_status distibution')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:08.769827Z","iopub.execute_input":"2022-02-10T12:38:08.770109Z","iopub.status.idle":"2022-02-10T12:38:09.122072Z","shell.execute_reply.started":"2022-02-10T12:38:08.770078Z","shell.execute_reply":"2022-02-10T12:38:09.121118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers.fashion_news_frequency.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:09.123565Z","iopub.execute_input":"2022-02-10T12:38:09.124702Z","iopub.status.idle":"2022-02-10T12:38:09.363958Z","shell.execute_reply.started":"2022-02-10T12:38:09.124644Z","shell.execute_reply":"2022-02-10T12:38:09.363112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"_ , ax = plt.subplots(figsize=[14,6])\nsns.countplot(x=\"fashion_news_frequency\", data=customers, ax=ax)","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:09.365290Z","iopub.execute_input":"2022-02-10T12:38:09.366097Z","iopub.status.idle":"2022-02-10T12:38:11.241559Z","shell.execute_reply.started":"2022-02-10T12:38:09.366049Z","shell.execute_reply":"2022-02-10T12:38:11.240750Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pie, ax = plt.subplots(figsize=[16,8])\ncustomers.groupby('fashion_news_frequency').size().plot(kind='pie',autopct='%.2f',ax=ax,title='fashion_news_frequency distibution')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:11.242905Z","iopub.execute_input":"2022-02-10T12:38:11.243287Z","iopub.status.idle":"2022-02-10T12:38:11.600368Z","shell.execute_reply.started":"2022-02-10T12:38:11.243242Z","shell.execute_reply":"2022-02-10T12:38:11.599328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(customers.age,color=\"blue\", kde=True,bins=100, label='age')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:11.602240Z","iopub.execute_input":"2022-02-10T12:38:11.602840Z","iopub.status.idle":"2022-02-10T12:38:18.184912Z","shell.execute_reply.started":"2022-02-10T12:38:11.602790Z","shell.execute_reply":"2022-02-10T12:38:18.183674Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 3. Articles","metadata":{}},{"cell_type":"code","source":"articles.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:18.186433Z","iopub.execute_input":"2022-02-10T12:38:18.187057Z","iopub.status.idle":"2022-02-10T12:38:18.221768Z","shell.execute_reply.started":"2022-02-10T12:38:18.187005Z","shell.execute_reply":"2022-02-10T12:38:18.220942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.prod_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:45:18.373143Z","iopub.execute_input":"2022-02-10T12:45:18.373452Z","iopub.status.idle":"2022-02-10T12:45:18.429732Z","shell.execute_reply.started":"2022-02-10T12:45:18.373415Z","shell.execute_reply":"2022-02-10T12:45:18.428870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.prod_name.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:48:20.008288Z","iopub.execute_input":"2022-02-10T12:48:20.008607Z","iopub.status.idle":"2022-02-10T12:48:20.033327Z","shell.execute_reply.started":"2022-02-10T12:48:20.008579Z","shell.execute_reply":"2022-02-10T12:48:20.032754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.product_type_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:47:43.815692Z","iopub.execute_input":"2022-02-10T12:47:43.816135Z","iopub.status.idle":"2022-02-10T12:47:43.840631Z","shell.execute_reply.started":"2022-02-10T12:47:43.816085Z","shell.execute_reply":"2022-02-10T12:47:43.839933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.product_type_name.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:48:39.808237Z","iopub.execute_input":"2022-02-10T12:48:39.809127Z","iopub.status.idle":"2022-02-10T12:48:39.822127Z","shell.execute_reply.started":"2022-02-10T12:48:39.809088Z","shell.execute_reply":"2022-02-10T12:48:39.821573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.product_group_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:49:19.333126Z","iopub.execute_input":"2022-02-10T12:49:19.333447Z","iopub.status.idle":"2022-02-10T12:49:19.359358Z","shell.execute_reply.started":"2022-02-10T12:49:19.333413Z","shell.execute_reply":"2022-02-10T12:49:19.358564Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"_ , ax = plt.subplots(figsize=[22,8])\nsns.countplot(x=\"product_group_name\", data=articles, ax=ax)","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:50:52.603956Z","iopub.execute_input":"2022-02-10T12:50:52.604583Z","iopub.status.idle":"2022-02-10T12:50:53.079812Z","shell.execute_reply.started":"2022-02-10T12:50:52.604544Z","shell.execute_reply":"2022-02-10T12:50:53.078969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.graphical_appearance_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:51:52.328951Z","iopub.execute_input":"2022-02-10T12:51:52.329556Z","iopub.status.idle":"2022-02-10T12:51:52.355711Z","shell.execute_reply.started":"2022-02-10T12:51:52.329517Z","shell.execute_reply":"2022-02-10T12:51:52.354814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.colour_group_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:52:40.847589Z","iopub.execute_input":"2022-02-10T12:52:40.848400Z","iopub.status.idle":"2022-02-10T12:52:40.876430Z","shell.execute_reply.started":"2022-02-10T12:52:40.848356Z","shell.execute_reply":"2022-02-10T12:52:40.875608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.department_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:53:27.420061Z","iopub.execute_input":"2022-02-10T12:53:27.420360Z","iopub.status.idle":"2022-02-10T12:53:27.446103Z","shell.execute_reply.started":"2022-02-10T12:53:27.420331Z","shell.execute_reply":"2022-02-10T12:53:27.445155Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.department_name.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:54:49.596291Z","iopub.execute_input":"2022-02-10T12:54:49.596606Z","iopub.status.idle":"2022-02-10T12:54:49.613006Z","shell.execute_reply.started":"2022-02-10T12:54:49.596579Z","shell.execute_reply":"2022-02-10T12:54:49.612058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.index_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:54:59.516082Z","iopub.execute_input":"2022-02-10T12:54:59.516716Z","iopub.status.idle":"2022-02-10T12:54:59.544597Z","shell.execute_reply.started":"2022-02-10T12:54:59.516669Z","shell.execute_reply":"2022-02-10T12:54:59.543822Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"_ , ax = plt.subplots(figsize=[20,8])\nsns.countplot(x=\"index_name\", data=articles, ax=ax)","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:55:54.492455Z","iopub.execute_input":"2022-02-10T12:55:54.492757Z","iopub.status.idle":"2022-02-10T12:55:54.886262Z","shell.execute_reply.started":"2022-02-10T12:55:54.492725Z","shell.execute_reply":"2022-02-10T12:55:54.885436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pie, ax = plt.subplots(figsize=[16,8])\narticles.groupby('index_name').size().plot(kind='pie',autopct='%.2f',ax=ax,title='index_name distibution')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:56:21.691727Z","iopub.execute_input":"2022-02-10T12:56:21.692188Z","iopub.status.idle":"2022-02-10T12:56:21.944497Z","shell.execute_reply.started":"2022-02-10T12:56:21.692151Z","shell.execute_reply":"2022-02-10T12:56:21.943657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.index_group_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:57:14.482776Z","iopub.execute_input":"2022-02-10T12:57:14.483456Z","iopub.status.idle":"2022-02-10T12:57:14.510845Z","shell.execute_reply.started":"2022-02-10T12:57:14.483405Z","shell.execute_reply":"2022-02-10T12:57:14.509947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"_ , ax = plt.subplots(figsize=[16,6])\nsns.countplot(x=\"index_group_name\", data=articles, ax=ax)","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:57:48.638557Z","iopub.execute_input":"2022-02-10T12:57:48.639477Z","iopub.status.idle":"2022-02-10T12:57:48.995035Z","shell.execute_reply.started":"2022-02-10T12:57:48.639416Z","shell.execute_reply":"2022-02-10T12:57:48.994203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pie, ax = plt.subplots(figsize=[16,8])\narticles.groupby('index_group_name').size().plot(kind='pie',autopct='%.2f',ax=ax,title='index_group_name distibution')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:58:28.898149Z","iopub.execute_input":"2022-02-10T12:58:28.898946Z","iopub.status.idle":"2022-02-10T12:58:29.079810Z","shell.execute_reply.started":"2022-02-10T12:58:28.898899Z","shell.execute_reply":"2022-02-10T12:58:29.078696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.section_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:59:31.174871Z","iopub.execute_input":"2022-02-10T12:59:31.175173Z","iopub.status.idle":"2022-02-10T12:59:31.207211Z","shell.execute_reply.started":"2022-02-10T12:59:31.175142Z","shell.execute_reply":"2022-02-10T12:59:31.206351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.garment_group_name.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-10T13:00:22.383427Z","iopub.execute_input":"2022-02-10T13:00:22.383706Z","iopub.status.idle":"2022-02-10T13:00:22.412324Z","shell.execute_reply.started":"2022-02-10T13:00:22.383676Z","shell.execute_reply":"2022-02-10T13:00:22.411505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 4. Plot some Products","metadata":{}},{"cell_type":"code","source":"def plot_images(Path):\n    images = []\n    for img_path in glob.glob(Path + '/*.jpg'):\n        images.append(mpimg.imread(img_path))\n\n    plt.figure(figsize=(20,20))\n    columns = 3\n    for i, image in enumerate(images):\n        plt.subplot(len(images) // columns + 1, columns, i + 1)\n        plt.imshow(image)","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:18.223037Z","iopub.execute_input":"2022-02-10T12:38:18.223277Z","iopub.status.idle":"2022-02-10T12:38:18.229657Z","shell.execute_reply.started":"2022-02-10T12:38:18.223247Z","shell.execute_reply":"2022-02-10T12:38:18.228988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images('../input/h-and-m-personalized-fashion-recommendations/images/010')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:18.230857Z","iopub.execute_input":"2022-02-10T12:38:18.231300Z","iopub.status.idle":"2022-02-10T12:38:20.133704Z","shell.execute_reply.started":"2022-02-10T12:38:18.231270Z","shell.execute_reply":"2022-02-10T12:38:20.132731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images('../input/h-and-m-personalized-fashion-recommendations/images/015')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:20.134946Z","iopub.execute_input":"2022-02-10T12:38:20.135194Z","iopub.status.idle":"2022-02-10T12:38:28.094521Z","shell.execute_reply.started":"2022-02-10T12:38:20.135163Z","shell.execute_reply":"2022-02-10T12:38:28.093599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images('../input/h-and-m-personalized-fashion-recommendations/images/011')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:28.096049Z","iopub.execute_input":"2022-02-10T12:38:28.096563Z","iopub.status.idle":"2022-02-10T12:38:36.793872Z","shell.execute_reply.started":"2022-02-10T12:38:28.096512Z","shell.execute_reply":"2022-02-10T12:38:36.792751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images('../input/h-and-m-personalized-fashion-recommendations/images/020')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:38:53.159424Z","iopub.execute_input":"2022-02-10T12:38:53.159979Z","iopub.status.idle":"2022-02-10T12:39:04.179672Z","shell.execute_reply.started":"2022-02-10T12:38:53.159943Z","shell.execute_reply":"2022-02-10T12:39:04.178684Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_images('../input/h-and-m-personalized-fashion-recommendations/images/022')","metadata":{"execution":{"iopub.status.busy":"2022-02-10T12:44:13.448593Z","iopub.execute_input":"2022-02-10T12:44:13.448884Z","iopub.status.idle":"2022-02-10T12:44:27.087398Z","shell.execute_reply.started":"2022-02-10T12:44:13.448854Z","shell.execute_reply":"2022-02-10T12:44:27.086365Z"},"trusted":true},"execution_count":null,"outputs":[]}]}