{"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 cv2\nimport numpy as np # linear algebra\nimport os\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport plotly.express as px\nfrom os import listdir\nfrom os.path import isfile, join\nfrom scipy.stats import pearsonr\n\nfrom termcolor import colored\nfrom IPython.display import HTML\n\nimport warnings\npd.set_option('display.max_rows', None)\npd.set_option('display.max_columns', None)\npd.set_option('float_format', '{:f}'.format)\nwarnings.filterwarnings('ignore')\n\ni=0\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        #print(os.path.join(dirname, filename))\n        i=i+1\n\n\nfrom IPython.display import Markdown\ndef bold(string):\n    display(Markdown(string))\n    \nimport warnings as wrn\nwrn.filterwarnings('ignore', category = DeprecationWarning) \nwrn.filterwarnings('ignore', category = FutureWarning) \nwrn.filterwarnings('ignore', category = UserWarning)\nfrom IPython.core.display import display, HTML, Javascript\n\n# ----- Notebook Theme -----\n#Source from https://www.kaggle.com/yamqwe/the-nuclear-option-infer-cb68f9 \nnotebook_theme = 'pomegranate'\ncolor_maps = {'turquoise': ['#1abc9c', '#e8f8f5', '#d1f2eb', '#a3e4d7', '#76d7c4', '#48c9b0', '#1abc9c', '#17a589', '#148f77', '#117864', '#0e6251'], \n              'green': ['#16a085', '#e8f6f3', '#d0ece7', '#a2d9ce', '#73c6b6', '#45b39d', '#16a085', '#138d75', '#117a65', '#0e6655', '#0b5345'], \n              'emerald': ['#2ecc71', '#eafaf1', '#d5f5e3', '#abebc6', '#82e0aa', '#58d68d', '#2ecc71', '#28b463', '#239b56', '#1d8348', '#186a3b'], \n              'nephritis': ['#27ae60', '#e9f7ef', '#d4efdf', '#a9dfbf', '#7dcea0', '#52be80', '#27ae60', '#229954', '#1e8449', '#196f3d', '#145a32'], \n              'peter': ['#3498db', '#ebf5fb', '#d6eaf8', '#aed6f1', '#85c1e9', '#5dade2', '#3498db', '#2e86c1', '#2874a6', '#21618c', '#1b4f72'], \n              'belize': ['#2980b9', '#eaf2f8', '#d4e6f1', '#a9cce3', '#7fb3d5', '#5499c7', '#2980b9', '#2471a3', '#1f618d', '#1a5276', '#154360'], \n              'amethyst': ['#9b59b6', '#f5eef8', '#ebdef0', '#d7bde2', '#c39bd3', '#af7ac5', '#9b59b6', '#884ea0', '#76448a', '#633974', '#512e5f'], \n              'wisteria': ['#8e44ad', '#f4ecf7', '#e8daef', '#d2b4de', '#bb8fce', '#a569bd', '#8e44ad', '#7d3c98', '#6c3483', '#5b2c6f', '#4a235a'], \n              'wet': ['#34495e', '#ebedef', '#d6dbdf', '#aeb6bf', '#85929e', '#5d6d7e', '#34495e', '#2e4053', '#283747', '#212f3c', '#1b2631'], \n              'midnight': ['#2c3e50', '#eaecee', '#d5d8dc', '#abb2b9', '#808b96', '#566573', '#2c3e50', '#273746', '#212f3d', '#1c2833', '#17202a'], \n              'sunflower': ['#f1c40f', '#fef9e7', '#fcf3cf', '#f9e79f', '#f7dc6f', '#f4d03f', '#f1c40f', '#d4ac0d', '#b7950b', '#9a7d0a', '#7d6608'], \n              'orange': ['#f39c12', '#fef5e7', '#fdebd0', '#fad7a0', '#f8c471', '#f5b041', '#f39c12', '#d68910', '#b9770e', '#9c640c', '#7e5109'], \n              'carrot': ['#e67e22', '#fdf2e9', '#fae5d3', '#f5cba7', '#f0b27a', '#eb984e', '#e67e22', '#ca6f1e', '#af601a', '#935116', '#784212'], \n              'pumpkin': ['#d35400', '#fbeee6', '#f6ddcc', '#edbb99', '#e59866', '#dc7633', '#d35400', '#ba4a00', '#a04000', '#873600', '#6e2c00'], \n              'alizarin': ['#e74c3c', '#fdedec', '#fadbd8', '#f5b7b1', '#f1948a', '#ec7063', '#e74c3c', '#cb4335', '#b03a2e', '#943126', '#78281f'], \n              'pomegranate': ['#c0392b', '#f9ebea', '#f2d7d5', '#e6b0aa', '#d98880', '#cd6155', '#c0392b', '#a93226', '#922b21', '#7b241c', '#641e16'], \n              'clouds': ['#ecf0f1', '#fdfefe', '#fbfcfc', '#f7f9f9', '#f4f6f7', '#f0f3f4', '#ecf0f1', '#d0d3d4', '#b3b6b7', '#979a9a', '#7b7d7d'], \n              'silver': ['#bdc3c7', '#f8f9f9', '#f2f3f4', '#e5e7e9', '#d7dbdd', '#cacfd2', '#bdc3c7', '#a6acaf', '#909497', '#797d7f', '#626567'], \n              'concrete': ['#95a5a6', '#f4f6f6', '#eaeded', '#d5dbdb', '#bfc9ca', '#aab7b8', '#95a5a6', '#839192', '#717d7e', '#5f6a6a', '#4d5656'], \n              'asbestos': ['#7f8c8d', '#f2f4f4', '#e5e8e8', '#ccd1d1', '#b2babb', '#99a3a4', '#7f8c8d', '#707b7c', '#616a6b', '#515a5a', '#424949']}\ncolor_maps = {i: color_maps[i] for i in color_maps if i not in ['clouds', 'silver', 'concrete', 'asbestos', 'wet asphalt', 'midnight blue', 'wet']}\nCMAP = 'turquoise'\nprompt = '#1DBCCD'\nmain_color = '#E58F65' # color_maps[notebook_theme]\nstrong_main_color = '#EB9514' # = color_maps[notebook_theme] \ncustom_colors = [strong_main_color, main_color]\n\n\n# ----- Notebook Theme -----\n\nhtml_contents =\"\"\"\n<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <link rel=\"stylesheet\" href=\"https://www.w3schools.com/w3css/4/w3.css\">\n        <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Raleway\">\n        <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Oswald\">\n        <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Open Sans\">\n        <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css\">\n        <style>\n        .title-section{\n            font-family: \"Oswald\", Arial, sans-serif;\n            font-weight: bold;\n            color: \"#6A8CAF\";\n            letter-spacing: 6px;\n        }\n        hr { border: 1px solid #E58F65 !important;\n             color: #E58F65 !important;\n             background: #E58F65 !important;\n           }\n        body {\n            font-family: \"Open Sans\", sans-serif;\n            }        \n        </style>\n    </head>    \n</html>\n\"\"\"\n\nHTML(html_contents)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:03:02.573768Z","iopub.execute_input":"2022-03-09T17:03:02.574045Z","iopub.status.idle":"2022-03-09T17:03:32.838873Z","shell.execute_reply.started":"2022-03-09T17:03:02.574012Z","shell.execute_reply":"2022-03-09T17:03:32.838163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"css_file = '''\ndiv #notebook {\nbackground-color: white;\nfont-family: 'Open Sans', Helvetica, sans-serif;\nline-height: 20px;\n}\n\n#notebook-container {\nmargin-top: 2em;\npadding-top: 2em;\nborder-top: 4px solid %s; /* light orange */\n-webkit-box-shadow: 0px 0px 8px 2px rgba(224, 212, 226, 0.5); /* pink */\n    box-shadow: 0px 0px 8px 2px rgba(224, 212, 226, 0.5); /* pink */\n}\n\ndiv .input {\nmargin-bottom: 1em;\n}\n\n.rendered_html h1, .rendered_html h2, .rendered_html h3, .rendered_html h4, .rendered_html h5, .rendered_html h6 {\ncolor: %s; /* light orange */\nfont-weight: 600;\n}\n\n.rendered_html code {\n    background-color: #efefef; /* light gray */\n}\n\n.CodeMirror {\ncolor: #8c8c8c; /* dark gray */\npadding: 0.7em;\n}\n\ndiv.input_area {\nborder: none;\n    background-color: %s; /* rgba(229, 143, 101, 0.1); light orange [exactly #E58F65] */\n    border-top: 2px solid %s; /* light orange */\n}\n\ndiv.input_prompt {\ncolor: %s; /* light blue */\n}\n\ndiv.output_prompt {\ncolor: %s; /* strong orange */\n}\n\ndiv.cell.selected:before, div.cell.selected.jupyter-soft-selected:before {\nbackground: %s; /* light orange */\n}\n\ndiv.cell.selected, div.cell.selected.jupyter-soft-selected {\n    border-color: %s; /* light orange */\n}\n\n.edit_mode div.cell.selected:before {\nbackground: %s; /* light orange */\n}\n\n.edit_mode div.cell.selected {\nborder-color: %s; /* light orange */\n\n}\n'''\ndef to_rgb(h): return tuple(int(h[i:i+2], 16) for i in (0, 2, 4))\nmain_color_rgba = 'rgba(%s, %s, %s, 0.1)' % (to_rgb(main_color[1:])[0], to_rgb(main_color[1:])[1], to_rgb(main_color[1:])[2])\nopen('notebook.css', 'w').write(css_file % (main_color, main_color, main_color_rgba, main_color,  prompt, strong_main_color, main_color, main_color, main_color, main_color))\nfrom IPython.core.display import display, HTML, Javascript\ndef nb(): return HTML(\"<style>\" + open(\"notebook.css\", \"r\").read() + \"</style>\")\nnb()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:03:32.840866Z","iopub.execute_input":"2022-03-09T17:03:32.841376Z","iopub.status.idle":"2022-03-09T17:03:32.854113Z","shell.execute_reply.started":"2022-03-09T17:03:32.841336Z","shell.execute_reply":"2022-03-09T17:03:32.853353Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# [👔👕👖H & M Fashion Recommendation Analysis👚👗🥻](#0)\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:03:32.85553Z","iopub.execute_input":"2022-03-09T17:03:32.855949Z","iopub.status.idle":"2022-03-09T17:03:32.864587Z","shell.execute_reply.started":"2022-03-09T17:03:32.855899Z","shell.execute_reply":"2022-03-09T17:03:32.863882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/H%26M-Logo.svg/330px-H%26M-Logo.svg.png)\n\n\n\n### Hennes & Mauritz AB (H&M) is a Swedish multinational clothing company headquartered in Stockholm. It is known for its fast-fashion clothing for men, women, teenagers, and children. As of November 2019, H&M operates in 74 countries with over 5,000 stores under the various company brands, with 126,000 full-time equivalent positions. It is the second-largest global clothing retailer, behind Spain-based Inditex (parent company of Zara). Founded by Erling Persson and run by his son Stefan Persson and Helena Helmersson, the company makes its online shopping available in 33 countries\n\n#### Source : Wikipedia (https://en.wikipedia.org/wiki/H%26M)\n\n![](https://upload.wikimedia.org/wikipedia/commons/1/1e/H%26mPavilions.jpg)\n","metadata":{}},{"cell_type":"markdown","source":" *  Task-1 Dataset Load  \n *  Task-2 Data Visualization Charts  \n *  Task-3 Statistical Analysis and Inference  \n *  Task-4 Forecasting and Recommendations","metadata":{}},{"cell_type":"markdown","source":"<a id=1><h3 >1️⃣ Dataset Loading<br></h3></a>\n<a id=2><h3 >2️⃣ Dataset Visualization Using Simple Plots<br></h3></a>\n<a id=3><h3 >3️⃣ Let us do a bit of forecasting using Facebook Prophet Regression<br></h3></a>\n<a id=4><h3 >4️⃣ Stock Analysis of the data<br></h3></a>\n<a id=5><h3 >5️⃣ Let us do Summarize <br></h3></a>\n","metadata":{}},{"cell_type":"markdown","source":"# [1️⃣. Dataset Loading](#1)\n>","metadata":{}},{"cell_type":"code","source":"FILE_PATH = '../input/h-and-m-personalized-fashion-recommendations/'\narticles = pd.read_csv(FILE_PATH + \"articles.csv\")\ncustomers = pd.read_csv(FILE_PATH + \"customers.csv\")\ntransactions = pd.read_csv(FILE_PATH + \"transactions_train.csv\")\nimages_dir = FILE_PATH + \"/images\"\ncat_images = [f for f in listdir(images_dir)]","metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-09T17:03:32.865979Z","iopub.execute_input":"2022-03-09T17:03:32.866357Z","iopub.status.idle":"2022-03-09T17:04:21.897221Z","shell.execute_reply.started":"2022-03-09T17:03:32.86632Z","shell.execute_reply":"2022-03-09T17:04:21.893325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Number of observations in ARTICLES dataset: {colored(articles.shape, 'red')}\")\nprint(f\"Number of observations in CUSTOMERS dataset: {colored(customers.shape, 'green')}\")\nprint(f\"Number of observations in TRANSACTIONS dataset: {colored(transactions.shape, 'blue')}\")","metadata":{"_kg_hide-input":true,"_kg_hide-output":false,"execution":{"iopub.status.busy":"2022-03-09T17:04:21.903486Z","iopub.execute_input":"2022-03-09T17:04:21.904002Z","iopub.status.idle":"2022-03-09T17:04:21.91251Z","shell.execute_reply.started":"2022-03-09T17:04:21.903961Z","shell.execute_reply":"2022-03-09T17:04:21.911824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(colored(articles.columns, 'yellow'))\nprint(colored(customers.columns, 'green'))\nprint(colored(transactions.columns, 'blue'))","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:21.91374Z","iopub.execute_input":"2022-03-09T17:04:21.914469Z","iopub.status.idle":"2022-03-09T17:04:21.926266Z","shell.execute_reply.started":"2022-03-09T17:04:21.914422Z","shell.execute_reply":"2022-03-09T17:04:21.925525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# [2️⃣. Dataset Visualization Using Simple Plots](#2)\n\n\n## Initial simple plots using \n* *Plotly*\n","metadata":{}},{"cell_type":"code","source":"fig = px.histogram(articles, x = 'product_type_name', width = 800,height = 500,title = 'Product Type Distribution')\nfig.show()\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:21.928247Z","iopub.execute_input":"2022-03-09T17:04:21.92972Z","iopub.status.idle":"2022-03-09T17:04:22.719152Z","shell.execute_reply.started":"2022-03-09T17:04:21.92969Z","shell.execute_reply":"2022-03-09T17:04:22.718521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.histogram(customers, x = 'age', width = 800,height = 500,title = 'Customer Age Type Distribution')\nfig.show()\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:22.720283Z","iopub.execute_input":"2022-03-09T17:04:22.72064Z","iopub.status.idle":"2022-03-09T17:04:28.860018Z","shell.execute_reply.started":"2022-03-09T17:04:22.720595Z","shell.execute_reply":"2022-03-09T17:04:28.859304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#new_articles = articles['product_type_name'].value_counts()\n#.rename_axis('product_type_name').reset_index(name='product_type_name')\nfig = px.bar(articles.groupby(['product_type_name']).count().sort_values('prod_name',ascending=False),x='prod_name',color ='prod_name',\n             width = 800,height = 2000,title = 'product_type_name Age wise Distribution')\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:28.861273Z","iopub.execute_input":"2022-03-09T17:04:28.862069Z","iopub.status.idle":"2022-03-09T17:04:29.204221Z","shell.execute_reply.started":"2022-03-09T17:04:28.862027Z","shell.execute_reply":"2022-03-09T17:04:29.202945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.bar(customers.groupby(['age']).count().sort_values('club_member_status',ascending=False),x='club_member_status',color ='club_member_status',\n             width = 800,height = 1000,title = 'Customer Age wise Distribution')\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:29.206093Z","iopub.execute_input":"2022-03-09T17:04:29.20737Z","iopub.status.idle":"2022-03-09T17:04:29.933347Z","shell.execute_reply.started":"2022-03-09T17:04:29.207291Z","shell.execute_reply":"2022-03-09T17:04:29.932684Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# source code credit - @Yamqwe - https://www.kaggle.com/yamqwe/the-big-mac-index-eda \nCMAP = 'Accent'","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:29.934401Z","iopub.execute_input":"2022-03-09T17:04:29.93479Z","iopub.status.idle":"2022-03-09T17:04:29.939298Z","shell.execute_reply.started":"2022-03-09T17:04:29.934753Z","shell.execute_reply":"2022-03-09T17:04:29.9385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set_context(\"poster\", font_scale = 0.6,rc = {\"grid.linewidth\": 0.4})\nsns.set_style({'font.family':'serif'})\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:29.940818Z","iopub.execute_input":"2022-03-09T17:04:29.94107Z","iopub.status.idle":"2022-03-09T17:04:29.949984Z","shell.execute_reply.started":"2022-03-09T17:04:29.941033Z","shell.execute_reply":"2022-03-09T17:04:29.949255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# source code credit - @Yamqwe - https://www.kaggle.com/yamqwe/the-big-mac-index-eda \ndef hist(col, title):\n    plt.figure(figsize = (20, 8))\n    ax = sns.distplot(col,kde=False);\n    values = np.array([patch.get_height() for patch in ax.patches])\n    norm = plt.Normalize(values.min(), values.max())\n    colors = plt.cm.rainbow(norm(values))\n    for patch, color in zip(ax.patches, colors): patch.set_color(color)\n    plt.title(title, size = 20, color = custom_colors[0])\n    sns.set_style(\"whitegrid\")\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:29.95102Z","iopub.execute_input":"2022-03-09T17:04:29.951582Z","iopub.status.idle":"2022-03-09T17:04:29.960907Z","shell.execute_reply.started":"2022-03-09T17:04:29.951545Z","shell.execute_reply":"2022-03-09T17:04:29.960148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# source code credit - @Yamqwe - https://www.kaggle.com/yamqwe/the-big-mac-index-eda \ndef triple_plot(x, title,c):\n    fig, ax = plt.subplots(3,1,figsize=(20, 8),sharex=True)\n    sns.distplot(x, ax=ax[0],color=c)\n    ax[0].set(xlabel=None)\n    ax[0].set_title('Histogram + KDE')\n    sns.boxplot(x, ax=ax[1],color=c)\n    ax[1].set(xlabel=None)\n    ax[1].set_title('Boxplot')\n    sns.violinplot(x, ax=ax[2],color=c)\n    ax[2].set(xlabel=None)\n    ax[2].set_title('Violin plot')\n    #     fig.suptitle(title, fontsize=16)\n    plt.tight_layout(pad=3.0)\n    plt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:29.966659Z","iopub.execute_input":"2022-03-09T17:04:29.967064Z","iopub.status.idle":"2022-03-09T17:04:29.976942Z","shell.execute_reply.started":"2022-03-09T17:04:29.967031Z","shell.execute_reply":"2022-03-09T17:04:29.97624Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles.corr().style.background_gradient(cmap = CMAP)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:29.978482Z","iopub.execute_input":"2022-03-09T17:04:29.978678Z","iopub.status.idle":"2022-03-09T17:04:30.052201Z","shell.execute_reply.started":"2022-03-09T17:04:29.978646Z","shell.execute_reply":"2022-03-09T17:04:30.05157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CMAP = 'Spectral'\ncustomers.corr().style.background_gradient(cmap = CMAP)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:30.053248Z","iopub.execute_input":"2022-03-09T17:04:30.053835Z","iopub.status.idle":"2022-03-09T17:04:30.138981Z","shell.execute_reply.started":"2022-03-09T17:04:30.053799Z","shell.execute_reply":"2022-03-09T17:04:30.138074Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CMAP='prism'\ntransactions.corr().style.background_gradient(cmap = CMAP)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:30.140524Z","iopub.execute_input":"2022-03-09T17:04:30.140804Z","iopub.status.idle":"2022-03-09T17:04:31.504096Z","shell.execute_reply.started":"2022-03-09T17:04:30.140768Z","shell.execute_reply":"2022-03-09T17:04:31.50342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CMAP='rainbow'\nplt.figure(figsize=(16,16),dpi=80)\nfor x in range(2):\n    if x == 0 :\n        corr = articles.corr()\n    elif x == 1:\n        corr = transactions.corr()\n        \n    mask = np.triu(np.ones_like(corr, dtype=bool))\n    sns.heatmap(corr, mask=mask, cmap = CMAP, robust=True, center=0, square=True, linewidths=.5)\n    plt.title('Correlation', fontsize=15)\n    plt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:31.505516Z","iopub.execute_input":"2022-03-09T17:04:31.50604Z","iopub.status.idle":"2022-03-09T17:04:33.596187Z","shell.execute_reply.started":"2022-03-09T17:04:31.506001Z","shell.execute_reply":"2022-03-09T17:04:33.595501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"color_maps = {i: color_maps[i] for i in color_maps if i not in ['clouds', 'silver', 'concrete', 'asbestos', 'wet asphalt', 'midnight blue', 'wet']}","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:33.597733Z","iopub.execute_input":"2022-03-09T17:04:33.598239Z","iopub.status.idle":"2022-03-09T17:04:33.602805Z","shell.execute_reply.started":"2022-03-09T17:04:33.5982Z","shell.execute_reply":"2022-03-09T17:04:33.601974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# source code credit - @Yamqwe - https://www.kaggle.com/yamqwe/the-big-mac-index-eda \nimport random\ncategs = [i for i in articles.columns if len(articles[i].unique()) < 10 or i in articles.select_dtypes(exclude='number').columns]\nfor col in [i for i in articles.columns if i not in categs]: \n    hist(articles[col], 'Distribution of ' + col)    \n    triple_plot(articles[col],'Distribution ' + col, random.choice(list(color_maps.values()))[4])","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:33.604351Z","iopub.execute_input":"2022-03-09T17:04:33.604884Z","iopub.status.idle":"2022-03-09T17:04:47.869982Z","shell.execute_reply.started":"2022-03-09T17:04:33.604845Z","shell.execute_reply":"2022-03-09T17:04:47.869268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import random\ncategs = [i for i in customers.columns if len(customers[i].unique()) < 10 or i in customers.select_dtypes(exclude='number').columns]\nfor col in [i for i in customers.columns if i not in categs]: \n    hist(customers[col], 'Distribution of ' + col)    \n    triple_plot(customers[col],'Distribution ' + col, random.choice(list(color_maps.values()))[4])","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:47.871045Z","iopub.execute_input":"2022-03-09T17:04:47.871417Z","iopub.status.idle":"2022-03-09T17:04:57.313828Z","shell.execute_reply.started":"2022-03-09T17:04:47.871378Z","shell.execute_reply":"2022-03-09T17:04:57.313016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import random\ncategs = [i for i in transactions.columns if len(transactions[i].unique()) < 10 or i in transactions.select_dtypes(exclude='number').columns]\nfor col in [i for i in transactions.columns if i not in categs]: \n    hist(transactions[col], 'Distribution of ' + col)    \n    triple_plot(transactions[col],'Distribution ' + col, random.choice(list(color_maps.values()))[4])","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:04:57.31514Z","iopub.execute_input":"2022-03-09T17:04:57.315464Z","iopub.status.idle":"2022-03-09T17:10:29.406876Z","shell.execute_reply.started":"2022-03-09T17:04:57.31542Z","shell.execute_reply":"2022-03-09T17:10:29.406148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,16),dpi=80)\ncorr = articles.corr()\nmask = np.triu(np.ones_like(corr, dtype=bool))\nsns.heatmap(corr, mask=mask, cmap = CMAP, robust=True, center=0, square=True, linewidths=.5)\nplt.title('Correlation', fontsize=15)\nplt.show()\n\nplt.figure(figsize=(16,16),dpi=80)\ncorr = articles.corr()\nmask = np.triu(np.ones_like(corr, dtype=bool))\nsns.heatmap(corr, mask=mask, cmap = CMAP, robust=True, center=0, square=True, linewidths=.5)\nplt.title('Correlation', fontsize=15)\nplt.show()\n\n\ndata = articles.groupby(by=\"article_id\")[[\"article_id\",\"product_code\",\"prod_name\", \"product_group_name\", \"department_no\", \"garment_group_no\"]].first().reset_index(drop=True)\n\n# Figure\nf, (ax1, ax2, ax3,ax4) = plt.subplots(1, 4, figsize = (20, 12))\n\na = sns.distplot(data[\"article_id\"], ax=ax1, color=custom_colors[1], hist=False, kde_kws=dict(lw=6, ls=\"--\"))\nb = sns.distplot(data[\"product_code\"], ax=ax2)\nc = sns.distplot(data[\"department_no\"], ax=ax3)\nd = sns.distplot(data[\"garment_group_no\"], ax=ax4)\n\na.set_title(\"article_id Distribution\", fontsize=16)\nb.set_title(\"product_code Distribution\", fontsize=16)\nc.set_title(\"department_no Distribution\", fontsize=16)\nd.set_title(\"garment_group_no Distribution\", fontsize=16)\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:10:29.408215Z","iopub.execute_input":"2022-03-09T17:10:29.408585Z","iopub.status.idle":"2022-03-09T17:10:32.992188Z","shell.execute_reply.started":"2022-03-09T17:10:29.408547Z","shell.execute_reply":"2022-03-09T17:10:32.991478Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_bar(df, columntocheck, columntocount):\n    long_df = pd.DataFrame(df.groupby(columntocheck)[columntocount].count().reset_index().rename({columntocount: 'count'}, axis=1))\n    fig = px.bar(long_df, x=columntocheck, y=\"count\", color=columntocheck, title=f\"bar plot for {columntocheck} \")\n    fig.show()\n    del long_df\n    \ndef plot_hist(df, column):\n    fig = px.histogram(df, x=column, nbins=10, title=f'{column} distribution ')\n    fig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-09T17:10:32.993378Z","iopub.execute_input":"2022-03-09T17:10:32.99408Z","iopub.status.idle":"2022-03-09T17:10:33.001654Z","shell.execute_reply.started":"2022-03-09T17:10:32.994042Z","shell.execute_reply":"2022-03-09T17:10:33.000965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-09T17:10:33.002831Z","iopub.execute_input":"2022-03-09T17:10:33.003589Z","iopub.status.idle":"2022-03-09T17:10:33.015166Z","shell.execute_reply.started":"2022-03-09T17:10:33.003551Z","shell.execute_reply":"2022-03-09T17:10:33.014508Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ncustomer_cols_to_check = [ 'FN', 'Active', 'club_member_status','fashion_news_frequency', 'age']\nfor x in customer_cols_to_check:\n    plot_bar(customers,x,'customer_id')\n    plot_hist(customers,x)\n#plot_hist(customers,'customer_id')\n","metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-09T17:10:33.016265Z","iopub.execute_input":"2022-03-09T17:10:33.016521Z","iopub.status.idle":"2022-03-09T17:11:15.206031Z","shell.execute_reply.started":"2022-03-09T17:10:33.016487Z","shell.execute_reply":"2022-03-09T17:11:15.204643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f, ax = plt.subplots(figsize=(15, 7))\nax = sns.histplot(data=articles, y='index_name', color='purple')\nax.set_xlabel('count by index name')\nax.set_ylabel('index name')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:11:15.207192Z","iopub.execute_input":"2022-03-09T17:11:15.207468Z","iopub.status.idle":"2022-03-09T17:11:15.66418Z","shell.execute_reply.started":"2022-03-09T17:11:15.207417Z","shell.execute_reply":"2022-03-09T17:11:15.663504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f, ax = plt.subplots(figsize=(15, 7))\nax = sns.histplot(data=articles, y='garment_group_name', color='orange', hue='index_group_name', multiple=\"stack\")\nax.set_xlabel('count by garment group')\nax.set_ylabel('garment group')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:11:15.666412Z","iopub.execute_input":"2022-03-09T17:11:15.666887Z","iopub.status.idle":"2022-03-09T17:11:16.527151Z","shell.execute_reply.started":"2022-03-09T17:11:15.666846Z","shell.execute_reply":"2022-03-09T17:11:16.526474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles_for_merge = articles[['article_id', 'prod_name', 'product_type_name', 'product_group_name', 'index_name']]\narticles_for_merge = transactions[['customer_id', 'article_id', 'price', 't_dat']].merge(articles_for_merge, on='article_id', how='left')","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:11:16.528424Z","iopub.execute_input":"2022-03-09T17:11:16.529111Z","iopub.status.idle":"2022-03-09T17:11:26.091643Z","shell.execute_reply.started":"2022-03-09T17:11:16.529081Z","shell.execute_reply":"2022-03-09T17:11:26.090844Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set_style(\"darkgrid\")\nf, ax = plt.subplots(figsize=(25,18))\n_ = articles_for_merge[articles_for_merge['product_group_name'] == 'Accessories']\nax = sns.boxplot(data=_, x='price', y='product_type_name')\nax.set_xlabel('Price outliers', fontsize=22)\nax.set_ylabel('Index names', fontsize=22)\nax.xaxis.set_tick_params(labelsize=22)\nax.yaxis.set_tick_params(labelsize=22)\ndel _\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:11:26.092974Z","iopub.execute_input":"2022-03-09T17:11:26.093233Z","iopub.status.idle":"2022-03-09T17:11:52.193179Z","shell.execute_reply.started":"2022-03-09T17:11:26.093198Z","shell.execute_reply":"2022-03-09T17:11:52.192482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles_index = articles_for_merge[['product_group_name', 'price']].groupby('product_group_name').mean()\nsns.set_style(\"darkgrid\")\nf, ax = plt.subplots(figsize=(10,5))\nax = sns.barplot(x=articles_index.price, y=articles_index.index, color='green', alpha=0.8)\nax.set_xlabel('Price by product group')\nax.set_ylabel('Product group')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:11:52.194265Z","iopub.execute_input":"2022-03-09T17:11:52.194861Z","iopub.status.idle":"2022-03-09T17:11:55.852727Z","shell.execute_reply.started":"2022-03-09T17:11:52.194821Z","shell.execute_reply":"2022-03-09T17:11:55.85202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles_index = articles_for_merge[['index_name', 'price']].groupby('index_name').mean()\nsns.set_style(\"darkgrid\")\nf, ax = plt.subplots(figsize=(10,5))\nax = sns.barplot(x=articles_index.price, y=articles_index.index, color='orange', alpha=0.8)\nax.set_xlabel('Price by index')\nax.set_ylabel('Index')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:11:55.853761Z","iopub.execute_input":"2022-03-09T17:11:55.854134Z","iopub.status.idle":"2022-03-09T17:11:59.696184Z","shell.execute_reply.started":"2022-03-09T17:11:55.854096Z","shell.execute_reply":"2022-03-09T17:11:59.695483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"temp = articles.groupby([\"product_group_name\"])[\"product_type_name\"].nunique()\ndf = pd.DataFrame({'Product Group': temp.index,\n                   'Product Types': temp.values\n                  })\ndf = df.sort_values(['Product Types'], ascending=False)\nplt.figure(figsize = (8,6))\nplt.title('Number of Product Types per each Product Group')\nsns.set_color_codes(\"pastel\")\ns = sns.barplot(x = 'Product Group', y=\"Product Types\", data=df)\ns.set_xticklabels(s.get_xticklabels(),rotation=90)\nlocs, labels = plt.xticks()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:11:59.697409Z","iopub.execute_input":"2022-03-09T17:11:59.70009Z","iopub.status.idle":"2022-03-09T17:12:00.059119Z","shell.execute_reply.started":"2022-03-09T17:11:59.70005Z","shell.execute_reply":"2022-03-09T17:12:00.058477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"temp = articles.groupby([\"product_group_name\"])[\"article_id\"].nunique()\ndf = pd.DataFrame({'Product Group': temp.index,\n                   'Articles': temp.values\n                  })\ndf = df.sort_values(['Articles'], ascending=False)\nplt.figure(figsize = (8,6))\nplt.title('Number of Articles per each Product Group')\nsns.set_color_codes(\"pastel\")\ns = sns.barplot(x = 'Product Group', y=\"Articles\", data=df)\ns.set_xticklabels(s.get_xticklabels(),rotation=90)\nlocs, labels = plt.xticks()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:12:00.060295Z","iopub.execute_input":"2022-03-09T17:12:00.061099Z","iopub.status.idle":"2022-03-09T17:12:00.417122Z","shell.execute_reply.started":"2022-03-09T17:12:00.06106Z","shell.execute_reply":"2022-03-09T17:12:00.416466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2022-03-09T17:12:00.4183Z","iopub.execute_input":"2022-03-09T17:12:00.418894Z","iopub.status.idle":"2022-03-09T17:12:05.657563Z","shell.execute_reply.started":"2022-03-09T17:12:00.418856Z","shell.execute_reply":"2022-03-09T17:12:05.656473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#  <span class=\"title-section w3-xxlarge\" style=\"color:#FF0080\"> Credits </span>\n\n###  <span class=\"title-section w3-large\" style=\"color:#FF0080\"> Multiple inputs and inspirations by many kagglers. Fully curated list is getting updated</span>","metadata":{}},{"cell_type":"markdown","source":"##  <span class=\"title-section w3-xlarge\" style=\"color:#FF0080\"> Work In Progress</span>","metadata":{}}]}