{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"lunana  \nlast update 2022 04 08  \nゆっくりしていってね！  \n\nversion 3 +graph  \nversion 4 +add test  \nversion 5 +Trends","metadata":{"id":"3aM8dNjwKVmY"}},{"cell_type":"markdown","source":"# Trends  \n## Add test  \n* H&M Byfone's add test ゆっくり実況 LB=0.0225  \nhttps://www.kaggle.com/code/lunapandachan/h-m-trending-products-weekly-add-test","metadata":{}},{"cell_type":"markdown","source":"# Data list  \n* [**images**](#images)  ---image file\n\n* [**transaction_train.csv**](#transaction_train.csv)  \n\n* [**article.csv**](#article.csv)  \n\n* [**customers.csv**](#customers.csv)  \n\n* [**sample_submission.csv**](#sample_submission.csv)","metadata":{}},{"cell_type":"markdown","source":"**霊夢：今日も画像のコンペだね。  \n魔理沙：まずは概要を読んでみよう。**\n\n**Reimu: It's an image competition today as well.  \nMarisa: First, let's read the overview.**","metadata":{"id":"PgIt2tfOKYvb"}},{"cell_type":"markdown","source":"H＆M Groupは、53のオンライン市場と約4,850の店舗を持つブランドと企業のファミリーです。私たちのオンラインストアは買い物客に閲覧するための製品の幅広い選択を提供します。しかし、選択肢が多すぎると、顧客は自分が興味を持っているものや探しているものをすぐに見つけられず、最終的には購入できない可能性があります。ショッピング体験を向上させるには、製品の推奨事項が重要です。さらに重要なことに、顧客が正しい選択をするのを支援することは、収益を減らし、それによって輸送からの排出を最小限に抑えるため、持続可能性にもプラスの影響を及ぼします。  \n\nこのコンペティションでは、H＆M Groupは、以前のトランザクションのデータ、および顧客と製品のメタデータに基づいて製品の推奨事項を作成することを勧めます。利用可能なメタデータは、衣服の種類や顧客の年齢などの単純なデータから、製品の説明からのテキストデータ、衣服の画像からの画像データにまで及びます。  \n\nどのような情報が役立つかについての先入観はありません。それはあなたが知るためのものです。カテゴリデータ型アルゴリズムを調査したい場合、またはNLPと画像処理の深層学習に飛び込みたい場合は、それはあなた次第です。  \n\n\nH&M Group is a family of brands and businesses with 53 online markets and approximately 4,850 stores. Our online store offers shoppers an extensive selection of products to browse through. But with too many choices, customers might not quickly find what interests them or what they are looking for, and ultimately, they might not make a purchase. To enhance the shopping experience, product recommendations are key. More importantly, helping customers make the right choices also has a positive implications for sustainability, as it reduces returns, and thereby minimizes emissions from transportation.\n\nIn this competition, H&M Group invites you to develop product recommendations based on data from previous transactions, as well as from customer and product meta data. The available meta data spans from simple data, such as garment type and customer age, to text data from product descriptions, to image data from garment images.\n\nThere are no preconceptions on what information that may be useful – that is for you to find out. If you want to investigate a categorical data type algorithm, or dive into NLP and image processing deep learning, that is up to you.","metadata":{"id":"qqlnWh3yKZ-R"}},{"cell_type":"markdown","source":"# images","metadata":{}},{"cell_type":"markdown","source":"**霊夢:画像のコンペだから最初に画像データを見てみよう。**\n\n**Reimu: It's an image competition, so let's look at the image data first.**","metadata":{}},{"cell_type":"markdown","source":"images / -それぞれに対応する画像のフォルダarticle_id; article_id画像は、article_id;の最初の3桁から始まるサブフォルダに配置されます。すべてのarticle_idに対応する画像があるわけではないことに注意してください。\n\nimages/ - a folder of images corresponding to each article_id; images are placed in subfolders starting with the first three digits of the article_id; note, not all article_id values have a corresponding image.","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pylab as plt\nimport os\nfrom os import listdir\nimport cv2","metadata":{"id":"gjVvKrXcKs1o","execution":{"iopub.status.busy":"2022-03-07T14:42:18.965195Z","iopub.execute_input":"2022-03-07T14:42:18.965534Z","iopub.status.idle":"2022-03-07T14:42:19.354198Z","shell.execute_reply.started":"2022-03-07T14:42:18.965448Z","shell.execute_reply":"2022-03-07T14:42:19.353408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images_dir = '../input/h-and-m-personalized-fashion-recommendations/images'\ncat_images = [f for f in listdir(images_dir)]","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:42:19.355746Z","iopub.execute_input":"2022-03-07T14:42:19.356252Z","iopub.status.idle":"2022-03-07T14:42:19.368585Z","shell.execute_reply.started":"2022-03-07T14:42:19.356217Z","shell.execute_reply":"2022-03-07T14:42:19.367945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def getImagePaths(path):\n\n    image_names = []\n    for dirname, _, filenames in os.walk(path):\n        for filename in filenames:\n            fullpath = os.path.join(dirname, filename)\n            image_names.append(fullpath)\n    return image_names\n\ndef display_multiple_img(images_paths, rows, cols):\n\n    figure, ax = plt.subplots(nrows=rows,ncols=cols,figsize=(16,8) )\n    for ind,image_path in enumerate(images_paths):\n        image=cv2.imread(image_path)\n        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) \n        try:\n            ax.ravel()[ind].imshow(image)\n            ax.ravel()[ind].set_axis_off()\n        except:\n            continue;\n    plt.tight_layout()\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:42:19.370132Z","iopub.execute_input":"2022-03-07T14:42:19.370593Z","iopub.status.idle":"2022-03-07T14:42:19.379143Z","shell.execute_reply.started":"2022-03-07T14:42:19.370558Z","shell.execute_reply":"2022-03-07T14:42:19.378403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images_path = getImagePaths(images_dir)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:42:19.38084Z","iopub.execute_input":"2022-03-07T14:42:19.381355Z","iopub.status.idle":"2022-03-07T14:42:51.35251Z","shell.execute_reply.started":"2022-03-07T14:42:19.38132Z","shell.execute_reply":"2022-03-07T14:42:51.351835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_multiple_img(images_path[0:30], 6, 5)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:42:51.353835Z","iopub.execute_input":"2022-03-07T14:42:51.354711Z","iopub.status.idle":"2022-03-07T14:42:58.669812Z","shell.execute_reply.started":"2022-03-07T14:42:51.354667Z","shell.execute_reply":"2022-03-07T14:42:58.669014Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# transaction_train.csv","metadata":{}},{"cell_type":"markdown","source":"**魔理沙：次はtrainデータを見てみよう**\n\n**Marisa: Next, let's look at the train data.**","metadata":{"id":"8eZi9TNGKdl3"}},{"cell_type":"markdown","source":"transaction_train.csv-各日付の各顧客の購入と追加情報で構成されるトレーニングデータ。重複する行は、同じアイテムの複数の購入に対応します。あなたの仕事はarticle_id、トレーニングデータ期間の直後の7日間に各顧客が購入するものを予測することです。  \n\ntransactions_train.csv - the training data, consisting of the purchases each customer for each date, as well as additional information. Duplicate rows correspond to multiple purchases of the same item. Your task is to predict the article_ids each customer will purchase during the 7-day period immediately after the training data period.","metadata":{"id":"Q2U_WmKrKxA0"}},{"cell_type":"code","source":"df_train = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\")\ndf_train.head()","metadata":{"id":"74V8FJWGK3cF","execution":{"iopub.status.busy":"2022-03-07T14:42:58.670891Z","iopub.execute_input":"2022-03-07T14:42:58.671216Z","iopub.status.idle":"2022-03-07T14:44:03.464518Z","shell.execute_reply.started":"2022-03-07T14:42:58.671188Z","shell.execute_reply":"2022-03-07T14:44:03.463703Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.describe()","metadata":{"id":"lK8RntkELDWW","execution":{"iopub.status.busy":"2022-03-07T14:44:03.466063Z","iopub.execute_input":"2022-03-07T14:44:03.466305Z","iopub.status.idle":"2022-03-07T14:44:06.610081Z","shell.execute_reply.started":"2022-03-07T14:44:03.466276Z","shell.execute_reply":"2022-03-07T14:44:06.609104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(df_train)","metadata":{"id":"OG4ej4ohLJQT","execution":{"iopub.status.busy":"2022-03-07T14:44:06.611529Z","iopub.execute_input":"2022-03-07T14:44:06.611841Z","iopub.status.idle":"2022-03-07T14:44:06.619351Z","shell.execute_reply.started":"2022-03-07T14:44:06.6118Z","shell.execute_reply":"2022-03-07T14:44:06.618521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:priceのグラフを書いてみよう。**  \n\n**Reimu: Let's draw a price graph.**","metadata":{}},{"cell_type":"code","source":"df_train['price'].plot(kind='hist', bins=100, figsize=(15, 6));\nplt.title(\"Target distribution\", weight='bold', fontsize=16);","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:44:06.620745Z","iopub.execute_input":"2022-03-07T14:44:06.62095Z","iopub.status.idle":"2022-03-07T14:44:11.182754Z","shell.execute_reply.started":"2022-03-07T14:44:06.620924Z","shell.execute_reply":"2022-03-07T14:44:11.181798Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:priceの単位は何だろう？  \n魔理沙:日本の「円」でないことは確かだな。**\n\n**Reimu: What is the unit of price?  \nMarisa: I'm sure it's not the \"yen\" of Japan.**\n\n![https://1.bp.blogspot.com/-YriNGI2Efhg/USNoM1sm-VI/AAAAAAAANSo/4SYv9Z4wL74/s400/money_1.png](https://1.bp.blogspot.com/-YriNGI2Efhg/USNoM1sm-VI/AAAAAAAANSo/4SYv9Z4wL74/s400/money_1.png)","metadata":{}},{"cell_type":"code","source":"df_train['sales_channel_id'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:44:11.186361Z","iopub.execute_input":"2022-03-07T14:44:11.186619Z","iopub.status.idle":"2022-03-07T14:44:11.368574Z","shell.execute_reply.started":"2022-03-07T14:44:11.186589Z","shell.execute_reply":"2022-03-07T14:44:11.367688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:'sales_channel_id'は2種類あるみたいだ。  \n魔理沙:円グラフで割合を見てみよう。**  \n\n**Reimu: There seem to be two types of'sales_channel_id'.  \nMarisa: Let's look at the percentage in a pie chart.**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 8))\nplt.rcParams[\"font.size\"] = 18\nplt.pie(df_train[\"sales_channel_id\"].value_counts().sort_values(ascending=True),labels = df_train[\"sales_channel_id\"].value_counts().sort_values(ascending=True).index,startangle = 90,autopct=\"%1.1f%%\")","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:44:11.369911Z","iopub.execute_input":"2022-03-07T14:44:11.370145Z","iopub.status.idle":"2022-03-07T14:44:11.821187Z","shell.execute_reply.started":"2022-03-07T14:44:11.370116Z","shell.execute_reply":"2022-03-07T14:44:11.819969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:costomerが2年の間に何回買い物しているかヒストグラムで見てみよう。**\n\n**Reimu: Let's take a look at the histogram of how many times costomer has shopped in two years.**","metadata":{}},{"cell_type":"code","source":"df1=df_train.groupby('customer_id').size()\nplt.figure(figsize=(15, 8))\nplt.hist(df1.values.tolist(),bins=100,range=(0,100))","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:44:11.822896Z","iopub.execute_input":"2022-03-07T14:44:11.823504Z","iopub.status.idle":"2022-03-07T14:44:32.661658Z","shell.execute_reply.started":"2022-03-07T14:44:11.82345Z","shell.execute_reply":"2022-03-07T14:44:32.660675Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:大体の人は20着以下みたいだね。  \n魔理沙:1年に10着ってとこかな？**\n\n**Reimu: Most people seem to wear 20 or less.  \nMarisa: Do you wear 10 in a year?**\n\n![https://3.bp.blogspot.com/-MGd0Z_T_fn4/VZt5DJ5IAGI/AAAAAAAAuyU/2EClnKUNgmo/s400/fuku_tatamu.png](https://3.bp.blogspot.com/-MGd0Z_T_fn4/VZt5DJ5IAGI/AAAAAAAAuyU/2EClnKUNgmo/s400/fuku_tatamu.png)","metadata":{}},{"cell_type":"markdown","source":"**霊夢:売れ筋のグラフを書いてみよう。**\n\n**Reimu: Let's draw a hot-selling graph.**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 20))\nplt.rcParams[\"font.size\"] = 18\nplt.xticks(rotation=90)\nplt.bar(df_train[\"article_id\"].astype(str).value_counts().sort_values(ascending=True)[-10:].index,df_train[\"article_id\"].value_counts().sort_values(ascending=True)[-10:],tick_label = df_train[\"article_id\"].astype(str).value_counts().sort_values(ascending=True)[-10:].index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:44:54.480503Z","iopub.execute_input":"2022-03-07T14:44:54.481372Z","iopub.status.idle":"2022-03-07T14:46:27.250845Z","shell.execute_reply.started":"2022-03-07T14:44:54.481332Z","shell.execute_reply":"2022-03-07T14:46:27.249708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**魔理沙:Top2を画像で見てみよう。**\n\n**Marisa: Let's take a look at the Top 2 in the image.**","metadata":{}},{"cell_type":"code","source":"path = \"../input/h-and-m-personalized-fashion-recommendations/images/070/0706016001.jpg\"\nim = plt.imread(path)\nplt.figure(figsize=(15, 6))\nplt.imshow(im)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:46:50.652997Z","iopub.execute_input":"2022-03-07T14:46:50.653278Z","iopub.status.idle":"2022-03-07T14:46:51.219863Z","shell.execute_reply.started":"2022-03-07T14:46:50.653248Z","shell.execute_reply":"2022-03-07T14:46:51.218842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = \"../input/h-and-m-personalized-fashion-recommendations/images/070/0706016002.jpg\"\nim = plt.imread(path)\nplt.figure(figsize=(15, 6))\nplt.imshow(im)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:47:54.314325Z","iopub.execute_input":"2022-03-07T14:47:54.31513Z","iopub.status.idle":"2022-03-07T14:47:54.895502Z","shell.execute_reply.started":"2022-03-07T14:47:54.31509Z","shell.execute_reply":"2022-03-07T14:47:54.894545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:ズボンが一番売れたんだね。**\n\n**Reimu: The pants sold best.**","metadata":{}},{"cell_type":"markdown","source":"**魔理沙:次はarticleデータを見てみよう。**\n\n**Marisa: Next, let's take a look at the article data.**","metadata":{}},{"cell_type":"markdown","source":"# article.csv","metadata":{}},{"cell_type":"markdown","source":"articles.csv-購入可能なそれぞれのarticle_idの詳細なメタデータ\n\narticles.csv - detailed metadata for each article_id available for purchase","metadata":{}},{"cell_type":"code","source":"df_article = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/articles.csv\")\ndf_article.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:04.891538Z","iopub.execute_input":"2022-03-07T14:51:04.891929Z","iopub.status.idle":"2022-03-07T14:51:05.873711Z","shell.execute_reply.started":"2022-03-07T14:51:04.891895Z","shell.execute_reply":"2022-03-07T14:51:05.873149Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(df_article)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:05.875294Z","iopub.execute_input":"2022-03-07T14:51:05.875753Z","iopub.status.idle":"2022-03-07T14:51:05.881239Z","shell.execute_reply.started":"2022-03-07T14:51:05.875719Z","shell.execute_reply":"2022-03-07T14:51:05.880317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_article.info()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:05.882603Z","iopub.execute_input":"2022-03-07T14:51:05.883218Z","iopub.status.idle":"2022-03-07T14:51:06.074598Z","shell.execute_reply.started":"2022-03-07T14:51:05.88317Z","shell.execute_reply":"2022-03-07T14:51:06.073495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(df_article['product_type_name'].unique())","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:06.076361Z","iopub.execute_input":"2022-03-07T14:51:06.077057Z","iopub.status.idle":"2022-03-07T14:51:06.094495Z","shell.execute_reply.started":"2022-03-07T14:51:06.077017Z","shell.execute_reply":"2022-03-07T14:51:06.093627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(df_article['product_group_name'].unique())","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:06.09657Z","iopub.execute_input":"2022-03-07T14:51:06.096837Z","iopub.status.idle":"2022-03-07T14:51:06.111333Z","shell.execute_reply.started":"2022-03-07T14:51:06.096807Z","shell.execute_reply":"2022-03-07T14:51:06.110692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:気になる箇所をグラフにしてみるよ。  \n魔理沙:まずは、product_group_nameのグラフを書いてみよう。**\n\n**Reimu: Let's graph the parts you care about.  \nMarisa: First, let's draw a graph of product_group_name.**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 10))\nplt.rcParams[\"font.size\"] = 18\nplt.xticks(rotation=90)\nplt.bar(df_article[\"product_group_name\"].value_counts().sort_values(ascending=True).index,df_article[\"product_group_name\"].value_counts().sort_values(ascending=True),tick_label = df_article[\"product_group_name\"].value_counts().sort_values(ascending=True).index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:06.112948Z","iopub.execute_input":"2022-03-07T14:51:06.113504Z","iopub.status.idle":"2022-03-07T14:51:06.538958Z","shell.execute_reply.started":"2022-03-07T14:51:06.113463Z","shell.execute_reply":"2022-03-07T14:51:06.538051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:Garment Upper bodyがダントツだな。  \n魔理沙:次はproduct_type_nameのグラフを書いてみよう。**\n\n**Reimu: Garment Upper body is by far the best.  \nMarisa: Next, let's draw a graph of product_type_name.**\n\n![https://4.bp.blogspot.com/-5rZdUK4Hils/V2FUaBaHRFI/AAAAAAAA7XI/Dk7lqx9-ahMjXmrfdMVFxyR-iRJnXjvTACLcB/s450/fashion_parka_woman.png](https://4.bp.blogspot.com/-5rZdUK4Hils/V2FUaBaHRFI/AAAAAAAA7XI/Dk7lqx9-ahMjXmrfdMVFxyR-iRJnXjvTACLcB/s450/fashion_parka_woman.png)","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 15))\nplt.rcParams[\"font.size\"] = 18\nplt.barh(df_article[\"product_type_name\"].value_counts().sort_values(ascending=True)[-20:].index,df_article[\"product_type_name\"].value_counts().sort_values(ascending=True)[-20:],tick_label = df_article[\"product_type_name\"].value_counts().sort_values(ascending=True)[-20:].index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:49.362364Z","iopub.execute_input":"2022-03-07T14:51:49.362887Z","iopub.status.idle":"2022-03-07T14:51:49.76417Z","shell.execute_reply.started":"2022-03-07T14:51:49.362847Z","shell.execute_reply":"2022-03-07T14:51:49.763306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:ズボン、ドレス、セーター、Tシャツがトップを争ってる感じかな？  \n魔理沙:product_group_nameのグラフでは、ズボンは2位に値すると思うが、Garment Upper bodyにドレス、セーター、Tシャツが含まれているのかな？**\n\n**Reimu: I think pants, dresses, sweaters, and T-shirts are competing for the top.  \nMarisa: In the product_group_name graph, I think trousers deserve second place, but does the Garment Upper body include dresses, sweaters, and T-shirts?**\n\n![https://4.bp.blogspot.com/-rjGbr6H8rZs/VMItos_vo_I/AAAAAAAAqwQ/nHkcYTPXQPY/s400/tatemono_dress_shop.png](https://4.bp.blogspot.com/-rjGbr6H8rZs/VMItos_vo_I/AAAAAAAAqwQ/nHkcYTPXQPY/s400/tatemono_dress_shop.png)","metadata":{}},{"cell_type":"markdown","source":"**霊夢:次は、colour_group_nameのグラフを書いてみよう。**\n\n**Reimu: Next, let's draw a graph of color_group_name.**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 20))\nplt.rcParams[\"font.size\"] = 18\nplt.barh(df_article[\"colour_group_name\"].value_counts().sort_values(ascending=True).index,df_article[\"colour_group_name\"].value_counts().sort_values(ascending=True),tick_label = df_article[\"colour_group_name\"].value_counts().sort_values(ascending=True).index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:06.958517Z","iopub.execute_input":"2022-03-07T14:51:06.958801Z","iopub.status.idle":"2022-03-07T14:51:07.953243Z","shell.execute_reply.started":"2022-03-07T14:51:06.958767Z","shell.execute_reply":"2022-03-07T14:51:07.952183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:暗い色が多いみたいだな。  \n魔理沙:次はperceived_colour_value_nameのグラフを書いてみよう。**\n\n**Reimu: It seems that there are many dark colors.  \nMarisa: Next, let's draw a graph of perceived_colour_value_name.**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 10))\nplt.rcParams[\"font.size\"] = 18\nplt.bar(df_article[\"perceived_colour_value_name\"].value_counts().sort_values(ascending=True).index,df_article[\"perceived_colour_value_name\"].value_counts().sort_values(ascending=True),tick_label = df_article[\"perceived_colour_value_name\"].value_counts().sort_values(ascending=True).index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:07.954924Z","iopub.execute_input":"2022-03-07T14:51:07.955576Z","iopub.status.idle":"2022-03-07T14:51:08.261287Z","shell.execute_reply.started":"2022-03-07T14:51:07.955522Z","shell.execute_reply":"2022-03-07T14:51:08.260417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:Darkがダントツだな。  \n魔理沙:次はdepartment_nameのグラフを書いてみよう。**\n\n**Reimu: Dark is by far the best.  \nMarisa: Next, let's draw a graph of department_name.**\n\n![https://1.bp.blogspot.com/-pX_upYiDqqE/WzC-dq2qNXI/AAAAAAABNCM/LZrISI4hd44KutOdW7aWDaZH7RYQ_rDVwCLcBGAs/s400/fashion_parka_dark.png](https://1.bp.blogspot.com/-pX_upYiDqqE/WzC-dq2qNXI/AAAAAAABNCM/LZrISI4hd44KutOdW7aWDaZH7RYQ_rDVwCLcBGAs/s400/fashion_parka_dark.png)","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 20))\nplt.rcParams[\"font.size\"] = 18\nplt.barh(df_article[\"department_name\"].value_counts().sort_values(ascending=True)[-40:].index,df_article[\"department_name\"].value_counts().sort_values(ascending=True)[-40:],tick_label = df_article[\"department_name\"].value_counts().sort_values(ascending=True)[-40:].index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:53:16.677345Z","iopub.execute_input":"2022-03-07T14:53:16.677745Z","iopub.status.idle":"2022-03-07T14:53:17.273177Z","shell.execute_reply.started":"2022-03-07T14:53:16.67765Z","shell.execute_reply":"2022-03-07T14:53:17.272237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:ジャージが1位だ。  \n魔理沙:今までのグラフを考えると、黒や紺のジャージが多いのかな？  \n霊夢:確かにそうだな。**\n\n**Reimu: The jersey is number one.  \nMarisa: Considering the graphs so far, are there many black and dark blue jerseys?  \nReimu: That's true.**\n\n![https://4.bp.blogspot.com/-U4GYvrbP1xs/V1z9DKCAyOI/AAAAAAAA7Oo/x4o_Dglgz6IG-0GTZbk5I1uUYrBc2N-dACLcB/s400/fashion_jersey.png](https://4.bp.blogspot.com/-U4GYvrbP1xs/V1z9DKCAyOI/AAAAAAAA7Oo/x4o_Dglgz6IG-0GTZbk5I1uUYrBc2N-dACLcB/s400/fashion_jersey.png)","metadata":{}},{"cell_type":"markdown","source":"**魔理沙:次はindex_nameのグラフを書いてみよう。**\n\n**Marisa: Next, let's draw a graph of index_name.**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 10))\nplt.rcParams[\"font.size\"] = 18\nplt.xticks(rotation=90)\nplt.bar(df_article[\"index_name\"].value_counts().sort_values(ascending=True).index,df_article[\"index_name\"].value_counts().sort_values(ascending=True),tick_label = df_article[\"index_name\"].value_counts().sort_values(ascending=True).index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:09.118341Z","iopub.execute_input":"2022-03-07T14:51:09.11859Z","iopub.status.idle":"2022-03-07T14:51:09.455143Z","shell.execute_reply.started":"2022-03-07T14:51:09.11856Z","shell.execute_reply":"2022-03-07T14:51:09.454069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:レディースが多くて、2番目は何だ？  \n魔理沙:男も女も着れるユニセックスのことかな？**\n\n**Reimu: There are many ladieswear, what's the second?   \nMarisa: Is it unisex that both men and women can wear?**\n\n![https://1.bp.blogspot.com/-1mDH3g7QRPw/UU--szX9ocI/AAAAAAAAO8c/uQ8FFYpXDnA/s400/date_couple.png](https://1.bp.blogspot.com/-1mDH3g7QRPw/UU--szX9ocI/AAAAAAAAO8c/uQ8FFYpXDnA/s400/date_couple.png)","metadata":{}},{"cell_type":"markdown","source":"**霊夢:次はcustomersデータを見てみよう。**\n\n**Reimu: Next, let's look at the customers data.**","metadata":{}},{"cell_type":"markdown","source":"# customers.csv","metadata":{}},{"cell_type":"markdown","source":"customers.csv-データセット内の各メタcustomer_idデータ  \n\ncustomers.csv - metadata for each customer_id in dataset","metadata":{}},{"cell_type":"code","source":"df_costomers = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/customers.csv\")\ndf_costomers.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:09.456371Z","iopub.execute_input":"2022-03-07T14:51:09.457397Z","iopub.status.idle":"2022-03-07T14:51:14.928961Z","shell.execute_reply.started":"2022-03-07T14:51:09.457353Z","shell.execute_reply":"2022-03-07T14:51:14.928095Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**魔理沙:年齢でグラフにしてみよう。** \n\n**Marisa: Let's graph by age.**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(15, 25))\nplt.rcParams[\"font.size\"] = 15\nplt.barh(df_costomers[\"age\"].value_counts().sort_values(ascending=True).index,df_costomers[\"age\"].value_counts().sort_values(ascending=True),tick_label = df_costomers[\"age\"].value_counts().sort_values(ascending=True).index)","metadata":{"execution":{"iopub.status.busy":"2022-03-07T14:51:14.930334Z","iopub.execute_input":"2022-03-07T14:51:14.930807Z","iopub.status.idle":"2022-03-07T14:51:16.291601Z","shell.execute_reply.started":"2022-03-07T14:51:14.930763Z","shell.execute_reply":"2022-03-07T14:51:16.290983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:20代の若い世代に人気があるんだね。  \n魔理沙:50歳前後にも人気がありそうだ。**  \n\n**Reimu: It's popular with the younger generation in their twenties.  \nMarisa: It seems to be popular around the age of 50.**\n\n![https://1.bp.blogspot.com/-gTf4sWnRdDw/X0B4RSQQLrI/AAAAAAABarI/MJ9DW90dSVwtMjuUoErxemnN4nPXBnXUwCNcBGAsYHQ/s400/otaku_girl_fashion.png](https://1.bp.blogspot.com/-gTf4sWnRdDw/X0B4RSQQLrI/AAAAAAABarI/MJ9DW90dSVwtMjuUoErxemnN4nPXBnXUwCNcBGAsYHQ/s400/otaku_girl_fashion.png)","metadata":{}},{"cell_type":"markdown","source":"**魔理沙：最後にsample_submissionを見てみよう**\n\n**Marisa: Finally, let's take a look at sample_submission.**","metadata":{"id":"ImOk5OYoN9UL"}},{"cell_type":"markdown","source":"# sample_submission.csv","metadata":{}},{"cell_type":"markdown","source":"sample_submission.csv-正しい形式のサンプル送信ファイル \n\nsample_submission.csv - a sample submission file in the correct format","metadata":{}},{"cell_type":"markdown","source":"customer_idトレーニングデータで観察されたそれぞれについて、最大12個のラベルを予測できますarticle_id。これは、トレーニング期間後の次の7日間に顧客が購入する予測アイテムです。ファイルにはヘッダーが含まれ、次の形式である必要があります。  \n\nFor each customer_id observed in the training data, you may predict up to 12 labels for the article_id, which is the predicted items a customer will buy in the next 7-day period after the training time period. The file should contain a header and have the following format:  \n\n**魔理沙:以下のURLから評価方法について見れます。**\n\n**Marisa: You can see the evaluation method from the following URL.**  \nhttps://www.kaggle.com/c/h-and-m-personalized-fashion-recommendations/overview/evaluation","metadata":{}},{"cell_type":"code","source":"sample_submission = pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/sample_submission.csv\")\nsample_submission","metadata":{"id":"p0maxlzeOFem","execution":{"iopub.status.busy":"2022-03-07T14:51:16.293868Z","iopub.execute_input":"2022-03-07T14:51:16.294307Z","iopub.status.idle":"2022-03-07T14:51:21.078437Z","shell.execute_reply.started":"2022-03-07T14:51:16.294273Z","shell.execute_reply":"2022-03-07T14:51:21.077814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**霊夢:今回はここまでです。  \n魔理沙:最後までご覧いただきありがとうございました。**\n\n**Reimu: That's all for this time.  \nMarisa: Thank you for watching until the end.**\n\n![https://4.bp.blogspot.com/-yHD_2Wd9COA/W3abz2I2X-I/AAAAAAABOEo/Y1DA1AQiVGoOttCPOJz8fIZc4jO18WiZwCLcBGAs/s400/zarei_woman.png](https://4.bp.blogspot.com/-yHD_2Wd9COA/W3abz2I2X-I/AAAAAAABOEo/Y1DA1AQiVGoOttCPOJz8fIZc4jO18WiZwCLcBGAs/s400/zarei_woman.png)","metadata":{}}]}