{"id":204,"date":"2020-10-21T19:34:24","date_gmt":"2020-10-21T10:34:24","guid":{"rendered":"https:\/\/www.ritzcolor.net\/?p=204"},"modified":"2020-12-10T20:08:53","modified_gmt":"2020-12-10T11:08:53","slug":"%e3%81%a9%e7%b4%a0%e4%ba%ba%e3%81%aekaggle4-2nd-sub","status":"publish","type":"post","link":"https:\/\/www.ritzcolor.net\/?p=204","title":{"rendered":"\u3069\u7d20\u4eba\u306ekaggle4 -2nd sub-"},"content":{"rendered":"\n<p>\u524d\u56de\u306f\u5e74\u3068\u6708\u306e\u307f\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3001shop\u3084category, item\u306e\u540d\u524d\u3092\u5168\u3066\u7834\u68c4\u3057\u3066\u4e88\u60f3\u3057\u3066\u3044\u307e\u3057\u305f\u3002\u3055\u3089\u306b\u4e88\u6e2c\u7cbe\u5ea6\u3092\u4e0a\u3052\u308b\u305f\u3081\u306b\u306f\u3053\u306e\u8fba\u308a\u306e\u60c5\u5831\u3092\u4e0a\u624b\u304f\u4f7f\u3044\u305f\u3044\u306a\u3068\u601d\u3044\u3001\u4eca\u56de\u306f\u3053\u306e\u8fba\u308a\u3092\u4e0a\u624b\u304f\u4f7f\u304a\u3046\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3042\u3068\u524d\u56de\u306e\u554f\u984c\u70b9\u3068\u3057\u3066\u3001item_id\u3084shop_id\u3092\u305d\u306e\u307e\u307e\u9023\u7d9a\u3059\u308b\u6570\u5024\u3068\u3057\u3066\u4f7f\u7528\u3057\u3066\u3044\u305f\u306e\u3067\u3001\u30ce\u30a4\u30ba\u3068\u306a\u3063\u3066\u3044\u305f\u3053\u3068\u304c\u4e88\u60f3\u3055\u308c\u307e\u3059\u3002id\u306e4\u306e\u58f2\u308a\u4e0a\u3052\u304c3\u30685\u306e\u9593\u306b\u3042\u308b\u304b\uff1f\u3068\u3044\u3046\u3068\u306a\u3044\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3055\u3066shop_name\u306a\u3069\u306f\u30ed\u30b7\u30a2\u8a9e\u3067\u3001\u3055\u3063\u3071\u308a\u308f\u304b\u3089\u306a\u3044\u3057\u6a5f\u68b0\u5b66\u7fd2\u306b\u6587\u5b57\u5217\u306f\u50d5\u306e\u62d9\u3044\u77e5\u8b58\u3067\u306f\u305d\u306e\u307e\u307e\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u306e\u3067\u3001\u306a\u3093\u3089\u304b\u306e\u5de5\u592b\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30c7\u30fc\u30bf\u306e\u7a2e\u985e\u304c\u5c11\u306a\u3051\u308c\u3070\u3001\u7537\u6027\u30921, \u5973\u6027\u30920\u3068\u3059\u308b\u306a\u3069\u3057\u3066\u6570\u5024\u306b\u7f6e\u304d\u63db\u3048\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001item.info()\u3067\u307f\u3066\u307f\u308b\u3068\u300122170\u7a2e\u985e\u3002\u3002\u3002shop\u306f60\u3067category\u306f30\u3068\u4e2d\u3005\u306e\u7a2e\u985e\u306a\u306e\u3067\u3001\u305f\u3060\u5358\u306b\u7f6e\u304d\u63db\u3048\u305f\u3068\u3053\u308d\u3067\u4e0a\u624b\u304f\u4f7f\u3048\u306a\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u3053\u3067\u8003\u3048\u305f\u306e\u304c\u3001item, shop, category\u305d\u308c\u305e\u308c\u306b\u304a\u3044\u3066\u3001\u58f2\u308c\u884c\u304d\u30e9\u30f3\u30af\u3092\u4f5c\u3063\u3066\u3084\u308c\u3070\u305d\u3053\u305d\u3053\u610f\u5473\u304c\u3042\u308b\u3088\u3046\u306b\u306a\u308b\u306e\u3067\u306f\uff1f\u3068\u601d\u3044\u3001\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\u4f7f\u7528\u3057\u305f\u30b3\u30fc\u30c9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>#\u305d\u308c\u305e\u308cpivot\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u308a\u3001\u964d\u9806\u306b\u30bd\u30fc\u30c8\u3002\u305d\u3053\u306bindex\u3092\u4ed8\u4e0e\u3057\u3001\u58f2\u308a\u4e0a\u3052\u30e9\u30f3\u30ad\u30f3\u30b0\u3092\u4f5c\u6210\u3059\u308b\nitem_rank = train_3[[&quot;item_name&quot;, &quot;item_cnt_day&quot;]].groupby([&quot;item_name&quot;], as_index=True).sum().sort_values(by=&quot;item_cnt_day&quot;, ascending=False)\n#ID\u3068\u3057\u30661\u304b\u3089\u632f\u308a\u76f4\u3057\u3002sort\u306f\u4e0a\u306e\u30d4\u30dc\u30c3\u30c8\u751f\u6210\u6642\u306b\u5b9f\u65bd\u305a\u307f\nitem_rank[&#39;item_rank&#39;] = pd.RangeIndex(start=1, stop=len(item_rank.index) + 1, step=1)<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3092item\u3060\u3051\u3067\u306a\u304f\u3001shop\u3068category\u3067\u3082\u7e70\u308a\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>#as_index=False\u3067\u7d50\u5408\u6642\u306b\u30a8\u30e9\u30fc(\u7406\u7531\u78ba\u8a8d\u5fc5\u8981\u3002\u3002\u3002)\nshop_rank = train_3[[&quot;shop_name&quot;, &quot;item_cnt_day&quot;]].groupby([&quot;shop_name&quot;], as_index=True).sum().sort_values(by=&quot;item_cnt_day&quot;, ascending=False)\ncategory_rank = train_3[[&quot;item_category_name&quot;, &quot;item_cnt_day&quot;]].groupby([&quot;item_category_name&quot;], as_index=True).sum().sort_values(by=&quot;item_cnt_day&quot;, ascending=False)\nshop_rank[&#39;shop_rank&#39;] = pd.RangeIndex(start=1, stop=len(shop_rank.index) + 1, step=1)\ncategory_rank[&#39;category_rank&#39;] = pd.RangeIndex(start=1, stop=len(category_rank.index) + 1, step=1)<\/code><\/pre><\/div>\n\n\n\n<p>\u305d\u308c\u305e\u308c\u306erank\u3092\u5404\u7a2ename\u3092\u30ad\u30fc\u306b\u3057\u3066\u3001train\u3068test\u306b\u7d50\u5408\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>#train, test\u306bitem, shop, category_rank\u3092\u7d50\u5408\n#left\u306b\u3057\u306a\u3044\u3068inner\u306a\u3069\u3067\u3084\u308b\u3068\u884c\u304c\u5909\u5316\u3057\u3066\u3057\u307e\u3046\u3002\ntrain_4 = pd.merge(train_3, item_rank[&quot;item_rank&quot;], how=&quot;left&quot; ,on=&quot;item_name&quot;)\ntest_4 = pd.merge(test_3, item_rank[&quot;item_rank&quot;], how=&quot;left&quot; ,on=&quot;item_name&quot;)\ntrain_5 = pd.merge(train_4, shop_rank[&quot;shop_rank&quot;], how=&quot;left&quot; ,on=&quot;shop_name&quot;)\ntest_5 = pd.merge(test_4, shop_rank[&quot;shop_rank&quot;], how=&quot;left&quot; ,on=&quot;shop_name&quot;)\ntrain_6 = pd.merge(train_5, category_rank[&quot;category_rank&quot;], how=&quot;left&quot; ,on=&quot;item_category_name&quot;)\ntest_6 = pd.merge(test_5, category_rank[&quot;category_rank&quot;], how=&quot;left&quot; ,on=&quot;item_category_name&quot;)<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u3053\u307e\u3067\u304d\u305f\u3089\u3001name\u306f\u3082\u3046\u4e0d\u8981(\u3068\u3044\u3046\u304b\u5b66\u7fd2\u6642\u306b\u30a8\u30e9\u30fc\u306b\u306a\u308b)\u3067\u3059\u306e\u3067\u3001\u6b21\u306e\u30b3\u30fc\u30c9\u3067\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>train_6 = train_6.drop([&quot;item_name&quot;, &quot;item_category_name&quot;, &quot;shop_name&quot;], axis=1)\ntest_6 = test_6.drop([&quot;item_name&quot;, &quot;item_category_name&quot;, &quot;shop_name&quot;], axis=1)<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3067\u3044\u3044\u3068\u601d\u3044\u3001\u610f\u6c17\u63da\u3005\u3068\u5b66\u7fd2\u3057\u305f\u3089\u3001NaN\u30a8\u30e9\u30fc\u3002\u3002\u3002\u3069\u3046\u3082item\u30ea\u30b9\u30c8\u306b\u306a\u3044item\u304c\u542b\u307e\u308c\u3066\u3044\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30ea\u30b9\u30c8\u306b\u306a\u3044item\u306a\u306e\u3067\u3001\u58f2\u308a\u4e0a\u3052\u5c11\u306a\u3044\u3060\u308d\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u6700\u4e0b\u4f4d\u306e\u6570\u5b57\u3092\u5165\u529b\u3059\u308b\u3053\u3068\u306b\u3002\u3061\u306a\u307f\u306b\u3053\u3053\u3092\u9069\u5f53\u306b0\u306b\u3057\u305f\u3089\u3001\u6700\u5f8c\u306e\u8a55\u4fa1\u3067RMST 20\u3068\u304b\u51fa\u3066\u304a\u3063\u305f\u307e\u3052\u307e\u3057\u305f\u3002\u3002\u30021\u304c\u4e00\u756a\u58f2\u308c\u3084\u3059\u3044\u3068\u3044\u3046\u7279\u5fb4\u91cf\u306a\u306e\u306b\u3001\u58f2\u4e0a\u306e\u5c11\u306a\u3044item\u30920\u306b\u3057\u3066\u3057\u307e\u3063\u305f\u305f\u3081\u3001\u3081\u3061\u3083\u304f\u3061\u3083\u306a\u7d50\u679c\u306b\u306a\u3063\u305f\u306e\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>train_6.describe()\u3067\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001max\u306f21807\u3067\u3057\u305f\u3002\u305d\u308c\u3088\u308a\u3082\u58f2\u4e0a\u5c11\u306a\u3044\u3060\u308d\u3046\u3068\u3044\u3046\u3053\u3068\u306721808\u3067\u7f6e\u63db\u3059\u308b\u3053\u3068\u3068\u3057\u307e\u3057\u305f\u3002(\u672c\u5f53\u306f\u78ba\u8a8d\u5fc5\u8981)<\/p>\n\n\n\n<p>null\u51e6\u7406\u306e\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plane\"><code>#test_6\u306eitem_rank\u306bnull\u304c\u3042\u308b\u3002\u2192null\u3092\u3069\u3046\u5bfe\u5fdc\u3059\u308b\u304b\uff1f max\u304c21807\u306a\u306e\u3067\u3001na\u306f21808\u3068\u914d\u7f6e\ntest_6[&quot;item_rank&quot;] = test_6[&quot;item_rank&quot;].fillna(21808)<\/code><\/pre><\/div>\n\n\n\n<p>\u624b\u6cd5\u306f\u524d\u56de\u540c\u69d8\u306b\u6c7a\u5b9a\u6728\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.tree import DecisionTreeClassifier\nfrom sklearn.model_selection import train_test_split\nX_train_lr, X_test_lr, Y_train_lr, Y_test_lr = train_test_split(X_train, Y_train, test_size=0.2)\n\ndecision_tree = DecisionTreeClassifier()\ndecision_tree.fit(X_train, Y_train)\n\nY_pred = decision_tree.predict(X_test)\nacc_decision_tree = round(decision_tree.score(X_train, Y_train) * 100, 2)\n\nprint(acc_decision_tree)<\/code><\/pre><\/div>\n\n\n\n<p>\u30e2\u30c7\u30eb\u3082\u898b\u76f4\u3059\u3079\u304d\u3060\u306a\u3068\u601d\u3044\u3064\u3064\u3082\u3001\u3068\u308a\u3042\u3048\u305a\u3053\u308c\u3067\u63d0\u51fa\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u7d50\u679c\u306f1.47967\u3068\u524d\u56de1.53867\u3060\u3063\u305f\u306e\u3067\u3001\u5c11\u3057\u6539\u5584\u3057\u3068\u308b\uff01\u9806\u4f4d\u306f7,782\u4f4d\u3002\u524d\u56de\u306f7,935\u4f4d\u306a\u306e\u3067\u300d\u4e0a\u304c\u3063\u3066\u306f\u3044\u307e\u3059\u304c\u307e\u3060\u307e\u3060\u679c\u3066\u3057\u306a\u3044\u3002\u3002\u3002<\/p>\n\n\n\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u5c11\u3057\u3060\u3051\u6539\u5584\u306f\u3057\u307e\u3057\u305f\u304c\u3001\u3082\u3046\u5c11\u3057\u9811\u5f35\u308a\u305f\u3044\u3068\u3053\u308d\u3002\u3057\u304b\u3057\u672c\u65e5\u306f\uff11\u65e5\u3042\u305f\u308a\u306e\u63d0\u51fa\u56de\u6570\u3092\u8d85\u3048\u3066\u3057\u307e\u3063\u305f\u3088\u3046(\u4e0b\u8a18\u53c2\u7167)\u3067\u3059\u3002\u3002\u3002<\/p>\n\n\n\n<p><strong>You have&nbsp;3 submissions&nbsp;remaining today.&nbsp;<\/strong>This resets&nbsp;14 hours&nbsp;from now (00:00 UTC).<\/p>\n\n\n\n<p>\u6b21\u306e\u6539\u5584\u30dd\u30a4\u30f3\u30c8\u306f\u3001\u30e9\u30f3\u30af\u3092\u30b0\u30eb\u30fc\u30d7\u5206\u3051(TOP100\u30921, \u305d\u308c\u4ee5\u4e0b\u30922\u306b\u3059\u308b)\u3059\u308b\u3068\u304b\u30021\u4f4d\u30682\u4f4d\u306e\u58f2\u4e0a\u5dee\u30683000\u4f4d\u30683001\u4f4d\u306e\u58f2\u4e0a\u5dee\u304c\u540c\u3058\u3068\u306f\u601d\u3048\u306a\u3044\u304b\u3089\u3067\u3059\u3002\u3082\u3046\u5c11\u3057\u307e\u3068\u3081\u3066\u3084\u3063\u305f\u65b9\u304c\u3044\u3044\u306e\u304b\u306a\u3068\u3002<\/p>\n\n\n\n<p>\u3082\u3046\u4e00\u3064\u306fitem_price\u3092\u4f7f\u7528\u3057\u3066\u3044\u306a\u3044\u70b9\u3067\u3059\u3002\u58f2\u308a\u4e0a\u3052\u306b\u5f71\u97ff\u3092\u4e0e\u3048\u3066\u3044\u308b\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u56de\u3067\u51fa\u6765\u308b\u304b\u306f\u3061\u3087\u3063\u3068\u308f\u304b\u3093\u306a\u3044\u3067\u3059\u304c\u3001\u3053\u3053\u307e\u3067\u76f4\u611f\u7684\u306b\u7279\u5fb4\u91cf\u3092\u9078\u3093\u3067\u304d\u307e\u3057\u305f\u304c\u3001\u6b21\u3042\u305f\u308a\u304b\u3089\u306f\u3061\u3083\u3093\u3068\u53ef\u8996\u5316\u3057\u306a\u304c\u3089\u53d6\u6368\u9078\u629e\u3092\u8003\u3048\u3066\u3044\u304d\u307e\u3059\u3002\u3042\u3068\u6c7a\u5b9a\u6728\u4ee5\u5916\u306e\u5b66\u7fd2\u3082\u624b\u3092\u4ed8\u3051\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3053\u30fc\u3057\u3060\u3051\u6539\u5584\u3057\u305f2\u56de\u76ee\u306e\u63d0\u51fa\u3067\u3057\u305f\u3002\u4eca\u9031\u4e2d\u306b\u306f\u4f55\u3068\u304b\u534a\u5206\u304f\u3089\u3044\u306e\u9806\u4f4d(4500\u4f4d\u304f\u3089\u3044)\u307e\u3067\u3044\u304f\u3088\u3046\u9811\u5f35\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306f\u5e74\u3068\u6708\u306e\u307f\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u3066\u3001shop\u3084category, item\u306e\u540d\u524d\u3092\u5168\u3066\u7834\u68c4\u3057\u3066\u4e88\u60f3\u3057\u3066\u3044\u307e\u3057\u305f\u3002\u3055\u3089\u306b\u4e88\u6e2c\u7cbe\u5ea6\u3092\u4e0a\u3052\u308b\u305f\u3081\u306b\u306f\u3053\u306e\u8fba\u308a\u306e\u60c5\u5831\u3092\u4e0a\u624b\u304f\u4f7f\u3044\u305f\u3044\u306a\u3068\u601d\u3044\u3001\u4eca\u56de\u306f\u3053\u306e\u8fba\u308a\u3092\u4e0a\u624b\u304f\u4f7f\u304a\u3046\u3068\u3057\u307e\u3057\u305f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":175,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3],"tags":[6,19,20],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.ritzcolor.net\/wp-content\/uploads\/2020\/10\/character_program_smart.png?fit=400%2C400&ssl=1","_links":{"self":[{"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=\/wp\/v2\/posts\/204"}],"collection":[{"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=204"}],"version-history":[{"count":3,"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=\/wp\/v2\/posts\/204\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=\/wp\/v2\/posts\/204\/revisions\/207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=\/wp\/v2\/media\/175"}],"wp:attachment":[{"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ritzcolor.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}