{"id":2007,"date":"2019-08-19T17:22:00","date_gmt":"2019-08-19T08:22:00","guid":{"rendered":"https:\/\/tnishimaki.com\/?p=2007"},"modified":"2025-06-12T19:23:52","modified_gmt":"2025-06-12T10:23:52","slug":"python%e3%81%ab%e3%82%88%e3%82%8b%e6%b1%ba%e5%ae%9a%e6%9c%a8%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/analysis-navi.com\/?p=2007","title":{"rendered":"Python\u306b\u3088\u308b\u6c7a\u5b9a\u6728\u5206\u6790\u306e\u5b9f\u884c\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u30c7\u30fc\u30bf\u5206\u6790\u624b\u6cd5\u306e\u3072\u3068\u3064\u300c\u6c7a\u5b9a\u6728\u5206\u6790\u300d\u3092Python\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6c7a\u5b9a\u6728\u5206\u6790\u306f\u7d4c\u55b6\u306e\u610f\u601d\u6c7a\u5b9a\u306a\u3069\u30d3\u30b8\u30cd\u30b9\u3067\u6d3b\u8e8d\u3059\u308b\u3053\u3068\u306e\u591a\u3044\u624b\u6cd5\u3067\u3059\u3002<br>\u3057\u304b\u3057\u3001Excel\u3067\u306f\u5b9f\u884c\u3067\u304d\u306a\u3044\u305f\u3081\u304b\u4e00\u822c\u7684\u306b\u7528\u3044\u3089\u308c\u3066\u3044\u308b\u30b7\u30fc\u30f3\u306f\u305d\u3053\u307e\u3067\u898b\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u3057\u304b\u3057\u3001<strong><span style=\"background-color: #87cefa;\">\u6c7a\u5b9a\u6728\u5206\u6790\u306f\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u3067\u5f37\u529b\u306a\u624b\u6cd5\u3067\u3042\u308a\u3001Python\u3092\u4f7f\u3048\u3070\u7c21\u5358\u306b\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/span><\/strong><br>\u305c\u3072\u4f7f\u3044\u3053\u306a\u3057\u3066\u9802\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7c21\u5358\u306b\u7406\u8ad6\u7d39\u4ecb<\/h2>\n\n\n\n<p>\u6c7a\u5b9a\u6728\u5206\u6790\u3068\u306f\u3001\u300c\u8981\u56e0\u30c7\u30fc\u30bf\u300d\u3068\u300c\u7d50\u679c\u30c7\u30fc\u30bf\u300d\u304c\u30da\u30a2\u3067\u5b58\u5728\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u7528\u3044\u3089\u308c\u308b\u3001\u3044\u308f\u3086\u308b<strong><span style=\"background-color: #87cefa;\">\u300c\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u300d\u306e\u3072\u3068\u3064<\/span><\/strong>\u3067\u3059\u3002<br>\u56de\u5e30\u5206\u6790\u3068\u4e00\u7dd2\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<p>\u305f\u3060\u3001<strong><span style=\"background-color: #87cefa;\">\u56de\u5e30\u5206\u6790\u306f\u300c\u58f2\u4e0a\u91d1\u984d=1.2\u00d7\u6c17\u6e29+100\u300d\u306e\u3088\u3046\u306b\u30c7\u30fc\u30bf\u306e\u95a2\u4fc2\u6027\u3092\u6570\u5f0f\u3067\u8868\u308f\u305b\u308b<\/span><\/strong>\u306e\u3067\u3059\u304c\u3001\u6c7a\u5b9a\u6728\u5206\u6790\u3067\u306f\u305d\u308c\u306f\u3067\u304d\u307e\u305b\u3093\u3002<br>\u305d\u306e\u4ee3\u308f\u308a\u3001<strong><span style=\"background-color: #87cefa;\">\u6c7a\u5b9a\u6728\u5206\u6790\u306f\u300c\u6c17\u6e29\u304c30\u5ea6\u4ee5\u4e0a\u306e\u5834\u5408\u306f\u58f2\u4e0a\u91d1\u984d400\u5186\u300130\u5ea6\u672a\u6e80\u306e\u5834\u5408\u306f200\u5186\u300d\u306e\u3088\u3046\u306b\u5834\u5408\u5206\u3051\u306e\u95a2\u4fc2\u6027\u3092\u8868\u3059<\/span><\/strong>\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u3055\u3089\u306b\u3001\u300c\u6c17\u6e2930\u5ea6\u4ee5\u4e0a\u3067\u5929\u6c17\u304c\u96e8\u306e\u5834\u5408\u306f\u30fb\u30fb\u30fb\u300d\u306a\u3069\u3001\u3069\u3093\u3069\u3093\u968e\u5c64\u3092\u6df1\u304f\u3057\u3066\u3044\u304f\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u3057\u3066\u3001\u6c7a\u5b9a\u6728\u5206\u6790\u306e\u51fa\u529b\u306f\u4e00\u822c\u7684\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u56f3\u3067\u8868\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/84bc1b516b99fdb7f17c04f9c0ca8a37-1024x662.png\" alt=\"\" class=\"wp-image-2140\" srcset=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/84bc1b516b99fdb7f17c04f9c0ca8a37-1024x662.png 1024w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/84bc1b516b99fdb7f17c04f9c0ca8a37-618x400.png 618w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/84bc1b516b99fdb7f17c04f9c0ca8a37-300x194.png 300w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/84bc1b516b99fdb7f17c04f9c0ca8a37-768x497.png 768w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/84bc1b516b99fdb7f17c04f9c0ca8a37.png 1039w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n\n\n\n\n<p>\u4e00\u672c\u306e\u679d\u304c\u679d\u5206\u304b\u308c\u3057\u3066\u3086\u304f\u6728\u306e\u3088\u3046\u306a\u69cb\u9020\u3092\u6301\u3064\u3053\u3068\u304b\u3089\u3001\u3053\u3046\u3044\u3063\u305f\u56f3\u3092<strong>\u300c\u6c7a\u5b9a\u6728\u300d<\/strong>\u3068\u547c\u3073\u3001\u305d\u308c\u3092\u7528\u3044\u305f\u30c7\u30fc\u30bf\u5206\u6790\u3092<strong>\u300c\u6c7a\u5b9a\u6728\u5206\u6790\u300d<\/strong>\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u56de\u5e30\u5206\u6790\u3068\u6c7a\u5b9a\u6728\u5206\u6790\u306e\u3069\u3061\u3089\u304c\u512a\u308c\u308b\u304b\u306f\u6642\u3068\u5834\u5408\u306b\u3088\u308a\u307e\u3059\u3002<br><strong><span style=\"background-color: #87cefa;\">\u300c\u30af\u30e9\u30b9\u306e\u4e88\u6e2c\u304c\u3057\u305f\u3044\u6642\u306f\u6c7a\u5b9a\u6728\u3001\u6570\u5024\u306e\u4e88\u6e2c\u304c\u3057\u305f\u3044\u6642\u306f\u56de\u5e30\u5206\u6790\u300d\u3068\u3044\u3046\u306e\u304c\u4e00\u822c\u7684\u306a\u6c17\u3082\u3057\u307e\u3059<\/span><\/strong>\u304c\u3001\u3069\u3061\u3089\u306e\u624b\u6cd5\u3067\u3082\u30af\u30e9\u30b9\u4e88\u6e2c\u3082\u6570\u5024\u4e88\u6e2c\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5206\u985e\u6728\u3068\u56de\u5e30\u6728<\/h3>\n\n\n\n<p>\u3055\u3089\u306b\u6c7a\u5b9a\u6728\u306f<strong>\u300c\u5206\u985e\u6728\u300d<\/strong>\u3068<strong>\u300c\u56de\u5e30\u6728\u300d<\/strong>\u306b\u5206\u3051\u3089\u308c\u307e\u3059\u3002<br>\u307b\u3068\u3093\u3069\u540c\u3058\u306a\u306e\u3067\u3059\u304c\u3001<strong><span style=\"background-color: #87cefa;\">\u300c\u5206\u985e\u6728\u300d\u306f\u30af\u30e9\u30b9\u3092\u4e88\u6e2c\u3057\u305f\u3044\u6642\u3002\u300c\u56de\u5e30\u6728\u300d\u306f\u6570\u5024\u3092\u4e88\u6e2c\u3057\u305f\u3044\u6642<\/span><\/strong>\u306b\u7528\u3044\u307e\u3059\u3002<br>\u305f\u3068\u3048\u3070\u5546\u54c1\u304c\u300c\u58f2\u308c\u308b\u304b\u3001\u58f2\u308c\u306a\u3044\u304b\u300d\u3092\u8abf\u3079\u305f\u3044\u6642\u306f\u5206\u985e\u6728\u3001\u300c\u3044\u304f\u3089\u58f2\u308c\u308b\u304b\u300d\u3092\u8abf\u3079\u305f\u3044\u6642\u306f\u56de\u5e30\u6728\u3001\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u306f\u30c7\u30fc\u30bf\u304c\u6c7a\u307e\u3063\u3066\u3044\u308c\u3070\u5fc5\u7136\u7684\u306b\u6c7a\u5b9a\u3059\u308b\u90e8\u5206\u306a\u306e\u3067\u3001\u3069\u3061\u3089\u3092\u4f7f\u3046\u304b\u3067\u60a9\u3080\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python\u306b\u3088\u308b\u6c7a\u5b9a\u6728\u5206\u6790\u306e\u5b9f\u884c<\/h2>\n\n\n\n<p>Python\u3067\u6c7a\u5b9a\u6728\u5206\u6790\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306f\u5e7e\u3064\u304b\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u30ad\u30ec\u30a4\u306a\u6c7a\u5b9a\u6728\u304c\u4f5c\u308c\u308b<strong>\u300cdtreeviz\u300d<\/strong>\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<br>\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u5206\u985e\u6728\u3068\u56de\u5e30\u6728\u3001\u3069\u3061\u3089\u3082\u4f5c\u6210\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f<\/h3>\n\n\n\n<p>\u5206\u985e\u6728\u306b\u306f<a href=\"https:\/\/analysis-navi.com\/?p=1229\">\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30\u5206\u6790<\/a>\u306e\u969b\u306b\u7528\u3044\u305f\u30c7\u30fc\u30bf\u3068\u540c\u3058\u3082\u306e\u3092\u4f7f\u3044\u307e\u3059\u3002<br>\u3042\u308b\u30c4\u30fc\u30eb\u306e\u5229\u7528\u8005\u60c5\u5831\u304b\u3089\u3001\u305d\u306e\u5229\u7528\u8005\u304c\u30e6\u30fc\u30b6\u767b\u9332\u3057\u3066\u304f\u308c\u305f\u304b\u3069\u3046\u304b\u3092\u4e00\u89a7\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3067\u3059\u3002<br>\u30c7\u30fc\u30bf\u306e\u5f62\u5f0f\u306f\u4ee5\u4e0b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"674\" height=\"912\" src=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/cd6dc449dec4cbef1d089ce9d80c5958.png\" alt=\"\" class=\"wp-image-2145\" srcset=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/cd6dc449dec4cbef1d089ce9d80c5958.png 674w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/cd6dc449dec4cbef1d089ce9d80c5958-296x400.png 296w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/cd6dc449dec4cbef1d089ce9d80c5958-222x300.png 222w\" sizes=\"(max-width: 674px) 100vw, 674px\" \/><\/figure>\n\n\n\n\n\n\n\n<p>\u56de\u5e30\u6728\u306b\u306f<a href=\"https:\/\/analysis-navi.com\/?p=1930\">\u91cd\u56de\u5e30\u5206\u6790<\/a>\u306e\u969b\u306b\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u3068\u540c\u3058\u3082\u306e\u3092\u4f7f\u3044\u307e\u3059\u3002<br>\u6c17\u6e29\u3084\u5929\u6c17\u306e\u60c5\u5831\u3068\u3001\u305d\u306e\u65e5\u306e\u30a2\u30a4\u30b9\u30af\u30ea\u30fc\u30e0\u306e\u58f2\u4e0a\u3092\u4e00\u89a7\u5316\u3057\u305f\u30c7\u30fc\u30bf\u3067\u3059\u3002<br>\u30c7\u30fc\u30bf\u306e\u5f62\u5f0f\u306f\u4ee5\u4e0b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"662\" height=\"896\" src=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/2dc814302539475c36bd3bc07b27096d.png\" alt=\"\" class=\"wp-image-2144\" srcset=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/2dc814302539475c36bd3bc07b27096d.png 662w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/2dc814302539475c36bd3bc07b27096d-296x400.png 296w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/2dc814302539475c36bd3bc07b27096d-222x300.png 222w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><\/figure>\n\n\n\n\n\n\n\n<p>\u306a\u304a\u3001dtreeviz\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u306f\u65e5\u672c\u8a9e\u306e\u8868\u793a\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u5217\u540d\u306e\u307f\u82f1\u8a9e\u306b\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306bcsv\u3092\u8aad\u307f\u8fbc\u307f\u3001X(\u5f93\u5c5e\u5909\u6570)\u306e\u5217\u3068y(\u76ee\u7684\u5909\u6570)\u306e\u5217\u306b\u5206\u96e2\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import numpy as np\nimport pandas as pd\n\n#CSV\u8aad\u307f\u8fbc\u307f\ndf = pd.read_csv(\"[\u30d5\u30a1\u30a4\u30eb\u540d]\")\n\n#\u76ee\u7684\u5909\u6570\u540d\u306e\u6307\u5b9a\ny_name = \"sales\"\n\n#\u5f93\u5c5e\u5909\u6570\uff08\u4f7f\u7528\u5217\uff09\u306e\u9078\u629e\nX_name = [\"temperature\",\"price\",\"rainy\"]\n\n#X\u3068y\u306b\u5206\u96e2\nX_train = df[X_name]\ny_train = df[y_name]<\/pre>\n\n\n\n<p>\u76ee\u7684\u5909\u6570\u540d\u3068\u5f93\u5c5e\u5909\u6570\u540d\u306f\u30c7\u30fc\u30bf\u306b\u5408\u308f\u305b\u3066\u5b9a\u7fa9\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>https:\/\/analysis-navi.com\/?p=1229<br>https:\/\/analysis-navi.com\/?p=1930<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5206\u985e\u6728\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u307e\u305a\u306f\u5206\u985e\u6728\u3092\u7528\u3044\u3066\u6c7a\u5b9a\u6728\u5206\u6790\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from sklearn.datasets import *\nfrom sklearn import tree\nfrom dtreeviz.trees import *\nimport graphviz\n\ndtree = tree.DecisionTreeClassifier(max_depth=2)\ndtree.fit(X_train, y_train)<\/pre>\n\n\n\n<p>\u5206\u985e\u6728\u3092\u4f5c\u6210\u3059\u308b\u6642\u306f\u300cDecisionTree<strong>Classifier<\/strong>\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u3044\u307e\u3059\u3002<br>\u5f15\u6570\u306e\u300cmax_depth\u300d\u306f\u6728\u306e\u6df1\u3055\u3092\u8868\u3057\u307e\u3059\u3002<br>\u4eca\u56de\u306f\u30c7\u30fc\u30bf\u306e\u6570\u3082\u7279\u5fb4\u91cf\u306e\u6570\u3082\u5c11\u306a\u3044\u306e\u3067\u3001\u6df1\u3055\u306f\u5c11\u306a\u3081\u306b2\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"swell-block-capbox cap_box is-style-inner\"><div class=\"cap_box_ttl\"><span>\u88dc\u8db3<\/span><\/div><div class=\"cap_box_content\">\n<p>\u6c7a\u5b9a\u6728\u5206\u6790\u306b\u304a\u3051\u308b\u6728\u306e\u6df1\u3055\uff08max_depth\uff09\u306f2\u301c5\u7a0b\u5ea6\u306b\u53ce\u3081\u305f\u307b\u3046\u304c\u3001\u89e3\u91c8\u3057\u3084\u3059\u3044\u7d50\u679c\u304c\u5f97\u3089\u308c\u308b\u5834\u5408\u304c\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<\/div><\/div>\n\n\n\n<p>\u7d9a\u3044\u3066\u306f\u3001\u7d50\u679c\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">viz = dtreeviz(dtree,X_train,y_train,\n               target_name='registration',\n               feature_names=X_name,\n               class_names=[\"Not Register\",\"Register\"],\n               )\n\nviz<\/pre>\n\n\n\n<p>\u6700\u5f8c\u306f\u300cviz\u300d\u3068\u3059\u308b\u3060\u3051\u3067\u7d50\u679c\u8868\u793a\u3067\u304d\u307e\u3059\u3002<br>\u307e\u305f\u3001<strong><span style=\"background-color: #87cefa;\">\u5206\u985e\u6728\u306e\u5834\u5408\u306f\u300cclass_names\u300d\u3068\u3044\u3046\u5f15\u6570\u3092\u5b9a\u7fa9\u3057\u306a\u3044\u3068\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3002<\/span><\/strong><br>\u305d\u306e\u540d\u306e\u901a\u308a\u3001\u3053\u3053\u306b\u306f\u30af\u30e9\u30b9\u540d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br>\u4eca\u56de\u306e\u5834\u5408\u3001\u300c0\u300d\u304c\u300c\u767b\u9332\u3057\u306a\u3044(Not Register)\u300d\u3001\u300c1\u300d\u304c\u300c\u767b\u9332\u3059\u308b(Register)\u300d\u306a\u306e\u3067\u3001\u305d\u308c\u3092\u30af\u30e9\u30b9\u540d\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3067\u306f\u3001\u7d50\u679c\u3092\u898b\u3066\u307f\u307e\u3059\u3002<br><img decoding=\"async\" src=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/5098a1da97bdecbce1e62d665b4f677c.png\" alt=\"\" width=\"358\" height=\"332\" class=\"alignnone size-full wp-image-2152\" srcset=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/5098a1da97bdecbce1e62d665b4f677c.png 716w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/5098a1da97bdecbce1e62d665b4f677c-431x400.png 431w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/5098a1da97bdecbce1e62d665b4f677c-300x278.png 300w\" sizes=\"(max-width: 358px) 100vw, 358px\" \/><\/p>\n\n\n\n<p>\u307e\u305a\u3001<strong><span style=\"background-color: #87cefa;\">\u300cstay time\u300d\u304c44.5\u79d2\u3092\u4e0a\u56de\u308b\u304b\u3069\u3046\u304b<\/span><\/strong>\u3067\u5834\u5408\u5206\u3051\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\u4e0b\u56de\u308b\u5834\u5408\u306f11\u4eba\u4e2d11\u4eba\u3001\u8ab0\u3082\u767b\u9332\u3057\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3059\u3002<br>\u4e0a\u56de\u308b\u5834\u5408\u306f\u30012\u968e\u5c64\u76ee\u306b\u884c\u304d\u307e\u3059\u3002<br>\u6b21\u306f<strong><span style=\"background-color: #87cefa;\">\u300cstudent\u300d\u3001\u3059\u306a\u308f\u3061\u5b66\u751f\u304b\u3069\u3046\u304b<\/span><\/strong>\u3067\u5834\u5408\u5206\u3051\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\u3053\u308c\u304c\u300c0\u300d\u3001\u3064\u307e\u308a\u5b66\u751f\u3067\u306a\u3044\u5834\u5408\u306f3\u5272\u7a0b\u5ea6\u304c\u767b\u9332\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u3067\u3059\u3002<br>\u9006\u306b\u300c1\u300d\u3001\u3064\u307e\u308a\u5b66\u751f\u306e\u5834\u5408\u306f7\u5272\u7a0b\u5ea6\u304c\u767b\u9332\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3064\u307e\u308a\u3001\u4eca\u56de\u306e\u5834\u5408<strong><span style=\"background-color: #87cefa;\">\u300c\u6ede\u5728\u6642\u9593\u304c\u9577\u3044\u5b66\u751f\u300d\u304c\u30e6\u30fc\u30b6\u767b\u9332\u3057\u3066\u304f\u308c\u308b<\/span><\/strong>\u3088\u3046\u3060\u3068\u3001\u3053\u306e\u56f3\u304b\u3089\u8aad\u307f\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u3001\u6700\u5f8c\u306b\u300cviz.save(&#8220;\u301c.svg&#8221;)\u300d\u3068\u3059\u308c\u3070\u51fa\u529b\u3055\u308c\u305f\u6c7a\u5b9a\u6728\u306e\u753b\u50cf\u3092\u4fdd\u5b58\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>(svg\u5f62\u5f0f\u4ee5\u5916\u306e\u51fa\u529b\u3092\u884c\u3046\u306b\u306f\u8a2d\u5b9a\u304c\u5fc5\u8981\u306a\u3088\u3046\u3067\u3059\u3002)<\/p>\n\n\n\n<p>\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30\u5206\u6790\u3067\u3082\u300c\u6ede\u5728\u6642\u9593\u300d\u3068\u300c\u5b66\u751f\u304b\u3069\u3046\u304b\u300d\u306e2\u3064\u304c\u91cd\u8981\u3068\u51fa\u3066\u3044\u307e\u3057\u305f\u306e\u3067\u3001\u4f3c\u305f\u7d50\u679c\u304c\u5f97\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u56de\u5e30\u6728\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u7d9a\u3044\u3066\u306f\u56de\u5e30\u6728\u306b\u3088\u308b\u6c7a\u5b9a\u6728\u5206\u6790\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from sklearn.datasets import *\nfrom sklearn import tree\nfrom dtreeviz.trees import *\nimport graphviz\n\ndtree = tree.DecisionTreeRegressor(max_depth=2)\ndtree.fit(X_train, y_train)<\/pre>\n\n\n\n<p>\u56de\u5e30\u6728\u3092\u4f5c\u6210\u3059\u308b\u6642\u306f\u300cDecisionTree<strong>Regressor<\/strong>\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u3044\u307e\u3059\u3002<br>\u5206\u985e\u6728\u3068\u540c\u3058\u304f\u3001max_depth=2\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7d50\u679c\u306e\u8868\u793a\u306f\u4ee5\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">viz = dtreeviz(dtree,X_train,y_train,\n               target_name='sales',\n               feature_names=X_name,\n               )\n\nviz<\/pre>\n\n\n\n<p><strong><span style=\"background-color: #87cefa;\">\u56de\u5e30\u6728\u306b\u304a\u3044\u3066\u306f\u300cclass_names\u300d\u3092\u5b9a\u7fa9\u3059\u308b\u5fc5\u8981\u6027\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/span><\/strong><\/p>\n\n\n\n<p>\u4ee5\u4e0a\u3092\u5b9f\u884c\u3059\u308b\u3068\u30fb\u30fb\u30fb\u3002<br><img decoding=\"async\" src=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/bb25076d6ed4e27ca2cf5962e607c6bf.png\" alt=\"\" width=\"486\" height=\"362\" class=\"alignnone size-full wp-image-2153\" srcset=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/bb25076d6ed4e27ca2cf5962e607c6bf.png 972w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/bb25076d6ed4e27ca2cf5962e607c6bf-537x400.png 537w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/bb25076d6ed4e27ca2cf5962e607c6bf-300x223.png 300w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/bb25076d6ed4e27ca2cf5962e607c6bf-768x572.png 768w\" sizes=\"(max-width: 486px) 100vw, 486px\" \/><\/p>\n\n\n\n<p>\u307e\u305a\u306f\u300ctemperature\u300d\u3001\u3064\u307e\u308a<strong><span style=\"background-color: #87cefa;\">\u6e29\u5ea6\u304c19.38\u5ea6\u3092\u4e0a\u56de\u308b\u304b\u3069\u3046\u304b<\/span><\/strong>\u3067\u5206\u5c90\u304c\u3042\u308a\u307e\u3059\u3002<br>\u7d9a\u3044\u30662\u6bb5\u76ee\u3082\u300ctemperature\u300d\u306e\u3088\u3046\u3067\u3059\u3002<br>\u7d50\u5c40\u3001<strong><span style=\"background-color: #87cefa;\">\u6e29\u5ea6\u30924\u30d1\u30bf\u30fc\u30f3\u306b\u5206\u3051\u308c\u3070\u826f\u304f\u3001price\u3084rainy\u306f\u63a8\u5b9a\u306b\u6b86\u3069\u95a2\u4fc2\u306a\u3044<\/span><\/strong>\u3068\u3044\u3046\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u3057\u305f\u3002<br>\u3053\u306e\u3088\u3046\u306b\u3001<strong><span style=\"background-color: #87cefa;\">\u5225\u306e\u968e\u5c64\u3067\u540c\u3058\u7279\u5fb4\u91cf\u304c\u4f7f\u308f\u308c\u308b\u5834\u5408\u3082\u3042\u308a\u307e\u3059\u3002<\/span><\/strong><\/p>\n\n\n\n<p>\u3053\u308c\u306f\u91cd\u56de\u5e30\u5206\u6790\u306e\u7d50\u679c\u3068\u306f\u9055\u3044\u307e\u3059\u304c\u3001\u304a\u305d\u3089\u304f\u300ctemperature\u300d\u3068\u300crainy\u300d\u81ea\u4f53\u306e\u76f8\u95a2\u304c\u9ad8\u3044\u306e\u3067\u3001\u7247\u65b9\u3092\u898b\u3066\u304a\u3051\u3070\u5341\u5206\u3068\u898b\u306a\u3055\u308c\u305f\u306e\u3067\u306f\u7121\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u672a\u77e5\u30c7\u30fc\u30bf\u306e\u4e88\u6e2c<\/h3>\n\n\n\n<p>\u672a\u77e5\u30c7\u30fc\u30bf\u306e\u63a8\u6e2c\u3082\u884c\u3063\u3066\u307f\u307e\u3059\u3002<br>\u3053\u308c\u306b\u306fdtreeviz\u306b\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6c7a\u5b9a\u6728\u3092\u63cf\u753b\u3059\u308b\u6642\u306b\u3001<strong><span style=\"background-color: #87cefa;\">\u65b0\u305f\u306b\u300cX\u300d\u3068\u3044\u3046\u5f15\u6570\u3092\u5b9a\u7fa9<\/span><\/strong>\u3057\u307e\u3059\u3002<br>\u3053\u308c\u306b\u306f\u3001\u7279\u5fb4\u91cf\u306e\u6570\u5024\u3092\u6307\u5b9a\u3057\u305f\u30ea\u30b9\u30c8\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305f\u3068\u3048\u3070\u3001\u4e0a\u306e\u5206\u985e\u6728\u306e\u4f8b\u3092\u7528\u3044\u3001\u6027\u5225=\u7537\u6027(0)\u3001\u5b66\u751f(1)\u3001\u6ede\u5728\u6642\u9593(50\u79d2)\u306e\u5834\u5408\u306f\u3069\u3046\u306a\u308b\u304b\u8abf\u3079\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">viz = dtreeviz(dtree,X_train,y_train,\n               target_name='sales',\n               feature_names=X_name,\n               class_names=[\"Not Register\",\"Register\"],\n               X=[0,1,50]\n               )<\/pre>\n\n\n\n<p>\u5f15\u6570X\u306b\u8abf\u3079\u305f\u3044\u6570\u5024\u3092\u5165\u529b\u3057\u3066\u304a\u304f\u3060\u3051\u3067\u3059\u3002<br>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u30fb\u30fb\u30fb\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"750\" height=\"846\" src=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/13a3da504c5e76f190f09080d1e27dd6.png\" alt=\"\" class=\"wp-image-2154\" srcset=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/13a3da504c5e76f190f09080d1e27dd6.png 750w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/13a3da504c5e76f190f09080d1e27dd6-355x400.png 355w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2019\/08\/13a3da504c5e76f190f09080d1e27dd6-266x300.png 266w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u30aa\u30ec\u30f3\u30b8\u8272\u306e\u67a0\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<br><strong><span style=\"background-color: #87cefa;\">\u7537\u6027\u306e\u5b66\u751f\u3067\u6ede\u5728\u6642\u9593\u304c50\u79d2\u3042\u308c\u3070\u3001\u30e6\u30fc\u30b6\u767b\u9332\u53ef\u80fd\u6027\u304c70%\u307b\u3069\u3067\u3042\u308b<\/span><\/strong>\u3068\u3072\u3068\u76ee\u3067\u5206\u304b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u3001Python\u3092\u7528\u3044\u305f\u6c7a\u5b9a\u6728\u5206\u6790\u306e\u5b9f\u884c\u65b9\u6cd5\u3067\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c7\u30fc\u30bf\u5206\u6790\u624b\u6cd5\u306e\u3072\u3068\u3064\u300c\u6c7a\u5b9a\u6728\u5206\u6790\u300d\u3092Python\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002 \u6c7a\u5b9a\u6728\u5206\u6790\u306f\u7d4c\u55b6\u306e\u610f\u601d\u6c7a\u5b9a\u306a\u3069\u30d3\u30b8\u30cd\u30b9\u3067\u6d3b\u8e8d\u3059\u308b\u3053\u3068\u306e\u591a\u3044\u624b\u6cd5\u3067\u3059\u3002\u3057\u304b\u3057\u3001Excel\u3067\u306f\u5b9f\u884c\u3067\u304d\u306a\u3044\u305f\u3081\u304b\u4e00\u822c\u7684\u306b\u7528\u3044\u3089\u308c\u3066\u3044\u308b\u30b7\u30fc\u30f3\u306f\u305d\u3053\u307e\u3067\u898b\u307e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5079,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"swell_btn_cv_data":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[129],"tags":[101,134],"class_list":["post-2007","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-study","tag-ml","tag-python"],"_links":{"self":[{"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/posts\/2007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2007"}],"version-history":[{"count":20,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/posts\/2007\/revisions"}],"predecessor-version":[{"id":5157,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/posts\/2007\/revisions\/5157"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/media\/5079"}],"wp:attachment":[{"href":"https:\/\/analysis-navi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}