{"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":"<span style=\"font-family:cursive; font-size:25px; color:crimson;\"> Introduction </span>\n\nH&M Group is a family of brands and businesses with 53 online markets and approximately 4,850 stores. Our online store offers shoppers an extensive selection of products to browse through. But with too many choices, customers might not quickly find what interests them or what they are looking for, and ultimately, they might not make a purchase. To enhance the shopping experience, product recommendations are key. More importantly, helping customers make the right choices also has a positive implications for sustainability, as it reduces returns, and thereby minimizes emissions from transportation.\n\nIn this competition, H&M Group invites you to develop product recommendations based on data from previous transactions, as well as from customer and product meta data. The available meta data spans from simple data, such as garment type and customer age, to text data from product descriptions, to image data from garment images.\n\nThere are no preconceptions on what information that may be useful – that is for you to find out. If you want to investigate a categorical data type algorithm, or dive into NLP and image processing deep learning, that is up to you.\n\n<img src=\"https://www.ecotextile.com/images/stories/2021/November/HnM.jpg\" width=500></img>\n\n<span style=\"font-family:cursive; font-size:25px; color:crimson;\"> Data Description </span> \n\nFor this challenge you are given the purchase history of customers across time, along with supporting metadata. Your challenge is to predict what articles each customer will purchase in the 7-day period immediately after the training data ends. Customer who did not make any purchase during that time are excluded from the scoring.\n\n<span style=\"font-family:cursive; font-size:25px; color:crimson;\"> Files </span>\n\n\n* images/ - a folder of images corresponding to each article_id; images are placed in subfolders starting with the first three digits of the article_id; note, not all article_id values have a corresponding image.\n* articles.csv - detailed metadata for each article_id available for purchase\n* customers.csv - metadata for each customer_id in dataset\n* sample_submission.csv - a sample submission file in the correct format\n* transactions_train.csv - the training data, consisting of the purchases each customer for each date, as well as additional information. Duplicate rows correspond to multiple purchases of the same item. Your task is to predict the article_ids each customer will purchase during the 7-day period immediately after the training data period.\n\nNOTE: You must make predictions for all customer_id values found in the sample submission. All customers who made purchases during the test period are scored, regardless of whether they had purchase history in the training data.","metadata":{}},{"cell_type":"markdown","source":"<span style=\"font-family:cursive; font-size:25px; color:crimson;\"> Going through data </span>","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\narticle = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/articles.csv\")\ncustomer = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/customers.csv\")\nsample_submission = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/sample_submission.csv\")\ntransaction_train = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:02:03.926273Z","iopub.execute_input":"2022-02-19T06:02:03.926621Z","iopub.status.idle":"2022-02-19T06:03:41.243408Z","shell.execute_reply.started":"2022-02-19T06:02:03.926517Z","shell.execute_reply":"2022-02-19T06:03:41.242332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:03:41.244598Z","iopub.execute_input":"2022-02-19T06:03:41.244788Z","iopub.status.idle":"2022-02-19T06:03:41.296407Z","shell.execute_reply.started":"2022-02-19T06:03:41.244742Z","shell.execute_reply":"2022-02-19T06:03:41.295296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:03:41.297776Z","iopub.execute_input":"2022-02-19T06:03:41.298013Z","iopub.status.idle":"2022-02-19T06:03:41.311179Z","shell.execute_reply.started":"2022-02-19T06:03:41.29798Z","shell.execute_reply":"2022-02-19T06:03:41.310275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:03:41.312997Z","iopub.execute_input":"2022-02-19T06:03:41.313171Z","iopub.status.idle":"2022-02-19T06:03:41.333083Z","shell.execute_reply.started":"2022-02-19T06:03:41.313151Z","shell.execute_reply":"2022-02-19T06:03:41.331742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transaction_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:03:41.334788Z","iopub.execute_input":"2022-02-19T06:03:41.335052Z","iopub.status.idle":"2022-02-19T06:03:41.354309Z","shell.execute_reply.started":"2022-02-19T06:03:41.335016Z","shell.execute_reply":"2022-02-19T06:03:41.3534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nlabel = article.index_group_name.unique()\ncount = article.index_group_name.value_counts()\nfig = px.pie(article, values=count, names=label,color_discrete_sequence=px.colors.sequential.Purpor)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:03:41.355613Z","iopub.execute_input":"2022-02-19T06:03:41.356131Z","iopub.status.idle":"2022-02-19T06:03:44.500897Z","shell.execute_reply.started":"2022-02-19T06:03:41.356095Z","shell.execute_reply":"2022-02-19T06:03:44.499834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"name = article.garment_group_name.unique()\nsizes = article.garment_group_name.value_counts()\nfig = px.bar(article, y=sizes, x=name, color = name,color_discrete_sequence=px.colors.sequential.Plotly3\n            )\nfig.update_layout(\n    title=\"Count of Garment Group Name\",\n    xaxis_title=\"Garment Group Name\",\n    yaxis_title=\"Count\"\n)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:03:44.502186Z","iopub.execute_input":"2022-02-19T06:03:44.502412Z","iopub.status.idle":"2022-02-19T06:03:44.757142Z","shell.execute_reply.started":"2022-02-19T06:03:44.502368Z","shell.execute_reply":"2022-02-19T06:03:44.755722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Jersey Basic has the highest count while Dresses/Skirts for girls has the lowest count ","metadata":{}},{"cell_type":"code","source":"name = article.index_name.unique()\nsizes = article.index_name.value_counts()\nfig = px.bar(article, y=sizes, x=name, color = name,color_discrete_sequence=px.colors.diverging.Picnic)\nfig.update_layout(\n    title=\"Count of Index name\",\n    xaxis_title=\"index_name\",\n    yaxis_title=\"Count\"\n)\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-19T06:03:44.758663Z","iopub.execute_input":"2022-02-19T06:03:44.758905Z","iopub.status.idle":"2022-02-19T06:03:44.905782Z","shell.execute_reply.started":"2022-02-19T06:03:44.758876Z","shell.execute_reply":"2022-02-19T06:03:44.905018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the above graph, Ladieswear has maximum number of count and children accessories,swimwear has the least number of counts","metadata":{}},{"cell_type":"markdown","source":"<span style=\"font-family:cursive; font-size:25px; color:crimson;\"> Sunburst Chart </span>","metadata":{}},{"cell_type":"markdown","source":"Sunburst plots visualize hierarchical data spanning outwards radially from root to leaves. The root starts from the center and children are added to the outer rings.","metadata":{}},{"cell_type":"code","source":"fig = px.sunburst(article, 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-19T06:03:44.907116Z","iopub.execute_input":"2022-02-19T06:03:44.907363Z","iopub.status.idle":"2022-02-19T06:03:47.232354Z","shell.execute_reply.started":"2022-02-19T06:03:44.907325Z","shell.execute_reply":"2022-02-19T06:03:47.231296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**<span style=\"color:purple;\"> Click on different parents(Ladieswear,Sport,Divided,etc) to interact more with it and to see nice visualization effect</span>**\n\nIn above graph different color represents different sections\n\nIn the middle is the parent and it is further subdivided into various types\n\nFor example Baby/Children shown in the middle is the parent and it is further divided into different children sizes, baby sizes, children accessories and swimwear.","metadata":{}},{"cell_type":"markdown","source":"I am on my way to find more cool visualizations if I find more I will update the notebook or make a new one :)","metadata":{}}]}