{"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":"Product Recommendation by HandM , we have different types of data provided by HandM and we will look into each data set to find best recommendation systems :\n","metadata":{}},{"cell_type":"markdown","source":"Thanks to these notebooks for great insights","metadata":{}},{"cell_type":"markdown","source":"https://www.kaggle.com/gpreda/h-m-eda-and-prediction\n\nhttps://www.kaggle.com/vanguarde/h-m-eda-first-look","metadata":{}},{"cell_type":"raw","source":"we have four different type of datas provided :\n1. Images : image of every article id\n2. Articles : detailed meta data of every article\n3. Customers : detailed meta data of each customer\n4. Transiction : purchase with details","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom tqdm.notebook import tqdm","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:49.906333Z","iopub.execute_input":"2022-02-20T17:52:49.906672Z","iopub.status.idle":"2022-02-20T17:52:50.890409Z","shell.execute_reply.started":"2022-02-20T17:52:49.906589Z","shell.execute_reply":"2022-02-20T17:52:50.889452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Let us look at each data set","metadata":{}},{"cell_type":"markdown","source":"# Articles","metadata":{}},{"cell_type":"code","source":"articles = pd.read_csv('../input/h-and-m-personalized-fashion-recommendations/articles.csv')","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:50.892392Z","iopub.execute_input":"2022-02-20T17:52:50.892866Z","iopub.status.idle":"2022-02-20T17:52:52.082797Z","shell.execute_reply.started":"2022-02-20T17:52:50.892821Z","shell.execute_reply":"2022-02-20T17:52:52.081817Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.set_option('display.max_columns',None)\narticles.head(2)","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.084232Z","iopub.execute_input":"2022-02-20T17:52:52.084468Z","iopub.status.idle":"2022-02-20T17:52:52.113374Z","shell.execute_reply.started":"2022-02-20T17:52:52.084438Z","shell.execute_reply":"2022-02-20T17:52:52.112756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Let us look into all columns:\n\narticle id : uid for article\n\nproduct_code and product_name for different products\n\nproduct_type_name and product_type_no : they are parent group of product_name , ie every product_name belongs to some product_type_name\n\nproduct_group_name : every product is part of some group\n\ngraphical appearence : for every cloth it has some graphical appearence and a unique code for each type of graphical appearence\n\ncolor group code and color name : color of each product and each percieved color columns gives more info about color of the product\n\nindex code and index name : unique index and name for products\n\nsection name and section number : section which product belongs to\n\ngarment group name and number : type of garment with its unique id\n\ndesc : description for the product\n\n\n\n\n\n","metadata":{}},{"cell_type":"markdown","source":"# Initial Data Analysis For the Articles ","metadata":{}},{"cell_type":"markdown","source":"looking for different unique data in different columns ","metadata":{}},{"cell_type":"code","source":"len(articles['prod_name'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.114747Z","iopub.execute_input":"2022-02-20T17:52:52.115445Z","iopub.status.idle":"2022-02-20T17:52:52.154849Z","shell.execute_reply.started":"2022-02-20T17:52:52.115384Z","shell.execute_reply":"2022-02-20T17:52:52.153970Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"45875 different type of products we have with us here","metadata":{}},{"cell_type":"code","source":"len(articles['product_type_name'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.156297Z","iopub.execute_input":"2022-02-20T17:52:52.156664Z","iopub.status.idle":"2022-02-20T17:52:52.173661Z","shell.execute_reply.started":"2022-02-20T17:52:52.156622Z","shell.execute_reply":"2022-02-20T17:52:52.173003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"131 different type of product type in our dataset","metadata":{}},{"cell_type":"code","source":"len(articles['product_group_name'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.174717Z","iopub.execute_input":"2022-02-20T17:52:52.175160Z","iopub.status.idle":"2022-02-20T17:52:52.189256Z","shell.execute_reply.started":"2022-02-20T17:52:52.175125Z","shell.execute_reply":"2022-02-20T17:52:52.188415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"19 different groups in which all the products lie","metadata":{}},{"cell_type":"code","source":"import seaborn as sns\nf,ax = plt.subplots(figsize=(15,7))\nax = sns.histplot(data=articles,y='product_group_name',color='red')\nax.set_xlabel('Count')\nax.set_ylabel('Group Name')","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.190515Z","iopub.execute_input":"2022-02-20T17:52:52.190807Z","iopub.status.idle":"2022-02-20T17:52:52.632830Z","shell.execute_reply.started":"2022-02-20T17:52:52.190778Z","shell.execute_reply":"2022-02-20T17:52:52.632091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(articles['index_group_name'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.634290Z","iopub.execute_input":"2022-02-20T17:52:52.634653Z","iopub.status.idle":"2022-02-20T17:52:52.646659Z","shell.execute_reply.started":"2022-02-20T17:52:52.634613Z","shell.execute_reply":"2022-02-20T17:52:52.646141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"so 5 different index groups in our dataset , let us see these different index groups","metadata":{}},{"cell_type":"code","source":"sns.countplot(articles['index_group_name'])","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.647518Z","iopub.execute_input":"2022-02-20T17:52:52.648226Z","iopub.status.idle":"2022-02-20T17:52:52.926738Z","shell.execute_reply.started":"2022-02-20T17:52:52.648192Z","shell.execute_reply":"2022-02-20T17:52:52.925899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Ladies wear is dominating different index groups and it is quite visible when you visit any H&M outlet hahah !","metadata":{}},{"cell_type":"markdown","source":"Let us see different garment groups under each of these index groups !","metadata":{}},{"cell_type":"code","source":"f, ax = plt.subplots(figsize=(15, 7))\nax = sns.histplot(data=articles, y='index_name', color='orange')\nax.set_xlabel('count by index name')\nax.set_ylabel('index name')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:52.930781Z","iopub.execute_input":"2022-02-20T17:52:52.931232Z","iopub.status.idle":"2022-02-20T17:52:53.239748Z","shell.execute_reply.started":"2022-02-20T17:52:52.931187Z","shell.execute_reply":"2022-02-20T17:52:53.239151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"index size gives more data insights of data in index","metadata":{}},{"cell_type":"markdown","source":"Index Group and Index Name structure , let us look how both are dividing data","metadata":{}},{"cell_type":"code","source":"articles.groupby(['index_group_name','index_name']).count()['article_id']","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:52:53.241370Z","iopub.execute_input":"2022-02-20T17:52:53.241945Z","iopub.status.idle":"2022-02-20T17:52:53.350517Z","shell.execute_reply.started":"2022-02-20T17:52:53.241902Z","shell.execute_reply":"2022-02-20T17:52:53.349531Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"let us see what is garment group name","metadata":{}},{"cell_type":"code","source":"articles['garment_group_name']","metadata":{"execution":{"iopub.status.busy":"2022-02-20T17:59:30.425807Z","iopub.execute_input":"2022-02-20T17:59:30.426083Z","iopub.status.idle":"2022-02-20T17:59:30.434090Z","shell.execute_reply.started":"2022-02-20T17:59:30.426051Z","shell.execute_reply":"2022-02-20T17:59:30.433547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(articles['garment_group_name'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:00:31.840630Z","iopub.execute_input":"2022-02-20T18:00:31.840917Z","iopub.status.idle":"2022-02-20T18:00:31.854048Z","shell.execute_reply.started":"2022-02-20T18:00:31.840884Z","shell.execute_reply":"2022-02-20T18:00:31.853073Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.groupby(['index_group_name','garment_group_name']).count()['article_id']","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:04:47.458482Z","iopub.execute_input":"2022-02-20T18:04:47.458776Z","iopub.status.idle":"2022-02-20T18:04:47.558089Z","shell.execute_reply.started":"2022-02-20T18:04:47.458743Z","shell.execute_reply":"2022-02-20T18:04:47.557099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.groupby(['index_name','garment_group_name']).count()['article_id']","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:02:14.934119Z","iopub.execute_input":"2022-02-20T18:02:14.934453Z","iopub.status.idle":"2022-02-20T18:02:15.042250Z","shell.execute_reply.started":"2022-02-20T18:02:14.934405Z","shell.execute_reply":"2022-02-20T18:02:15.041238Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"let us look at a sunbarst chart to understand the hierarichal structure between index_name , index_group_name and garment_group_name","metadata":{}},{"cell_type":"code","source":"import plotly.express as px\nfig = px.sunburst(articles, path=['index_group_name', 'index_name', 'garment_group_name'],width=800,\n    height=800,color_discrete_sequence=px.colors.cyclical.Edge)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:06:11.772054Z","iopub.execute_input":"2022-02-20T18:06:11.772517Z","iopub.status.idle":"2022-02-20T18:06:14.201127Z","shell.execute_reply.started":"2022-02-20T18:06:11.772474Z","shell.execute_reply":"2022-02-20T18:06:14.200438Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(articles['product_group_name'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:20:30.971942Z","iopub.execute_input":"2022-02-20T18:20:30.972197Z","iopub.status.idle":"2022-02-20T18:20:30.986481Z","shell.execute_reply.started":"2022-02-20T18:20:30.972170Z","shell.execute_reply":"2022-02-20T18:20:30.985250Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(articles.groupby(['product_group_name','garment_group_name']).count()['article_id'])","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:27:15.625794Z","iopub.execute_input":"2022-02-20T18:27:15.626093Z","iopub.status.idle":"2022-02-20T18:27:15.724899Z","shell.execute_reply.started":"2022-02-20T18:27:15.626058Z","shell.execute_reply":"2022-02-20T18:27:15.723919Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nfig = px.sunburst(articles, path=['product_group_name', 'garment_group_name'],width=800,\n    height=800,color_discrete_sequence=px.colors.cyclical.Edge)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:28:05.365668Z","iopub.execute_input":"2022-02-20T18:28:05.365951Z","iopub.status.idle":"2022-02-20T18:28:06.646265Z","shell.execute_reply.started":"2022-02-20T18:28:05.365918Z","shell.execute_reply":"2022-02-20T18:28:06.645407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Section Wise Data ","metadata":{}},{"cell_type":"code","source":"len(articles['section_name'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-02-20T18:17:35.162833Z","iopub.execute_input":"2022-02-20T18:17:35.163100Z","iopub.status.idle":"2022-02-20T18:17:35.176221Z","shell.execute_reply.started":"2022-02-20T18:17:35.163069Z","shell.execute_reply":"2022-02-20T18:17:35.175413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}