{"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 \n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        os.path.join(dirname, filename)\n        \nimport seaborn as sns        \nimport matplotlib.pyplot as plt\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-04-24T06:49:08.054630Z","iopub.execute_input":"2022-04-24T06:49:08.055244Z","iopub.status.idle":"2022-04-24T06:49:23.760959Z","shell.execute_reply.started":"2022-04-24T06:49:08.055202Z","shell.execute_reply":"2022-04-24T06:49:23.760171Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = '/kaggle/input/h-and-m-personalized-fashion-recommendations/'\ntrain      = pd.read_csv( path + 'transactions_train.csv')\nsample_sub = pd.read_csv(path + 'sample_submission.csv')\narticles   = pd.read_csv(path + 'articles.csv')\ncustomers  = pd.read_csv(path + 'customers.csv')","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:49:23.762684Z","iopub.execute_input":"2022-04-24T06:49:23.763527Z","iopub.status.idle":"2022-04-24T06:50:10.753698Z","shell.execute_reply.started":"2022-04-24T06:49:23.763480Z","shell.execute_reply":"2022-04-24T06:50:10.752596Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:10.755294Z","iopub.execute_input":"2022-04-24T06:50:10.755546Z","iopub.status.idle":"2022-04-24T06:50:10.767792Z","shell.execute_reply.started":"2022-04-24T06:50:10.755517Z","shell.execute_reply":"2022-04-24T06:50:10.766980Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_sub.head()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:10.769978Z","iopub.execute_input":"2022-04-24T06:50:10.770258Z","iopub.status.idle":"2022-04-24T06:50:10.787044Z","shell.execute_reply.started":"2022-04-24T06:50:10.770227Z","shell.execute_reply":"2022-04-24T06:50:10.786027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.head()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:10.788611Z","iopub.execute_input":"2022-04-24T06:50:10.790337Z","iopub.status.idle":"2022-04-24T06:50:10.818686Z","shell.execute_reply.started":"2022-04-24T06:50:10.790290Z","shell.execute_reply":"2022-04-24T06:50:10.817788Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.groupby(['product_group_name', 'product_type_name'])['article_id'].count()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:10.861116Z","iopub.execute_input":"2022-04-24T06:50:10.861588Z","iopub.status.idle":"2022-04-24T06:50:10.903990Z","shell.execute_reply.started":"2022-04-24T06:50:10.861551Z","shell.execute_reply":"2022-04-24T06:50:10.902163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"train['t_dat'] = pd.to_datetime(train['t_dat'])\nprint(f\"Min time - {train['t_dat'].min()}, Max time - {train['t_dat'].max()}\\n\")\ntrain['Day'] = train['t_dat'].dt.day\ntrain['Month'] = train['t_dat'].dt.month\ntrain['Year'] = train['t_dat'].dt.year\ntrain = train.drop(['t_dat'], axis ='columns')","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:10.907114Z","iopub.execute_input":"2022-04-24T06:50:10.907555Z","iopub.status.idle":"2022-04-24T06:50:29.283054Z","shell.execute_reply.started":"2022-04-24T06:50:10.907494Z","shell.execute_reply":"2022-04-24T06:50:29.282127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:29.284464Z","iopub.execute_input":"2022-04-24T06:50:29.284728Z","iopub.status.idle":"2022-04-24T06:50:29.292897Z","shell.execute_reply.started":"2022-04-24T06:50:29.284694Z","shell.execute_reply":"2022-04-24T06:50:29.290820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:29.294412Z","iopub.execute_input":"2022-04-24T06:50:29.294640Z","iopub.status.idle":"2022-04-24T06:50:29.330607Z","shell.execute_reply.started":"2022-04-24T06:50:29.294613Z","shell.execute_reply":"2022-04-24T06:50:29.329817Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.info()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:29.331898Z","iopub.execute_input":"2022-04-24T06:50:29.332130Z","iopub.status.idle":"2022-04-24T06:50:29.510878Z","shell.execute_reply.started":"2022-04-24T06:50:29.332101Z","shell.execute_reply":"2022-04-24T06:50:29.509942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#get numeric features\nnumeric_features = [f for f in articles.columns if articles[f].dtype != object]\narticles = articles[numeric_features]\narticles = articles.drop(['perceived_colour_value_id','perceived_colour_master_id','index_group_no','section_no','garment_group_no','product_type_no','graphical_appearance_no', 'department_no'], axis = 'columns')\narticles","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:29.512271Z","iopub.execute_input":"2022-04-24T06:50:29.513192Z","iopub.status.idle":"2022-04-24T06:50:29.532695Z","shell.execute_reply.started":"2022-04-24T06:50:29.513141Z","shell.execute_reply":"2022-04-24T06:50:29.532089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"merged = pd.merge(train, articles, on =\"article_id\")","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:29.534044Z","iopub.execute_input":"2022-04-24T06:50:29.534550Z","iopub.status.idle":"2022-04-24T06:50:51.100720Z","shell.execute_reply.started":"2022-04-24T06:50:29.534514Z","shell.execute_reply":"2022-04-24T06:50:51.098173Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"merged","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:50:51.102075Z","iopub.execute_input":"2022-04-24T06:50:51.102362Z","iopub.status.idle":"2022-04-24T06:50:51.125730Z","shell.execute_reply.started":"2022-04-24T06:50:51.102329Z","shell.execute_reply":"2022-04-24T06:50:51.125149Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (15,8))\nsns.countplot(merged['colour_group_code'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:54:31.381242Z","iopub.execute_input":"2022-04-24T06:54:31.381753Z","iopub.status.idle":"2022-04-24T06:54:34.594343Z","shell.execute_reply.started":"2022-04-24T06:54:31.381694Z","shell.execute_reply":"2022-04-24T06:54:34.593633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (15,8))\nsns.countplot(merged['Month'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:54:38.414212Z","iopub.execute_input":"2022-04-24T06:54:38.414800Z","iopub.status.idle":"2022-04-24T06:54:42.138398Z","shell.execute_reply.started":"2022-04-24T06:54:38.414762Z","shell.execute_reply":"2022-04-24T06:54:42.137286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (15,8))\nsns.countplot(merged['Day'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-04-24T06:55:50.338595Z","iopub.execute_input":"2022-04-24T06:55:50.339748Z","iopub.status.idle":"2022-04-24T06:55:54.874012Z","shell.execute_reply.started":"2022-04-24T06:55:50.339691Z","shell.execute_reply":"2022-04-24T06:55:54.873179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}}]}