{"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":"markdown","source":"<img src=\"https://www.bakingo.com/blog/wp-content/uploads/2020/02/Cover-Image-3-1.jpg\" alt=\"Paris\" class=\"center\">\n\nImage Source - Google Search\n<h2><p>&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;\n&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;\n</p> \n<h2 style=\"color:red;\">Thank you for checking this notebook.</h2>\n<h2 style=\"color:red;\">Please upvote if you like this notebbok.</h2>\n<h2 style=\"color:red;\">Feedbacks are welcome, Kindly provide your feedback in comments, we will try to improve.</h2>\n<h2>\n<p>&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;\n&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;&#128151;\n</p> ","metadata":{}},{"cell_type":"code","source":"#Importing libraries\nimport numpy as np\nimport pandas as pd\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom PIL import Image\n\n# Uploading data\narticles = 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')\ntransactions_train = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:06:17.601016Z","iopub.execute_input":"2022-02-13T11:06:17.601854Z","iopub.status.idle":"2022-02-13T11:07:20.236775Z","shell.execute_reply.started":"2022-02-13T11:06:17.601796Z","shell.execute_reply":"2022-02-13T11:07:20.235753Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"color:red;\">Top Selling Items - Valentine Week(7Feb -14Feb)</h1>","metadata":{}},{"cell_type":"code","source":"# colour_group_name\ntransactions_train['t_dat'] = pd.to_datetime(transactions_train['t_dat'], infer_datetime_format=True)\ntransactions_train['year'] = transactions_train['t_dat'].dt.year\ntransactions_train['mon'] = transactions_train['t_dat'].dt.month\ntransactions_train['day'] = transactions_train['t_dat'].dt.day\n\na = transactions_train[(transactions_train['mon'] == 2) & (transactions_train['day'] >=7) & (transactions_train['day'] <=14 )][['article_id', 'year']]\nb = articles[['article_id', 'colour_group_name']]\nval = pd.merge(a, b, how = 'inner', on = ['article_id']).reset_index()\nc = val.copy()\nc = c.groupby(by = ['article_id']).agg({'article_id':'count'})\nc.columns = ['Count']\nc = c.reset_index()\nc = c.sort_values(by = ['Count'], ascending=[False])\nc = c.head(11)\n\nplt.figure(figsize=(28, 10))\ni = 1\nfor j,x in enumerate(c['article_id'].to_list()):\n    try:\n        image = Image.open(\"../input/h-and-m-personalized-fashion-recommendations/images/0\"+str(x)[:2]+\"/0\"+str(x)+\".jpg\")\n        plt.subplot(2, 5, i)\n        plt.imshow(image)\n        #plt.axis('off')\n        plt.title(x)\n        plt.xlabel(\"Sell Count = \"+str(c['Count'].to_list()[j]))\n        i+=1\n    except:\n        pass\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:20.239003Z","iopub.execute_input":"2022-02-13T11:07:20.239278Z","iopub.status.idle":"2022-02-13T11:07:40.998860Z","shell.execute_reply.started":"2022-02-13T11:07:20.239236Z","shell.execute_reply":"2022-02-13T11:07:40.997908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"color:blue;\">Valentime Week Color Analysis</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:32:16.358496Z","iopub.execute_input":"2022-02-12T20:32:16.358752Z","iopub.status.idle":"2022-02-12T20:32:16.363366Z","shell.execute_reply.started":"2022-02-12T20:32:16.358728Z","shell.execute_reply":"2022-02-12T20:32:16.362568Z"}}},{"cell_type":"markdown","source":"![](https://appsforpcplanet.org/wp-content/uploads/2018/02/dress-code.jpg)\n\nImage Source = Google Search","metadata":{}},{"cell_type":"markdown","source":"<h1 style=\"color:red;\">Let do Top selling Color Analysis</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:45:16.334461Z","iopub.execute_input":"2022-02-12T20:45:16.334713Z","iopub.status.idle":"2022-02-12T20:45:16.340248Z","shell.execute_reply.started":"2022-02-12T20:45:16.334689Z","shell.execute_reply":"2022-02-12T20:45:16.339329Z"}}},{"cell_type":"code","source":"c = val.copy()\nc['final_color'] = None\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"red\"), \"red\", c['final_color'])\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"green\"), \"green\", c['final_color'])\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"white\"), \"white\", c['final_color'])\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"pink\"), \"pink\", c['final_color'])\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"blue\"), \"blue\", c['final_color'])\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"yellow\"), \"yellow\", c['final_color'])\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"black\"), \"black\", c['final_color'])\nc['final_color'] = np.where(c['colour_group_name'].str.lower().str.contains(\"orange\"), \"orange\", c['final_color'])\nc = c[c['final_color'].isna() == False]\n\nimport plotly.express as px\nd = c[c['year'] == 2019]['final_color'].value_counts().reset_index()\nd.columns = ['colour', 'cnt']\n#Creating grpah\ncolours = {\n    \"black\": \"#000000\",\n    \"blue\": \"#0000FF\",\n    \"white\": \"#FFFFFF\",\n    \"red\": \"#FF0000\",\n    \"pink\": \"#FF00FF\",\n    \"green\": \"#008000\",\n    \"yellow\": \"#FFFF00\",\n    \"orange\": \"#FFA500\"\n}\n\nplotly_plt = px.bar(d, x=\"colour\", y=[\"cnt\"], \n             #barmode = \"group\",\n#              labels={'color':'Color',\n#                      'cnt':'Count'                    },\n             title= \"2019 Valentine Week - Top Selling Color\",\n             #color=[\"default_pct\", \"total_pct\"],\n             #hover_name = \"default_pct\",\n             #text = [\"default_pct\", \"total_pct\"],\n             color=\"colour\",\n             text=\"value\",\n             width=1000, height=500,\n             color_discrete_map=colours,\n            )\nplotly_plt.show()\n\nd = c[c['year'] == 2020]['final_color'].value_counts().reset_index()\nd.columns = ['colour', 'cnt']\nplotly_plt = px.bar(d, x=\"colour\", y=[\"cnt\"], \n             #barmode = \"group\",\n#              labels={'color':'Color',\n#                      'cnt':'Count'                    },\n             title= \"2020 Valentine Week - Top Selling Color\",\n             #color=[\"default_pct\", \"total_pct\"],\n             #hover_name = \"default_pct\",\n             #text = [\"default_pct\", \"total_pct\"],\n             color=\"colour\",\n             text=\"value\",\n             width=1000, height=500,\n             color_discrete_map=colours,\n            )\nplotly_plt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:41.000646Z","iopub.execute_input":"2022-02-13T11:07:41.001318Z","iopub.status.idle":"2022-02-13T11:07:46.472970Z","shell.execute_reply.started":"2022-02-13T11:07:41.001266Z","shell.execute_reply":"2022-02-13T11:07:46.472039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def color_analysis(inp_color, no=5):\n    c = val.copy()\n    c = c[c['colour_group_name'].str.lower().str.contains(inp_color.lower())]\n    c = c.groupby(by = ['article_id', 'colour_group_name']).agg({'article_id':'count'})\n    c.columns = ['Count']\n    c = c.reset_index()\n    c = c.sort_values(by = ['Count'], ascending=[False])\n    c = c.head(no)\n\n    plt.figure(figsize=(28, 10))\n    i = 1\n    for j,x in enumerate(c['article_id'].to_list()):\n        try:\n            image = Image.open(\"../input/h-and-m-personalized-fashion-recommendations/images/0\"+str(x)[:2]+\"/0\"+str(x)+\".jpg\")\n            plt.subplot(2, 5, i)\n            plt.imshow(image)\n            #plt.axis('off')\n            plt.title(x)\n            plt.xlabel(\"Sell Count = \"+str(c['Count'].to_list()[j]))\n            plt.xlabel(\"Color = \"+str(c['colour_group_name'].to_list()[j]))\n            i+=1\n        except:\n            pass\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:46.475091Z","iopub.execute_input":"2022-02-13T11:07:46.475356Z","iopub.status.idle":"2022-02-13T11:07:46.485539Z","shell.execute_reply.started":"2022-02-13T11:07:46.475323Z","shell.execute_reply":"2022-02-13T11:07:46.484816Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"color:red;\">Red - Already in Love</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"red\")","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:46.486726Z","iopub.execute_input":"2022-02-13T11:07:46.487330Z","iopub.status.idle":"2022-02-13T11:07:49.557954Z","shell.execute_reply.started":"2022-02-13T11:07:46.487282Z","shell.execute_reply":"2022-02-13T11:07:49.557062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"color:green;\">I am waiting...</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"green\")","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:49.559512Z","iopub.execute_input":"2022-02-13T11:07:49.560386Z","iopub.status.idle":"2022-02-13T11:07:52.927232Z","shell.execute_reply.started":"2022-02-13T11:07:49.560334Z","shell.execute_reply":"2022-02-13T11:07:52.926462Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"background-color:black; color:white;\">Already booked</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"white\", 6)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:52.928446Z","iopub.execute_input":"2022-02-13T11:07:52.929140Z","iopub.status.idle":"2022-02-13T11:07:56.041195Z","shell.execute_reply.started":"2022-02-13T11:07:52.929104Z","shell.execute_reply":"2022-02-13T11:07:56.040294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\" background-color:black;color:pink;\">Proprsal Accepted</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"pink\", 5)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:56.042772Z","iopub.execute_input":"2022-02-13T11:07:56.043035Z","iopub.status.idle":"2022-02-13T11:07:59.104129Z","shell.execute_reply.started":"2022-02-13T11:07:56.043001Z","shell.execute_reply":"2022-02-13T11:07:59.103284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"color:blue;\">Love Applications Invited...</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"blue\", 5)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:07:59.105633Z","iopub.execute_input":"2022-02-13T11:07:59.106287Z","iopub.status.idle":"2022-02-13T11:08:02.280559Z","shell.execute_reply.started":"2022-02-13T11:07:59.106240Z","shell.execute_reply":"2022-02-13T11:08:02.279522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"background-color:black; color:yellow;\">Broke Up</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"yellow\", 5)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:08:02.282875Z","iopub.execute_input":"2022-02-13T11:08:02.283151Z","iopub.status.idle":"2022-02-13T11:08:05.374374Z","shell.execute_reply.started":"2022-02-13T11:08:02.283115Z","shell.execute_reply":"2022-02-13T11:08:05.373309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"color:black;\">Rejected Proposal</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"black\", 6)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:08:05.375738Z","iopub.execute_input":"2022-02-13T11:08:05.375984Z","iopub.status.idle":"2022-02-13T11:08:08.718585Z","shell.execute_reply.started":"2022-02-13T11:08:05.375954Z","shell.execute_reply":"2022-02-13T11:08:08.717614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"color:orange;\">Going to Propose</h1>","metadata":{"execution":{"iopub.status.busy":"2022-02-12T20:33:55.424422Z","iopub.execute_input":"2022-02-12T20:33:55.424829Z","iopub.status.idle":"2022-02-12T20:33:55.428832Z","shell.execute_reply.started":"2022-02-12T20:33:55.424792Z","shell.execute_reply":"2022-02-12T20:33:55.42823Z"}}},{"cell_type":"code","source":"color_analysis(\"orange\", 5)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-02-13T11:08:08.719915Z","iopub.execute_input":"2022-02-13T11:08:08.720161Z","iopub.status.idle":"2022-02-13T11:08:11.774002Z","shell.execute_reply.started":"2022-02-13T11:08:08.720132Z","shell.execute_reply":"2022-02-13T11:08:11.772920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h4 style=\"color:red;\">*Products are ignored for which image is not avaialble in image showing output columns</h4>","metadata":{"execution":{"iopub.status.busy":"2022-02-13T11:09:35.580756Z","iopub.execute_input":"2022-02-13T11:09:35.581729Z","iopub.status.idle":"2022-02-13T11:09:35.586532Z","shell.execute_reply.started":"2022-02-13T11:09:35.581683Z","shell.execute_reply":"2022-02-13T11:09:35.585708Z"}}}]}