{"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 matplotlib.pyplot as plt\nimport tensorflow as tf","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-28T10:42:26.353675Z","iopub.execute_input":"2022-03-28T10:42:26.354864Z","iopub.status.idle":"2022-03-28T10:42:32.318618Z","shell.execute_reply.started":"2022-03-28T10:42:26.354799Z","shell.execute_reply":"2022-03-28T10:42:32.317807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = \"../input/h-m-eda/\"\n\narticles = pd.read_csv(path + \"articles_data.csv\")\ncustomers = pd.read_csv(path + \"customers_data.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-03-28T10:12:25.767482Z","iopub.execute_input":"2022-03-28T10:12:25.767848Z","iopub.status.idle":"2022-03-28T10:12:30.132316Z","shell.execute_reply.started":"2022-03-28T10:12:25.767801Z","shell.execute_reply":"2022-03-28T10:12:30.131226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-28T10:10:38.661500Z","iopub.execute_input":"2022-03-28T10:10:38.661995Z","iopub.status.idle":"2022-03-28T10:10:38.699599Z","shell.execute_reply.started":"2022-03-28T10:10:38.661944Z","shell.execute_reply":"2022-03-28T10:10:38.698935Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-28T10:10:43.892130Z","iopub.execute_input":"2022-03-28T10:10:43.892416Z","iopub.status.idle":"2022-03-28T10:10:43.908358Z","shell.execute_reply.started":"2022-03-28T10:10:43.892381Z","shell.execute_reply":"2022-03-28T10:10:43.907466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"chunks = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\", chunksize=5298054) #this will result in 6 chunks\n\nchunk_list = []\n\nfor chunk in chunks:\n    #chunk_filter = chunk.drop(['sales_channel_id'], axis=1) \n    \n    chunk_list.append(chunk)\ntransactions = pd.concat(chunk_list)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T10:17:41.355753Z","iopub.execute_input":"2022-03-28T10:17:41.356053Z","iopub.status.idle":"2022-03-28T10:18:17.656186Z","shell.execute_reply.started":"2022-03-28T10:17:41.356023Z","shell.execute_reply":"2022-03-28T10:18:17.655269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transactions","metadata":{"execution":{"iopub.status.busy":"2022-03-28T10:18:40.406774Z","iopub.execute_input":"2022-03-28T10:18:40.407251Z","iopub.status.idle":"2022-03-28T10:18:40.421046Z","shell.execute_reply.started":"2022-03-28T10:18:40.407217Z","shell.execute_reply":"2022-03-28T10:18:40.420049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### First strategy: We can use LSTM for each customer to predict the next buy based on the previous ones","metadata":{}},{"cell_type":"code","source":"for customer in customers.customer_id:\n    customer_transactions = transactions[transactions.customer_id == customer].drop(['customer_id'], axis=1)\n    X = customer_transactions.drop(['article_id'], axis=1)\n    y = customer_transactions['article_id']\n    \n    ","metadata":{"execution":{"iopub.status.busy":"2022-03-28T10:31:09.625717Z","iopub.execute_input":"2022-03-28T10:31:09.626055Z","iopub.status.idle":"2022-03-28T10:41:51.630387Z","shell.execute_reply.started":"2022-03-28T10:31:09.626021Z","shell.execute_reply":"2022-03-28T10:41:51.628106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}