{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport plotly.express as px\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\nimport matplotlib.pyplot as plt\nimport os\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\npd.options.display.float_format = '{:.4f}'.format\n\ndef get_row(n_total, n_cols) :\n    if n_total % n_cols == 0 :\n        n_rows = n_total / n_cols\n    else :\n        n_rows = (n_total // n_cols) + 1\n    return int(n_rows)\ndef visualize_articles(articles , article_list, n_total , n_cols , figsize=(25,10)) :\n    n_rows = get_row(n_total , n_cols)\n    f, ax = plt.subplots(n_rows, n_cols, figsize=figsize)\n    axes = ax.flatten()\n    i = 0\n    for article in article_list:\n        visualize_article(axes , i , articles , article)\n        i += 1\n    else :\n        plt.show()\n\n\ndef visualize_article(axes,i, articles , article) :\n    desc = articles[articles['article_id'] == article]['detail_desc'].iloc[0]\n    desc_list = desc.split(' ')\n    for j, elem in enumerate(desc_list):\n        if j > 0 and j % 5 == 0:\n            desc_list[j] = desc_list[j] + '\\n'\n    desc = ' '.join(desc_list)\n    try :\n        img = mpimg.imread(f'../input/h-and-m-personalized-fashion-recommendations/images/0{str(article)[:2]}/0{int(article)}.jpg')\n        axes[i].imshow(img)\n    except :\n        pass\n    axes[i].set_xticks([], [])\n    axes[i].set_yticks([], [])\n    axes[i].set_title(article)\n    axes[i].grid(False)\n    axes[i].set_xlabel(desc, fontsize=10)\n    \n    \n    \n\ndef check_count(a,b,a_name=\"\" , b_name=\"\") :\n    itersection_set = set(a) & set(b)\n    a_uni_set = set(a).difference(set(b))\n    b_uni_set = set(b).difference(set(a))\n    print(\"=\"*20)\n    print(a_name , len(a))\n    print(b_name , len(b))\n    print(a_name , \"unique_set\" , len(a_uni_set))\n    print(b_name , \"unique_set\" , len(b_uni_set))\n    print(\"intersection\" , len(itersection_set))\n    print(\"=\"*20)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-08T14:03:08.13809Z","iopub.execute_input":"2022-03-08T14:03:08.138361Z","iopub.status.idle":"2022-03-08T14:03:08.152883Z","shell.execute_reply.started":"2022-03-08T14:03:08.138334Z","shell.execute_reply":"2022-03-08T14:03:08.152058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_submission_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/sample_submission.csv\"\ndata_article_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/articles.csv\"\ndata_transaction_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\"\ndata_customer_path = \"/kaggle/input/h-and-m-personalized-fashion-recommendations/customers.csv\"","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:03:08.330668Z","iopub.execute_input":"2022-03-08T14:03:08.330941Z","iopub.status.idle":"2022-03-08T14:03:08.335063Z","shell.execute_reply.started":"2022-03-08T14:03:08.330912Z","shell.execute_reply":"2022-03-08T14:03:08.334168Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_customer_path,nrows=1)\nprint(d.T)","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:03:08.553654Z","iopub.execute_input":"2022-03-08T14:03:08.553926Z","iopub.status.idle":"2022-03-08T14:03:08.567994Z","shell.execute_reply.started":"2022-03-08T14:03:08.553871Z","shell.execute_reply":"2022-03-08T14:03:08.567161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_transaction_path,nrows=1)\nprint(d.T)","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:03:10.09579Z","iopub.execute_input":"2022-03-08T14:03:10.096697Z","iopub.status.idle":"2022-03-08T14:03:10.110945Z","shell.execute_reply.started":"2022-03-08T14:03:10.096646Z","shell.execute_reply":"2022-03-08T14:03:10.110169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,nrows=1)\nprint(d.T)","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:03:11.102139Z","iopub.execute_input":"2022-03-08T14:03:11.102436Z","iopub.status.idle":"2022-03-08T14:03:11.118581Z","shell.execute_reply.started":"2022-03-08T14:03:11.102406Z","shell.execute_reply":"2022-03-08T14:03:11.117881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submission","metadata":{}},{"cell_type":"code","source":"customers_submission = pd.read_csv(data_submission_path,usecols =[ \"customer_id\"])\ncustomers_transaction = pd.read_csv(data_transaction_path,usecols =[ \"customer_id\"])\ncustomers_database = pd.read_csv(data_customer_path,usecols =[ \"customer_id\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:03:12.826985Z","iopub.execute_input":"2022-03-08T14:03:12.827281Z","iopub.status.idle":"2022-03-08T14:04:20.913937Z","shell.execute_reply.started":"2022-03-08T14:03:12.82724Z","shell.execute_reply":"2022-03-08T14:04:20.91272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers_submision_uni = np.unique(customers_submission.values)\ncustomers_transaction_uni = np.unique(customers_transaction.values)\ncustomers_database_uni = np.unique(customers_database.values)","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:04:20.916271Z","iopub.execute_input":"2022-03-08T14:04:20.916518Z","iopub.status.idle":"2022-03-08T14:04:59.536403Z","shell.execute_reply.started":"2022-03-08T14:04:20.916491Z","shell.execute_reply":"2022-03-08T14:04:59.535504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"check submission\n\n* The transaction table does not contain all of the customer IDs in the submission table.\n\n**In my opinion, a different approach is needed for customers who are not included.**","metadata":{}},{"cell_type":"code","source":"check_count(customers_submision_uni,customers_transaction_uni,\"submission\",\"transaction\")\ncheck_count(customers_submision_uni,customers_database_uni,\"submission\",\"database\")\ncheck_count(customers_transaction_uni,customers_database_uni,\"transaction\",\"database\")","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:04:59.538067Z","iopub.execute_input":"2022-03-08T14:04:59.5384Z","iopub.status.idle":"2022-03-08T14:05:08.887181Z","shell.execute_reply.started":"2022-03-08T14:04:59.538359Z","shell.execute_reply":"2022-03-08T14:05:08.886271Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"special_custmer_2 = list(set(customers_submision_uni).difference(set(customers_transaction_uni)))","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:07:01.985245Z","iopub.execute_input":"2022-03-08T14:07:01.985518Z","iopub.status.idle":"2022-03-08T14:07:02.975891Z","shell.execute_reply.started":"2022-03-08T14:07:01.985489Z","shell.execute_reply":"2022-03-08T14:07:02.975093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Customer","metadata":{}},{"cell_type":"code","source":"customer = pd.read_csv(data_customer_path,usecols = ['customer_id'])\ncustomer.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:08:38.743078Z","iopub.execute_input":"2022-03-08T14:08:38.743658Z","iopub.status.idle":"2022-03-08T14:08:41.499772Z","shell.execute_reply.started":"2022-03-08T14:08:38.74362Z","shell.execute_reply":"2022-03-08T14:08:41.498911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer = pd.read_csv(data_customer_path,usecols = ['customer_id','age','club_member_status',\"Active\"])\npd.DataFrame(customer['age'].describe()).T","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:18.915801Z","iopub.execute_input":"2022-03-08T14:10:18.916644Z","iopub.status.idle":"2022-03-08T14:10:21.331878Z","shell.execute_reply.started":"2022-03-08T14:10:18.916597Z","shell.execute_reply":"2022-03-08T14:10:21.331342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for bins in np.arange(50,100,10) :\n    customer[\"age\"].plot.hist(bins=bins,density =True,alpha=0.2)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:21.33364Z","iopub.execute_input":"2022-03-08T14:10:21.333925Z","iopub.status.idle":"2022-03-08T14:10:22.873368Z","shell.execute_reply.started":"2022-03-08T14:10:21.333873Z","shell.execute_reply":"2022-03-08T14:10:22.87136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Age Binning","metadata":{}},{"cell_type":"code","source":"labels = [\"10\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\",\"100\"]\nlabels_number = [int(label) for label in labels]\nlabels = [f\"{label}'s\" for label in labels]\nd = pd.cut(customer[\"age\"],labels_number,include_lowest=True, right=False, labels=labels[:-1])\ncustomer[\"age_binned\"] = pd.Categorical(d , categories=labels[:-1], ordered=True)","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:22.875355Z","iopub.execute_input":"2022-03-08T14:10:22.875763Z","iopub.status.idle":"2022-03-08T14:10:22.928531Z","shell.execute_reply.started":"2022-03-08T14:10:22.875717Z","shell.execute_reply":"2022-03-08T14:10:22.927771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer[\"age_binned\"].value_counts(sort=False)","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:22.929746Z","iopub.execute_input":"2022-03-08T14:10:22.930587Z","iopub.status.idle":"2022-03-08T14:10:22.946828Z","shell.execute_reply.started":"2022-03-08T14:10:22.93054Z","shell.execute_reply":"2022-03-08T14:10:22.945938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer[\"age_binned\"].value_counts(sort=False).plot.barh()","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:22.94844Z","iopub.execute_input":"2022-03-08T14:10:22.948725Z","iopub.status.idle":"2022-03-08T14:10:23.320086Z","shell.execute_reply.started":"2022-03-08T14:10:22.948696Z","shell.execute_reply":"2022-03-08T14:10:23.31927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer.query(\"age != age\").shape","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:23.527002Z","iopub.execute_input":"2022-03-08T14:10:23.527864Z","iopub.status.idle":"2022-03-08T14:10:23.549037Z","shell.execute_reply.started":"2022-03-08T14:10:23.527806Z","shell.execute_reply":"2022-03-08T14:10:23.548242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"special_age_list = [\"90's\",\"80's\"]\nspecial_customer_list = customer.query(\"age_binned in @special_age_list\")['customer_id'].values.tolist()","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:24.278436Z","iopub.execute_input":"2022-03-08T14:10:24.27888Z","iopub.status.idle":"2022-03-08T14:10:24.292982Z","shell.execute_reply.started":"2022-03-08T14:10:24.278835Z","shell.execute_reply":"2022-03-08T14:10:24.292429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_binned = customer","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:24.752143Z","iopub.execute_input":"2022-03-08T14:10:24.752567Z","iopub.status.idle":"2022-03-08T14:10:24.755429Z","shell.execute_reply.started":"2022-03-08T14:10:24.752526Z","shell.execute_reply":"2022-03-08T14:10:24.754849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer.groupby([\"age_binned\",\"club_member_status\"]).size()","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:25.515043Z","iopub.execute_input":"2022-03-08T14:10:25.515792Z","iopub.status.idle":"2022-03-08T14:10:25.65555Z","shell.execute_reply.started":"2022-03-08T14:10:25.51575Z","shell.execute_reply":"2022-03-08T14:10:25.654644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"summary = customer.groupby([\"age_binned\",\"club_member_status\"]).agg({\"club_member_status\" : [\"count\"]}).reset_index(drop=False)\nnew_cols = [\"_\".join(i) if i[1] != \"\" else i[0] for i in list(summary)]\nsummary.columns = new_cols","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:26.03764Z","iopub.execute_input":"2022-03-08T14:10:26.037921Z","iopub.status.idle":"2022-03-08T14:10:26.23235Z","shell.execute_reply.started":"2022-03-08T14:10:26.037891Z","shell.execute_reply":"2022-03-08T14:10:26.231552Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## TreeMap (Age Binned , club_member_status)","metadata":{}},{"cell_type":"code","source":"fig = px.treemap(summary, path=['age_binned', 'club_member_status'], values='club_member_status_count')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:10:27.140308Z","iopub.execute_input":"2022-03-08T14:10:27.140576Z","iopub.status.idle":"2022-03-08T14:10:27.219281Z","shell.execute_reply.started":"2022-03-08T14:10:27.140549Z","shell.execute_reply":"2022-03-08T14:10:27.218429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Special Customer (no transactions)\n\n* these customers does not have a transaction information.\n\n**Let's analyze these customers!**","metadata":{}},{"cell_type":"code","source":"check_customer = customer.query(\"customer_id in @special_custmer_2\")\ncheck_customer['Active'].fillna(0,inplace=True)\ntable = check_customer.Active.value_counts()\n\n\n\nfig, ax = plt.subplots(figsize=(5,5))\ncolors = sns.color_palette('Paired')\nax.pie(table, \n       labels=['Active 0(Non Active)',\"Active 1(Active)\"],\n       autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\nax.axis('equal')\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:12:43.95006Z","iopub.execute_input":"2022-03-08T14:12:43.950668Z","iopub.status.idle":"2022-03-08T14:12:44.231663Z","shell.execute_reply.started":"2022-03-08T14:12:43.950624Z","shell.execute_reply":"2022-03-08T14:12:44.230715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = check_customer.age_binned.value_counts()\n\nfig, ax = plt.subplots(figsize=(5,5))\ncolors = sns.color_palette('Paired')\nax.pie(table, \n       labels=table.index.tolist(),\n       autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\nax.axis('equal')\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:13:38.473567Z","iopub.execute_input":"2022-03-08T14:13:38.474424Z","iopub.status.idle":"2022-03-08T14:13:38.662112Z","shell.execute_reply.started":"2022-03-08T14:13:38.474382Z","shell.execute_reply":"2022-03-08T14:13:38.661375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"a = check_customer.groupby([\"age_binned\",\"Active\"]).size().reset_index()\na = a[a[0] > 0]","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:18:58.115148Z","iopub.execute_input":"2022-03-08T14:18:58.115968Z","iopub.status.idle":"2022-03-08T14:18:58.127992Z","shell.execute_reply.started":"2022-03-08T14:18:58.115921Z","shell.execute_reply":"2022-03-08T14:18:58.127279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_n = len(list(a.age_binned.unique()))\nn_cols = 4\nn_rows = get_row(total_n , n_cols)\nfigsize = (15,6)\nf, ax = plt.subplots(n_rows, n_cols, figsize=figsize)\naxes = ax.flatten()\ni = 0\nfor age_binned in list(a.age_binned.unique()) :\n    table = a[a.age_binned.str.contains(age_binned)].drop(\"age_binned\",axis=1).set_index(\"Active\")\n    table = pd.Series(table.values.squeeze(),index= table.index)\n    colors = sns.color_palette('Paired')\n    axes[i].pie(table, \n           labels=[f\"Active : {int(i)}\" for i in table.index.tolist()],\n           autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\n    axes[i].axis('equal')\n    axes[i].set_title(age_binned)\n    i += 1\nelse :\n    plt.show()\n\n","metadata":{"execution":{"iopub.status.busy":"2022-03-08T14:21:10.284287Z","iopub.execute_input":"2022-03-08T14:21:10.284607Z","iopub.status.idle":"2022-03-08T14:21:11.153872Z","shell.execute_reply.started":"2022-03-08T14:21:10.284576Z","shell.execute_reply":"2022-03-08T14:21:11.153058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Article","metadata":{}},{"cell_type":"code","source":"article = pd.read_csv(data_article_path,nrows=1)\narticle.T","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:56:52.334593Z","iopub.execute_input":"2022-03-07T08:56:52.33501Z","iopub.status.idle":"2022-03-07T08:56:52.383255Z","shell.execute_reply.started":"2022-03-07T08:56:52.33497Z","shell.execute_reply":"2022-03-07T08:56:52.382257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article = pd.read_csv(data_article_path,usecols = ['article_id'])\narticle.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:56:52.385537Z","iopub.execute_input":"2022-03-07T08:56:52.386015Z","iopub.status.idle":"2022-03-07T08:56:53.01192Z","shell.execute_reply.started":"2022-03-07T08:56:52.385972Z","shell.execute_reply":"2022-03-07T08:56:53.011004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"In the transaction table, the article does not contain about 995 pieces of information.","metadata":{}},{"cell_type":"code","source":"transaction_article = pd.read_csv(data_transaction_path, usecols=[\"article_id\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:56:53.012821Z","iopub.execute_input":"2022-03-07T08:56:53.013039Z","iopub.status.idle":"2022-03-07T08:57:37.106255Z","shell.execute_reply.started":"2022-03-07T08:56:53.013013Z","shell.execute_reply":"2022-03-07T08:57:37.105448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transaction_article_uni = np.unique(transaction_article.values)\narticle_uni = np.unique(article.values)\n\ncheck_count(transaction_article_uni,article_uni,\"transaction\",\"article\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:58:03.2368Z","iopub.execute_input":"2022-03-07T08:58:03.237078Z","iopub.status.idle":"2022-03-07T08:58:05.975661Z","shell.execute_reply.started":"2022-03-07T08:58:03.23705Z","shell.execute_reply":"2022-03-07T08:58:05.974696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"product_type_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(21,4), rot=90)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.756564Z","iopub.status.idle":"2022-03-07T08:57:39.756939Z","shell.execute_reply.started":"2022-03-07T08:57:39.756734Z","shell.execute_reply":"2022-03-07T08:57:39.756777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"graphical_appearance_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.758565Z","iopub.status.idle":"2022-03-07T08:57:39.758922Z","shell.execute_reply.started":"2022-03-07T08:57:39.758728Z","shell.execute_reply":"2022-03-07T08:57:39.758769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"colour_group_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.760067Z","iopub.status.idle":"2022-03-07T08:57:39.760381Z","shell.execute_reply.started":"2022-03-07T08:57:39.760218Z","shell.execute_reply":"2022-03-07T08:57:39.76024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"perceived_colour_value_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.761565Z","iopub.status.idle":"2022-03-07T08:57:39.761924Z","shell.execute_reply.started":"2022-03-07T08:57:39.761738Z","shell.execute_reply":"2022-03-07T08:57:39.761775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d = pd.read_csv(data_article_path,usecols=[\"index_name\"])\ntable = pd.Categorical(d.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(7,3), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T08:57:39.76308Z","iopub.status.idle":"2022-03-07T08:57:39.763396Z","shell.execute_reply.started":"2022-03-07T08:57:39.763232Z","shell.execute_reply":"2022-03-07T08:57:39.763255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path,usecols= [\"article_id\",\"section_name\"])\narticles.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:36:36.493831Z","iopub.execute_input":"2022-03-07T11:36:36.494516Z","iopub.status.idle":"2022-03-07T11:36:36.845739Z","shell.execute_reply.started":"2022-03-07T11:36:36.494469Z","shell.execute_reply":"2022-03-07T11:36:36.844763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from nltk.stem import WordNetLemmatizer\nwordnet_lemmatizer = WordNetLemmatizer()\ndef text_preprocessing(text):\n    text = text.replace(\" & \",\"&\")\n    text = text.replace(\",\",\"\")\n    text = text.lower()\n    text = text.replace(\"womens\",\"women\")\n    text = text.replace(\"mans\",\"man\")\n    text = text.replace(\" other 2\",\"\")\n    text = text.strip()\n    words = text.split(\" \")\n    lemm_text = [wordnet_lemmatizer.lemmatize(word) for word in words]\n    return lemm_text\narticles['section_name_split']=articles['section_name'].apply(lambda x:text_preprocessing(x))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:46:40.113419Z","iopub.execute_input":"2022-03-07T11:46:40.114183Z","iopub.status.idle":"2022-03-07T11:46:41.65493Z","shell.execute_reply.started":"2022-03-07T11:46:40.114149Z","shell.execute_reply":"2022-03-07T11:46:41.653852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles['section_name_split'].head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:46:42.280862Z","iopub.execute_input":"2022-03-07T11:46:42.281584Z","iopub.status.idle":"2022-03-07T11:46:42.289919Z","shell.execute_reply.started":"2022-03-07T11:46:42.281542Z","shell.execute_reply":"2022-03-07T11:46:42.288909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dd = articles['section_name_split'].values.tolist()\nunique_set = []\nfor d in dd :\n    unique_set.extend(d)\nelse :\n    keywords = list(np.unique(unique_set))\n    print(len(keywords))\n    print(keywords)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:47:24.327837Z","iopub.execute_input":"2022-03-07T11:47:24.328143Z","iopub.status.idle":"2022-03-07T11:47:24.512323Z","shell.execute_reply.started":"2022-03-07T11:47:24.328112Z","shell.execute_reply":"2022-03-07T11:47:24.511242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def find_keywords(keyword , x) :\n    return True if keyword in x else False\n## women cloth\n\ndef get_keyword_count(articles, keyword) :\n    sum_of_keyword = articles['section_name_split'].apply(lambda x : find_keywords(keyword, x)).sum()\n    return sum_of_keyword","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:54:42.004233Z","iopub.execute_input":"2022-03-07T11:54:42.004582Z","iopub.status.idle":"2022-03-07T11:54:42.011721Z","shell.execute_reply.started":"2022-03-07T11:54:42.004534Z","shell.execute_reply":"2022-03-07T11:54:42.010234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keyword_count_table= {}\nfor keyword in keywords :\n    keyword_count_table[keyword]= get_keyword_count(articles, keyword)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:55:24.402245Z","iopub.execute_input":"2022-03-07T11:55:24.402545Z","iopub.status.idle":"2022-03-07T11:55:26.81863Z","shell.execute_reply.started":"2022-03-07T11:55:24.402513Z","shell.execute_reply":"2022-03-07T11:55:26.817644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keyword_count_table= pd.Series(keyword_count_table).sort_values(ascending=False)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:56:42.228024Z","iopub.execute_input":"2022-03-07T11:56:42.228314Z","iopub.status.idle":"2022-03-07T11:56:42.234052Z","shell.execute_reply.started":"2022-03-07T11:56:42.228275Z","shell.execute_reply":"2022-03-07T11:56:42.233024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keyword_count_table.plot.bar(figsize=(17,5))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T11:56:58.730269Z","iopub.execute_input":"2022-03-07T11:56:58.730982Z","iopub.status.idle":"2022-03-07T11:56:59.632692Z","shell.execute_reply.started":"2022-03-07T11:56:58.730936Z","shell.execute_reply":"2022-03-07T11:56:59.631651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Transaction","metadata":{}},{"cell_type":"code","source":"data = pd.read_csv(data_transaction_path)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:06:58.131138Z","iopub.execute_input":"2022-03-07T13:06:58.131438Z","iopub.status.idle":"2022-03-07T13:07:37.557545Z","shell.execute_reply.started":"2022-03-07T13:06:58.131403Z","shell.execute_reply":"2022-03-07T13:07:37.556497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Channels","metadata":{}},{"cell_type":"code","source":"data['sales_channel_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:07:37.559445Z","iopub.execute_input":"2022-03-07T13:07:37.55975Z","iopub.status.idle":"2022-03-07T13:07:37.731484Z","shell.execute_reply.started":"2022-03-07T13:07:37.559715Z","shell.execute_reply":"2022-03-07T13:07:37.730495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.hist(np.log(data.query(\"sales_channel_id==1\")[\"price\"]),bins=60,color=\"b\",label=\"channel_id == 1\",alpha=0.3,density=True)\nplt.hist(np.log(data.query(\"sales_channel_id==2\")[\"price\"]),bins=60,color=\"r\",label=\"channel_id == 2\",alpha=0.3,density=True)\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:11.800495Z","iopub.execute_input":"2022-03-07T12:29:11.800814Z","iopub.status.idle":"2022-03-07T12:29:15.992686Z","shell.execute_reply.started":"2022-03-07T12:29:11.800779Z","shell.execute_reply":"2022-03-07T12:29:15.991611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Count Table Based on the Date(t_dat)","metadata":{}},{"cell_type":"code","source":"transaction_time = pd.to_datetime(data[\"t_dat\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:32.716895Z","iopub.execute_input":"2022-03-07T12:29:32.71721Z","iopub.status.idle":"2022-03-07T12:29:37.827718Z","shell.execute_reply.started":"2022-03-07T12:29:32.717177Z","shell.execute_reply":"2022-03-07T12:29:37.826731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = pd.Categorical(transaction_time.dt.year.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:19.563013Z","iopub.execute_input":"2022-03-07T03:01:19.563311Z","iopub.status.idle":"2022-03-07T03:01:23.119444Z","shell.execute_reply.started":"2022-03-07T03:01:19.563281Z","shell.execute_reply":"2022-03-07T03:01:23.118482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = pd.Categorical(transaction_time.dt.month.values.squeeze(),ordered=True).value_counts()\nprint(pd.DataFrame(table).T)\ntable.plot.bar(figsize=(16,4), rot=90)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:23.12089Z","iopub.execute_input":"2022-03-07T03:01:23.121089Z","iopub.status.idle":"2022-03-07T03:01:26.678979Z","shell.execute_reply.started":"2022-03-07T03:01:23.121064Z","shell.execute_reply":"2022-03-07T03:01:26.677989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[\"t_dat\"] = transaction_time","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:37.829455Z","iopub.execute_input":"2022-03-07T12:29:37.8297Z","iopub.status.idle":"2022-03-07T12:29:38.41169Z","shell.execute_reply.started":"2022-03-07T12:29:37.829668Z","shell.execute_reply":"2022-03-07T12:29:38.410714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.groupby(by=[data.t_dat.dt.month]).agg({\"price\" : [\"min\",\"max\",\"mean\",\"std\"]})","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:29.90889Z","iopub.execute_input":"2022-03-07T03:01:29.909342Z","iopub.status.idle":"2022-03-07T03:01:33.981926Z","shell.execute_reply.started":"2022-03-07T03:01:29.909296Z","shell.execute_reply":"2022-03-07T03:01:33.981022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.groupby(by=[data.t_dat.dt.year , data.t_dat.dt.month]).agg({\"price\" : [\"min\",\"max\",\"mean\",\"std\"]})","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:33.983213Z","iopub.execute_input":"2022-03-07T03:01:33.983414Z","iopub.status.idle":"2022-03-07T03:01:42.078092Z","shell.execute_reply.started":"2022-03-07T03:01:33.983391Z","shell.execute_reply":"2022-03-07T03:01:42.077013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = data.groupby(by=[data.t_dat.dt.year , data.t_dat.dt.month]).size()\ntable.index.names = [\"year\", \"month\"]","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:42.079318Z","iopub.execute_input":"2022-03-07T03:01:42.079659Z","iopub.status.idle":"2022-03-07T03:01:49.643917Z","shell.execute_reply.started":"2022-03-07T03:01:42.079622Z","shell.execute_reply":"2022-03-07T03:01:49.643023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = table.reset_index(drop=False).rename(columns={0:\"count\"})\ntable = table.sort_values(by=[\"year\",\"month\"])\ntable[\"year/month\"] = table.apply(lambda x : f'{x[\"year\"]:04d}/{x[\"month\"]:02d}',axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:49.646017Z","iopub.execute_input":"2022-03-07T03:01:49.646326Z","iopub.status.idle":"2022-03-07T03:01:49.66096Z","shell.execute_reply.started":"2022-03-07T03:01:49.646285Z","shell.execute_reply":"2022-03-07T03:01:49.659771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table.plot(x = \"year/month\",y=\"count\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:49.661993Z","iopub.execute_input":"2022-03-07T03:01:49.662198Z","iopub.status.idle":"2022-03-07T03:01:49.829679Z","shell.execute_reply.started":"2022-03-07T03:01:49.662173Z","shell.execute_reply":"2022-03-07T03:01:49.828932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.treemap(table, path=['year', 'month'], values='count')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:49.830821Z","iopub.execute_input":"2022-03-07T03:01:49.831148Z","iopub.status.idle":"2022-03-07T03:01:51.061497Z","shell.execute_reply.started":"2022-03-07T03:01:49.83112Z","shell.execute_reply":"2022-03-07T03:01:51.060583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = data.groupby(by=[data.t_dat.dt.dayofweek]).size()\ntable.index.names = [\"dayofweek\"]\ntable","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:13:22.567665Z","iopub.execute_input":"2022-03-07T03:13:22.568308Z","iopub.status.idle":"2022-03-07T03:13:26.368363Z","shell.execute_reply.started":"2022-03-07T03:13:22.568254Z","shell.execute_reply":"2022-03-07T03:13:26.367388Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(5,5))\ncolors = sns.color_palette('Paired')\nax.pie(table, \n       labels=['Mon','Tue',\"Wed\",\"Thr\",\"Fri\",\"Sat\",\"Sun\"],\n       autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\nax.axis('equal')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:13:27.041815Z","iopub.execute_input":"2022-03-07T03:13:27.042091Z","iopub.status.idle":"2022-03-07T03:13:27.216763Z","shell.execute_reply.started":"2022-03-07T03:13:27.04206Z","shell.execute_reply":"2022-03-07T03:13:27.215542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = table.reset_index(drop=False)\ntable[\"isholiday\"] = ['Weekdays','Weekdays','Weekdays','Weekdays','Weekdays','Holidays','Holidays']\ntable = table.groupby('isholiday').agg({0:\"sum\"})\ntable","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:13:29.54607Z","iopub.execute_input":"2022-03-07T03:13:29.546829Z","iopub.status.idle":"2022-03-07T03:13:29.562039Z","shell.execute_reply.started":"2022-03-07T03:13:29.546782Z","shell.execute_reply":"2022-03-07T03:13:29.561099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = pd.Series(table.values.squeeze(),index = table.index.values)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:43:58.063767Z","iopub.execute_input":"2022-03-07T03:43:58.064864Z","iopub.status.idle":"2022-03-07T03:43:58.070458Z","shell.execute_reply.started":"2022-03-07T03:43:58.064807Z","shell.execute_reply":"2022-03-07T03:43:58.069727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:44:15.163166Z","iopub.execute_input":"2022-03-07T03:44:15.163462Z","iopub.status.idle":"2022-03-07T03:44:15.169036Z","shell.execute_reply.started":"2022-03-07T03:44:15.163431Z","shell.execute_reply":"2022-03-07T03:44:15.168234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(5,5))\ncolors = sns.color_palette('Paired')\nax.pie(table, \n       labels=['Holidays',\"Weekdays\"],\n       autopct='%1.1f%%',shadow=True, startangle=90, colors=colors)\nax.axis('equal')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:44:28.887392Z","iopub.execute_input":"2022-03-07T03:44:28.887699Z","iopub.status.idle":"2022-03-07T03:44:28.999938Z","shell.execute_reply.started":"2022-03-07T03:44:28.887654Z","shell.execute_reply":"2022-03-07T03:44:28.998734Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:19.653585Z","iopub.execute_input":"2022-03-07T12:29:19.653921Z","iopub.status.idle":"2022-03-07T12:29:20.361763Z","shell.execute_reply.started":"2022-03-07T12:29:19.653877Z","shell.execute_reply":"2022-03-07T12:29:20.360594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top3_year_article_table = data.groupby([data.t_dat.dt.year]).apply(lambda x : x['article_id'].value_counts().head(3))\ntop3_year_article_table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:38.413529Z","iopub.execute_input":"2022-03-07T12:29:38.413982Z","iopub.status.idle":"2022-03-07T12:29:48.1187Z","shell.execute_reply.started":"2022-03-07T12:29:38.413945Z","shell.execute_reply":"2022-03-07T12:29:48.11763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = list(top3_year_article_table.reset_index()['level_1'].unique())\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 5 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:48.122011Z","iopub.execute_input":"2022-03-07T12:29:48.12263Z","iopub.status.idle":"2022-03-07T12:29:50.956184Z","shell.execute_reply.started":"2022-03-07T12:29:48.122578Z","shell.execute_reply":"2022-03-07T12:29:50.955431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top3_month_article_table =  data.groupby([data.t_dat.dt.month]).apply(lambda x : x['article_id'].value_counts().head(3))\ntop3_month_article_table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:29:52.716336Z","iopub.execute_input":"2022-03-07T12:29:52.717152Z","iopub.status.idle":"2022-03-07T12:30:00.485229Z","shell.execute_reply.started":"2022-03-07T12:29:52.717118Z","shell.execute_reply":"2022-03-07T12:30:00.484213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = list(top3_month_article_table.reset_index()['level_1'].unique())\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 7 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:59:10.948298Z","iopub.execute_input":"2022-03-07T03:59:10.948594Z","iopub.status.idle":"2022-03-07T03:59:16.710419Z","shell.execute_reply.started":"2022-03-07T03:59:10.948559Z","shell.execute_reply":"2022-03-07T03:59:16.709153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top3_dayofweek_article_table= data.groupby([data.t_dat.dt.dayofweek]).apply(lambda x : x['article_id'].value_counts().head(3))\ntop3_dayofweek_article_table","metadata":{"execution":{"iopub.status.busy":"2022-03-07T04:00:01.932621Z","iopub.execute_input":"2022-03-07T04:00:01.933599Z","iopub.status.idle":"2022-03-07T04:00:09.336898Z","shell.execute_reply.started":"2022-03-07T04:00:01.933549Z","shell.execute_reply":"2022-03-07T04:00:09.335957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = list(top3_dayofweek_article_table.reset_index()['level_1'].unique())\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 3 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T04:00:27.530769Z","iopub.execute_input":"2022-03-07T04:00:27.531052Z","iopub.status.idle":"2022-03-07T04:00:28.960619Z","shell.execute_reply.started":"2022-03-07T04:00:27.531025Z","shell.execute_reply":"2022-03-07T04:00:28.959805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_count_table= data.article_id.value_counts()\ntop10 = article_count_table.head(10)\ntop10_articles = top10.index.values.tolist()\n","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:49:05.036184Z","iopub.execute_input":"2022-03-07T03:49:05.036498Z","iopub.status.idle":"2022-03-07T03:49:06.784064Z","shell.execute_reply.started":"2022-03-07T03:49:05.036465Z","shell.execute_reply":"2022-03-07T03:49:06.783218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"visualize_articles(articles,top10_articles , n_total = len(top10_articles) , n_cols = 5 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:55:45.493282Z","iopub.execute_input":"2022-03-07T03:55:45.494047Z","iopub.status.idle":"2022-03-07T03:55:48.786522Z","shell.execute_reply.started":"2022-03-07T03:55:45.493998Z","shell.execute_reply":"2022-03-07T03:55:48.785762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = data.groupby(by=[data.t_dat.dt.year , data.t_dat.dt.dayofweek]).agg({\"price\" : [\"mean\"]})\ntable.index.names = [\"year\",\"dayofweek\"]","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:01:51.062845Z","iopub.execute_input":"2022-03-07T03:01:51.063609Z","iopub.status.idle":"2022-03-07T03:02:01.592588Z","shell.execute_reply.started":"2022-03-07T03:01:51.063569Z","shell.execute_reply":"2022-03-07T03:02:01.59137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table = table.reset_index().droplevel(1,axis=1)\nfig = px.treemap(table, path=['year', 'dayofweek'], values='price')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T03:02:01.594558Z","iopub.execute_input":"2022-03-07T03:02:01.594897Z","iopub.status.idle":"2022-03-07T03:02:01.693332Z","shell.execute_reply.started":"2022-03-07T03:02:01.59486Z","shell.execute_reply":"2022-03-07T03:02:01.692472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_purchage_freq = data.groupby([data.customer_id]).size()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:52:32.114246Z","iopub.execute_input":"2022-03-06T03:52:32.114504Z","iopub.status.idle":"2022-03-06T03:52:44.997698Z","shell.execute_reply.started":"2022-03-06T03:52:32.114476Z","shell.execute_reply":"2022-03-06T03:52:44.996781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_purchage_freq_greather_than_1000 = customer_purchage_freq[customer_purchage_freq > 1000]","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:56:47.751671Z","iopub.execute_input":"2022-03-06T03:56:47.75197Z","iopub.status.idle":"2022-03-06T03:56:47.759091Z","shell.execute_reply.started":"2022-03-06T03:56:47.75194Z","shell.execute_reply":"2022-03-06T03:56:47.757714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_purchage_freq_greather_than_1000","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:56:48.821082Z","iopub.execute_input":"2022-03-06T03:56:48.821312Z","iopub.status.idle":"2022-03-06T03:56:48.826931Z","shell.execute_reply.started":"2022-03-06T03:56:48.82129Z","shell.execute_reply":"2022-03-06T03:56:48.826212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_of_customer = data.customer_id.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:56:52.669705Z","iopub.execute_input":"2022-03-06T03:56:52.669974Z","iopub.status.idle":"2022-03-06T03:57:00.346466Z","shell.execute_reply.started":"2022-03-06T03:56:52.669919Z","shell.execute_reply":"2022-03-06T03:57:00.345472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f\"{len(customer_purchage_freq_greather_than_1000)}/{n_of_customer}\"","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:58:02.134694Z","iopub.execute_input":"2022-03-06T03:58:02.134963Z","iopub.status.idle":"2022-03-06T03:58:02.140095Z","shell.execute_reply.started":"2022-03-06T03:58:02.134935Z","shell.execute_reply":"2022-03-06T03:58:02.139435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customer_list =customer_purchage_freq_greather_than_1000.index.tolist()\nsub_data = data.query(\"customer_id in @customer_list\")","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:58:59.841103Z","iopub.execute_input":"2022-03-06T03:58:59.841389Z","iopub.status.idle":"2022-03-06T03:59:02.977275Z","shell.execute_reply.started":"2022-03-06T03:58:59.841358Z","shell.execute_reply":"2022-03-06T03:59:02.976432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_data.groupby(\"customer_id\")[\"price\"].describe()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T03:59:31.435062Z","iopub.execute_input":"2022-03-06T03:59:31.43535Z","iopub.status.idle":"2022-03-06T03:59:31.490679Z","shell.execute_reply.started":"2022-03-06T03:59:31.435321Z","shell.execute_reply":"2022-03-06T03:59:31.489796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = sub_data['article_id'].value_counts()\npd.DataFrame(article_list[article_list > 7]).T","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:00:51.85286Z","iopub.execute_input":"2022-03-06T04:00:51.853143Z","iopub.status.idle":"2022-03-06T04:00:51.876765Z","shell.execute_reply.started":"2022-03-06T04:00:51.853111Z","shell.execute_reply":"2022-03-06T04:00:51.875979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_data.groupby([\"article_id\",\"customer_id\"]).size()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:01:29.763729Z","iopub.execute_input":"2022-03-06T04:01:29.764178Z","iopub.status.idle":"2022-03-06T04:01:29.78389Z","shell.execute_reply.started":"2022-03-06T04:01:29.764143Z","shell.execute_reply":"2022-03-06T04:01:29.783237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regular_customer_articles_10 = sub_data.groupby([\"article_id\"]).agg({\"customer_id\" : [\"count\"]}).reset_index(drop=False).droplevel(1 ,axis=1).query(\"customer_id > 10\")","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:04:17.614695Z","iopub.execute_input":"2022-03-06T04:04:17.615897Z","iopub.status.idle":"2022-03-06T04:04:17.636056Z","shell.execute_reply.started":"2022-03-06T04:04:17.615827Z","shell.execute_reply":"2022-03-06T04:04:17.635432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = regular_customer_articles_10.article_id.values.tolist()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:04:34.243399Z","iopub.execute_input":"2022-03-06T04:04:34.24374Z","iopub.status.idle":"2022-03-06T04:04:34.248219Z","shell.execute_reply.started":"2022-03-06T04:04:34.243711Z","shell.execute_reply":"2022-03-06T04:04:34.247507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:05:20.179059Z","iopub.execute_input":"2022-03-06T04:05:20.179862Z","iopub.status.idle":"2022-03-06T04:05:20.184912Z","shell.execute_reply.started":"2022-03-06T04:05:20.17983Z","shell.execute_reply":"2022-03-06T04:05:20.184342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_data.query(\"article_id in @article_list\").groupby([\"article_id\",\"customer_id\"]).size()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:04:56.657865Z","iopub.execute_input":"2022-03-06T04:04:56.658767Z","iopub.status.idle":"2022-03-06T04:04:56.673755Z","shell.execute_reply.started":"2022-03-06T04:04:56.658704Z","shell.execute_reply":"2022-03-06T04:04:56.673246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path)","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:06:25.922391Z","iopub.execute_input":"2022-03-06T04:06:25.923191Z","iopub.status.idle":"2022-03-06T04:06:26.865082Z","shell.execute_reply.started":"2022-03-06T04:06:25.923127Z","shell.execute_reply":"2022-03-06T04:06:26.864262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n## reference : https://www.kaggle.com/vanguarde/h-m-eda-first-look \nf, ax = plt.subplots(1, 6, figsize=(25,10))\naxes = ax.flatten()\ni = 0\nfor article in article_list:\n    desc = articles[articles['article_id'] == article]['detail_desc'].iloc[0]\n    desc_list = desc.split(' ')\n    for j, elem in enumerate(desc_list):\n        if j > 0 and j % 5 == 0:\n            desc_list[j] = desc_list[j] + '\\n'\n    desc = ' '.join(desc_list)\n    img = mpimg.imread(f'../input/h-and-m-personalized-fashion-recommendations/images/0{str(article)[:2]}/0{int(article)}.jpg')\n    axes[i].imshow(img)\n    axes[i].set_xticks([], [])\n    axes[i].set_yticks([], [])\n    axes[i].set_title(article)\n    axes[i].grid(False)\n    axes[i].set_xlabel(desc, fontsize=10)\n    i += 1\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-06T04:10:10.977726Z","iopub.execute_input":"2022-03-06T04:10:10.977983Z","iopub.status.idle":"2022-03-06T04:10:13.034242Z","shell.execute_reply.started":"2022-03-06T04:10:10.977957Z","shell.execute_reply":"2022-03-06T04:10:13.033499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Special Customer (old age)\n\n\nAccording to the customer age information, it can be confirmed that older people also make purchases.\n\n* H&M targets woman in the lower middle class and working class, The target market for H&M is for younger people.\n\n[reference](https://ukdiss.com/examples/marketing-analysis-h-and-m.php)\n\nAlthough the company is targeting younger people, it wanted to identify products that would attract older people to buy as well.\n\nAt first, I thought it was an error in the data, but after actually analyzing it, I found that I was buying products with an older age group.\n\n**Let's analyze these customers!**\n","metadata":{}},{"cell_type":"code","source":"specal_customer_transaction_data = data.query(\"customer_id in @special_customer_list\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:33:58.191492Z","iopub.execute_input":"2022-03-07T13:33:58.191782Z","iopub.status.idle":"2022-03-07T13:34:04.383015Z","shell.execute_reply.started":"2022-03-07T13:33:58.191752Z","shell.execute_reply":"2022-03-07T13:34:04.381992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data = pd.merge(specal_customer_transaction_data , customer_binned , how=\"left\",on=\"customer_id\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:04.384614Z","iopub.execute_input":"2022-03-07T13:34:04.384867Z","iopub.status.idle":"2022-03-07T13:34:05.071564Z","shell.execute_reply.started":"2022-03-07T13:34:04.384836Z","shell.execute_reply":"2022-03-07T13:34:05.070763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:05.072926Z","iopub.execute_input":"2022-03-07T13:34:05.073497Z","iopub.status.idle":"2022-03-07T13:34:05.079854Z","shell.execute_reply.started":"2022-03-07T13:34:05.073453Z","shell.execute_reply":"2022-03-07T13:34:05.078996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:05.081737Z","iopub.execute_input":"2022-03-07T13:34:05.081992Z","iopub.status.idle":"2022-03-07T13:34:05.102376Z","shell.execute_reply.started":"2022-03-07T13:34:05.081945Z","shell.execute_reply":"2022-03-07T13:34:05.101485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"articles = pd.read_csv(data_article_path)\nspecal_customer_transaction_data = pd.merge(specal_customer_transaction_data , articles , how=\"left\",on=\"article_id\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:05.104084Z","iopub.execute_input":"2022-03-07T13:34:05.104398Z","iopub.status.idle":"2022-03-07T13:34:06.022585Z","shell.execute_reply.started":"2022-03-07T13:34:05.104354Z","shell.execute_reply":"2022-03-07T13:34:06.021662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['garment_group_name'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:06.023736Z","iopub.execute_input":"2022-03-07T13:34:06.023966Z","iopub.status.idle":"2022-03-07T13:34:06.034785Z","shell.execute_reply.started":"2022-03-07T13:34:06.023937Z","shell.execute_reply":"2022-03-07T13:34:06.034028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['section_name'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:08.982052Z","iopub.execute_input":"2022-03-07T13:34:08.982306Z","iopub.status.idle":"2022-03-07T13:34:08.994778Z","shell.execute_reply.started":"2022-03-07T13:34:08.982277Z","shell.execute_reply":"2022-03-07T13:34:08.993909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['sales_channel_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:09.699849Z","iopub.execute_input":"2022-03-07T13:34:09.7008Z","iopub.status.idle":"2022-03-07T13:34:09.708819Z","shell.execute_reply.started":"2022-03-07T13:34:09.70075Z","shell.execute_reply":"2022-03-07T13:34:09.707667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['club_member_status'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:10.416648Z","iopub.execute_input":"2022-03-07T13:34:10.416934Z","iopub.status.idle":"2022-03-07T13:34:10.429028Z","shell.execute_reply.started":"2022-03-07T13:34:10.416904Z","shell.execute_reply":"2022-03-07T13:34:10.428202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data['index_group_name'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:11.202867Z","iopub.execute_input":"2022-03-07T13:34:11.203706Z","iopub.status.idle":"2022-03-07T13:34:11.217863Z","shell.execute_reply.started":"2022-03-07T13:34:11.203632Z","shell.execute_reply":"2022-03-07T13:34:11.217158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## reference : https://www.kaggle.com/junjitakeshima/h-m-easy-grouping-by-sex-attribute-age-en-jp\nspecal_customer_transaction_data_by_sex = specal_customer_transaction_data[[\"customer_id\",\"index_group_name\",\"article_id\"]].groupby([\"customer_id\",\"index_group_name\"]).count().unstack()\nspecal_customer_transaction_data_by_sex = specal_customer_transaction_data_by_sex.fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:13.088076Z","iopub.execute_input":"2022-03-07T13:34:13.088769Z","iopub.status.idle":"2022-03-07T13:34:13.11933Z","shell.execute_reply.started":"2022-03-07T13:34:13.088723Z","shell.execute_reply":"2022-03-07T13:34:13.118378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_by_sex[\"attribute\"] =specal_customer_transaction_data_by_sex.apply(lambda x : list(x[x == x.max()].index)[0][1], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:14.199891Z","iopub.execute_input":"2022-03-07T13:34:14.200449Z","iopub.status.idle":"2022-03-07T13:34:14.785194Z","shell.execute_reply.started":"2022-03-07T13:34:14.200411Z","shell.execute_reply":"2022-03-07T13:34:14.784411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_by_sex_selected = specal_customer_transaction_data_by_sex.reset_index(drop=False)[[\"customer_id\",\"attribute\"]]","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:16.482607Z","iopub.execute_input":"2022-03-07T13:34:16.483122Z","iopub.status.idle":"2022-03-07T13:34:16.494386Z","shell.execute_reply.started":"2022-03-07T13:34:16.483077Z","shell.execute_reply":"2022-03-07T13:34:16.493555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data = pd.merge(specal_customer_transaction_data,specal_customer_transaction_data_by_sex_selected.droplevel(1,axis=1) , how=\"left\",on=\"customer_id\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:17.291373Z","iopub.execute_input":"2022-03-07T13:34:17.292221Z","iopub.status.idle":"2022-03-07T13:34:17.380797Z","shell.execute_reply.started":"2022-03-07T13:34:17.292176Z","shell.execute_reply":"2022-03-07T13:34:17.379894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data[[\"customer_id\",\"article_id\",\"attribute\"]].head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:37:44.193921Z","iopub.execute_input":"2022-03-07T13:37:44.194507Z","iopub.status.idle":"2022-03-07T13:37:44.20809Z","shell.execute_reply.started":"2022-03-07T13:37:44.19447Z","shell.execute_reply":"2022-03-07T13:37:44.207044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data[\"attribute\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:34:27.774838Z","iopub.execute_input":"2022-03-07T13:34:27.775144Z","iopub.status.idle":"2022-03-07T13:34:27.785353Z","shell.execute_reply.started":"2022-03-07T13:34:27.775113Z","shell.execute_reply":"2022-03-07T13:34:27.784453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Menswear\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:36:31.671375Z","iopub.execute_input":"2022-03-07T13:36:31.671668Z","iopub.status.idle":"2022-03-07T13:36:33.746111Z","shell.execute_reply.started":"2022-03-07T13:36:31.671638Z","shell.execute_reply":"2022-03-07T13:36:33.745179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Ladieswear\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:37:18.510821Z","iopub.execute_input":"2022-03-07T13:37:18.511115Z","iopub.status.idle":"2022-03-07T13:37:20.270278Z","shell.execute_reply.started":"2022-03-07T13:37:18.511077Z","shell.execute_reply":"2022-03-07T13:37:20.269371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Divided\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:37:29.894286Z","iopub.execute_input":"2022-03-07T13:37:29.894601Z","iopub.status.idle":"2022-03-07T13:37:32.121389Z","shell.execute_reply.started":"2022-03-07T13:37:29.894564Z","shell.execute_reply":"2022-03-07T13:37:32.12036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"article_list = specal_customer_transaction_data.query('attribute == \"Sport\"').article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:38:28.42716Z","iopub.execute_input":"2022-03-07T13:38:28.428052Z","iopub.status.idle":"2022-03-07T13:38:30.575701Z","shell.execute_reply.started":"2022-03-07T13:38:28.427992Z","shell.execute_reply":"2022-03-07T13:38:30.574741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"acc_article_list = specal_customer_transaction_data[specal_customer_transaction_data['index_name'].str.contains(\"Accessories\")].article_id.value_counts().head(6).index.tolist()\nvisualize_articles(articles,acc_article_list , n_total = len(acc_article_list) , n_cols = 6 , figsize=(25,14))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:41:57.225767Z","iopub.execute_input":"2022-03-07T13:41:57.226076Z","iopub.status.idle":"2022-03-07T13:41:59.19048Z","shell.execute_reply.started":"2022-03-07T13:41:57.226042Z","shell.execute_reply":"2022-03-07T13:41:59.189628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Some users probably bought clothes for their grandchildren.","metadata":{}},{"cell_type":"code","source":"specal_customer_transaction_data_certain_garment = specal_customer_transaction_data.query('garment_group_name == \"Woven/Jersey/Knitted mix Baby\"')[[\"article_id\",\"age_binned\"]]\narticle_list = specal_customer_transaction_data_certain_garment['article_id'].unique().tolist()\nvisualize_articles(articles,article_list , n_total = len(article_list) , n_cols = 5 , figsize=(25,20))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:43:00.760107Z","iopub.execute_input":"2022-03-07T13:43:00.760395Z","iopub.status.idle":"2022-03-07T13:43:06.159824Z","shell.execute_reply.started":"2022-03-07T13:43:00.760364Z","shell.execute_reply":"2022-03-07T13:43:06.159077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_top_6 = specal_customer_transaction_data.groupby(\"age_binned\").apply(lambda x : x['article_id'].value_counts().head(6))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:36:47.278695Z","iopub.execute_input":"2022-03-07T13:36:47.278993Z","iopub.status.idle":"2022-03-07T13:36:47.300703Z","shell.execute_reply.started":"2022-03-07T13:36:47.278943Z","shell.execute_reply":"2022-03-07T13:36:47.300045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"specal_customer_transaction_data_top_6 = specal_customer_transaction_data_top_6.reset_index(drop=False)\nspecal_customer_transaction_data_top_6","metadata":{"execution":{"iopub.status.busy":"2022-03-07T13:36:47.301905Z","iopub.execute_input":"2022-03-07T13:36:47.302619Z","iopub.status.idle":"2022-03-07T13:36:47.315966Z","shell.execute_reply.started":"2022-03-07T13:36:47.302579Z","shell.execute_reply":"2022-03-07T13:36:47.315048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f, ax = plt.subplots(2, 6, figsize=(25,15))\naxes = ax.flatten()\n\ni = 0\narticle_list = specal_customer_transaction_data_top_6.head(6)['level_1'].values.tolist()\nfor article in article_list:\n    visualize_article(axes , i , articles , article)\n    i += 1\narticle_list = specal_customer_transaction_data_top_6.tail(6)['level_1'].values.tolist()\nfor article in article_list:\n    visualize_article(axes , i , articles , article)\n    i += 1\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T12:40:31.955015Z","iopub.execute_input":"2022-03-07T12:40:31.95532Z","iopub.status.idle":"2022-03-07T12:40:35.653772Z","shell.execute_reply.started":"2022-03-07T12:40:31.955288Z","shell.execute_reply":"2022-03-07T12:40:35.652801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}