{"id":2753,"date":"2020-03-24T22:50:35","date_gmt":"2020-03-24T13:50:35","guid":{"rendered":"https:\/\/analysis-navi.com\/?p=2753"},"modified":"2025-06-08T19:09:55","modified_gmt":"2025-06-08T10:09:55","slug":"python%e3%81%ab%e3%82%88%e3%82%8b%e5%8b%be%e9%85%8d%e3%83%96%e3%83%bc%e3%82%b9%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0gbdt%e3%81%ae%e5%ae%9f%e8%a1%8c%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/analysis-navi.com\/?p=2753","title":{"rendered":"Python\u306b\u3088\u308b\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0(GBDT)\u306e\u5b9f\u884c\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5<strong>\u300c\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u300d<\/strong>\u306f\u3001\u30c7\u30fc\u30bf\u5206\u6790\u30b3\u30f3\u30da\u30c6\u30a3\u30b7\u30e7\u30f3<strong>\u300cKaggle\u300d<\/strong>\u3067\u826f\u3044\u6027\u80fd\u3092\u51fa\u3059\u4e8b\u304c\u591a\u304f\u3001\u4e00\u6c17\u306b\u591a\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u500b\u4eba\u306e\u4e3b\u89b3\u3068\u3057\u3066\u3082<strong><span style=\"background-color: #87cefa;\">\u300c\u6570\u91cf\u30c7\u30fc\u30bf\u5206\u6790\u306b\u304a\u3051\u308b\u6700\u5f37\u306e\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5\u300d<\/span><\/strong>\u3067\u306f\u306a\u3044\u304b\u3068\u8003\u3048\u3066\u304a\u308a(\u5f8c\u8ff0\u3057\u307e\u3059)\u3001\u6a5f\u68b0\u5b66\u7fd2\u306e\u624b\u6cd5\u306b\u8ff7\u3063\u305f\u3089\u4f55\u306f\u3068\u3082\u3042\u308c\u9069\u7528\u3057\u3066\u307f\u305f\u3044\u624b\u6cd5\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001\u305d\u3093\u306a\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u3092Python\u3067\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u3068\u306f<\/h2>\n\n\n\n<p>\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0(Gradient Boosting Decision Tree, GBDT)\u306f<strong>\u6559\u5e2b\u3042\u308a\u5b66\u7fd2<\/strong>\u306e\u3072\u3068\u3064\u3067\u3059\u3002<\/p>\n\n\n\n<p>\b\u65b9\u5f0f\u3068\u3057\u3066\u306f<strong><span style=\"background-color: #87cefa;\">\u6c7a\u5b9a\u6728\u3092\u6ca2\u5c71\u4f5c\u3063\u3066\u3001\u305d\u308c\u3089\u306e\u7d50\u679c\u3092\u7dcf\u5408\u7684\u306b\u8a55\u4fa1<\/span><\/strong>\u3057\u307e\u3059\u3002<br><a href=\"https:\/\/analysis-navi.com\/?p=2522\">\u30e9\u30f3\u30c0\u30e0\u30d5\u30a9\u30ec\u30b9\u30c8<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u30e9\u30f3\u30c0\u30e0\u30d5\u30a9\u30ec\u30b9\u30c8\u306f\b\u4f7f\u3046\u30c7\u30fc\u30bf\u3084\u4f7f\u3046\u5909\u6570\u3092\u3061\u3087\u3063\u3068\u305a\u3064\u5909\u3048\u305f\u6c7a\u5b9a\u6728\u3092\u305f\u304f\u3055\u3093\u4f5c\u308a\u3001\u6700\u7d42\u7684\u306b\u591a\u6570\u6c7a\u3092\u53d6\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e00\u65b9\u3001\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u306f\u307e\u305a\u4ee3\u8868\u3068\u306a\u308b\u6c7a\u5b9a\u6728\u3092\u4f5c\u6210\u3057\u3066\u3001\u305d\u306e\u7d50\u679c\u3092\u8e0f\u307e\u3048\u3066\u6728\u3092\u5c11\u3057\u305a\u3064\u66f4\u65b0\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br>\u6700\u7d42\u7d50\u679c\u3092<strong><span style=\"background-color: #87cefa;\">\u305f\u304f\u3055\u3093\u306e\u6c7a\u5b9a\u6728\u304b\u3089\u7dcf\u5408\u7684\u306b\u8a55\u4fa1\u3059\u308b\u3053\u3068\u306f\u540c\u3058\u3067\u3059\u304c\u3001\u305d\u308c\u304c\u300c\u4e26\u5217\u300d\u7684\u304b\u3001\u300c\u76f4\u5217\u300d\u7684\u304b\u3001\u3068\u3044\u3046\u6240\u304c\u5927\u304d\u306a\u9055\u3044\u3067\u3059\u3002<\/span><\/strong><\/p>\n\n\n\n<p>\u6c7a\u5b9a\u6728\u7cfb\u306e\u624b\u6cd5\u306e\u4fbf\u5229\u306a\u3068\u3053\u308d\u306f\u3001\u305d\u3082\u305d\u3082<strong><span style=\"background-color: #87cefa;\">\u5024\u306e\u5927\u5c0f\u95a2\u4fc2\u306b\u3057\u304b\u6ce8\u76ee\u3057\u306a\u3044\u306e\u3067\u3001\u6570\u5024\u306e\u6a19\u6e96\u5316\u30fb\u6b63\u898f\u5316\u306a\u3069\u306e\u5909\u63db\u304c\u4e0d\u8981<\/span><\/strong>\u306a\u3053\u3068\u3002<br>\u305d\u3057\u3066\u3001<strong><span style=\"background-color: #87cefa;\">\u30c7\u30fc\u30bf\u306b\u6b20\u640d\u5024\u304c\u3042\u3063\u3066\u3082\u305d\u306e\u307e\u307e\u8a08\u7b97\u3067\u304d\u308b<\/span><\/strong>\u3053\u3068\u3002\b<br>\u52a0\u3048\u3066\u3001<strong><span style=\"background-color: #87cefa;\">\u56de\u5e30\u554f\u984c\u3082\u5206\u985e\u554f\u984c\u3082\u89e3\u304f\u4e8b\u304c\u3067\u304d\u308b<\/span><\/strong>\u3053\u3068\u3002<br>\u305d\u3057\u3066\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u306f\u3001\u305d\u308c\u306b\u52a0\u3048\u3066\u5927\u3057\u305f\u5b66\u7fd2\u6642\u9593\u3082\u639b\u304b\u3089\u305a\u3001\u9ad8\u3044\u6027\u80fd\u304c\u51fa\u308b\u4e8b\u304c\u591a\u3044\u3068\u3044\u3046\u7d20\u6674\u3089\u3057\u3044\u624b\u6cd5\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3064\u307e\u308a\u3001<strong><span style=\"background-color: #87cefa;\">\u30c7\u30fc\u30bf\u3092\u305d\u3093\u306a\u306b\u3044\u3058\u3089\u306a\u304f\u3066\u3082\u3001\u305d\u308c\u306a\u308a\u306e\u3082\u306e\u304c\u51fa\u6765\u3066\u3057\u307e\u3046\u4e8b\u304c\u591a\u3044<\/span><\/strong>\u306e\u3067\u3059\u3002<br>\u7121\u8ad6\u3001\u305d\u3053\u304b\u3089\u30cf\u30a4\u30d1\u30fc\u30d1\u30e9\u30e1\u30fc\u30bf\u8abf\u6574\u3084\u7279\u5fb4\u91cf\u30a8\u30f3\u30b8\u30cb\u30a2\u30ea\u30f3\u30b0\u3092\u884c\u3046\u3053\u3068\u306b\u3088\u308a\u66f4\u306b\u6027\u80fd\u306f\u4f38\u3073\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30fb\u30fb\u30fb\u3068\u306f\u3044\u3048\u3001\u3044\u3064\u306a\u3093\u6642\u3067\u3082\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u304c\u512a\u308c\u308b\u3068\u3044\u3046\u8a33\u3067\u3082\u3042\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u4ed6\u306e\u624b\u6cd5\u3068\u306e\u6027\u80fd\u6bd4\u8f03\u306a\u3069\u306f\u76f8\u5909\u308f\u3089\u305a\u5fc5\u8981\u3067\u3059\u3002<br>\u3042\u304f\u307e\u3067\u3001<strong><span style=\"background-color: #87cefa;\">\u300c\u3053\u308c\u3060\u3051\u77e5\u3063\u3066\u3044\u308c\u3070\u826f\u3044\u624b\u6cd5\u300d\u3068\u3044\u3046\u610f\u5473\u3067\u306f\u306a\u304f\u3001\u300c\u307e\u305a\u9069\u7528\u3057\u3066\u307f\u305f\u3044\u624b\u6cd5\u300d\u3067\u3042\u308b<\/span><\/strong>\u3068\u3054\u7406\u89e3\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python\u306b\u3088\u308b\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u306e\u5b9f\u88c5<\/h2>\n\n\n\n<p>\u3055\u3066\u3001\u4e0a\u8ff0\u3057\u305f\u3088\u3046\u306b\u975e\u5e38\u306b\u5f37\u529b\u306a\u624b\u6cd5\u306a\u306e\u3067\u3059\u304c\u3001\u5b9f\u88c5\u306f\u975e\u5e38\u306b\u7c21\u5358\u3067\u3059\u3002<br>\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u3092\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u306f<strong>XGBoost<\/strong>\u3001<strong>lightgbm<\/strong>\u3001<strong>catboost<\/strong>\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u6700\u3082\u4f7f\u7528\u4f8b\u304c\u591a\u3044\u3068\u601d\u308f\u308c\u308bXGBoost\u3092\u7528\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c7\u30fc\u30bf\u306e\u6e96\u5099<\/h3>\n\n\n\n<p>\u4eca\u56de\u306f\u3001scikit-learn\u306e\u30b5\u30f3\u30d7\u30eb\u30c7\u30fc\u30bf\u306e\u3046\u3061\u306e1\u3064<strong>breast_cancer<\/strong>\u3092\u7528\u3044\u3066\u3001\u300c\u4e73\u304c\u3093\u304b\u3001\u305d\u3046\u3067\u306a\u3044\u304b\u300d\u306e\u4e88\u6e2c\u3092\u3055\u305b\u3066\u307f\u307e\u3059\u3002<br>\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u90e8\u5206\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f\nfrom sklearn.datasets import load_breast_cancer\nimport numpy as np\n\ncancer = load_breast_cancer()\nX = cancer.data\ny = cancer.target\nX_cols = cancer.feature_names<\/pre>\n\n\n\n<p><strong>X<\/strong>\u304c\u8aac\u660e\u5909\u6570\u306e2\u6b21\u5143\u30ea\u30b9\u30c8\u3001<strong>y<\/strong>\u304c\u76ee\u7684\u5909\u6570\u306e\u30ea\u30b9\u30c8\u3001<strong>X_cols<\/strong>\u304c\u8aac\u660e\u5909\u6570\u306e\u540d\u79f0\u30ea\u30b9\u30c8\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u306b\u3088\u308b\u5b66\u7fd2\u30e2\u30c7\u30eb\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u307e\u305a\u306fXGBoost\u3092import\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u306e\u5f8c\u3001\u89e3\u304d\u305f\u3044\u554f\u984c\u304c\u4f55\u304b\u306b\u3088\u3063\u3066\u547c\u3073\u51fa\u3059\u30af\u30e9\u30b9\u3068\u5f15\u6570\u304c\u5909\u308f\u3063\u3066\u304d\u307e\u3059\u3002<br>\b\u5927\u62b5\u306e\u5834\u5408\u306f\u4ee5\u4e0b\u306e3\u30d1\u30bf\u30fc\u30f3\u306e\u3044\u305a\u308c\u304b\u304b\u3089\u9078\u3076\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table table01\"><table class=\"has-fixed-layout\"><tbody><tr><th>2\u30af\u30e9\u30b9\u5206\u985e\u30bf\u30b9\u30af<\/th><td>XGBClassifier(objective=&#8221;binary:logistic&#8221;)<\/td><\/tr><tr><th>\u591a\u30af\u30e9\u30b9\u5206\u985e\u30bf\u30b9\u30af<\/th><td>XGBClassifier(objective=&#8221;multi:softmax&#8221;)<\/td><\/tr><tr><th>\u56de\u5e30\u30bf\u30b9\u30af(\u6570\u5024\u4e88\u6e2c)<\/th><td>XGBRegressor(objective=&#8221;reg:squarederror&#8221;)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u4eca\u56de\u306f2\u5024\u5206\u985e\u306a\u306e\u3067\u3001<strong>XGBClassifier(objective=&#8221;binary:logistic&#8221;)<\/strong>\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5f15\u6570\u306b\u3082\u8272\u3005\u6307\u5b9a\u3067\u304d\u307e\u3059\u304c\u3001\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u30a8\u30e9\u30fc\u3092\u8d77\u3053\u3059\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u306f\u4e0a\u8ff0\u3057\u305f<strong>objective<\/strong>\u306e\u307f\u3067\u3059\u3002<br>\u305d\u306e\u4ed6\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table table01\"><table class=\"has-fixed-layout\"><tbody><tr><th>\u6728\u306e\u6df1\u3055<\/th><td>max_depth(\u30c7\u30d5\u30a9\u30eb\u30c8=6)<\/td><\/tr><tr><th>\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u3059\u308b\u30c7\u30fc\u30bf\u6570\u306e\u5272\u5408<\/th><td>subsample(\u30c7\u30d5\u30a9\u30eb\u30c8=1.0)<\/td><\/tr><tr><th>\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u3059\u308b\u30ab\u30e9\u30e0\u6570\u306e\u5272\u5408<\/th><td>colsample_bytree(\u30c7\u30d5\u30a9\u30eb\u30c8=1.0)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\b\u3082\u3063\u3068\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u304c\u3001\u4f53\u611f\u3068\u3057\u3066\u306f\u6700\u3082\u6027\u80fd\u306b\u97ff\u3044\u3066\u304f\u308b\u306e\u306f\u4e0a\u8a183\u3064\u3067\u3059\u3002<br>\u3053\u306e\u3042\u305f\u308a\u306f\u4e3b\u89b3\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u304c<strong>max_depth<\/strong>\u306f5\u301c15\u3042\u305f\u308a\u3001<strong>subsample<\/strong>\u3068<strong>colsample_bytree<\/strong>\u306f0.8\u301c1\u3042\u305f\u308a\u3067\u8abf\u6574\u3057\u3066\u307f\u308b\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30fb\u30fb\u30fb\u307e\u305f\u3001\u4eca\u56de\u306f\u66f4\u306b\u9ad8\u307f\u3092\u76ee\u6307\u3057\u3066(?)\u3001<strong>\u4ea4\u5dee\u691c\u8a3c<\/strong>\u3082\u884c\u3063\u3066\u307f\u307e\u3059\u3002\u5206\u5272\u6570\u306f5\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6027\u80fd\u6307\u6a19\u3067\u3059\u304c\u3001\u5206\u985e\u30bf\u30b9\u30af(\u4e88\u6e2c\u3059\u308b\u3082\u306e\u304c\u30ab\u30c6\u30b4\u30ea)\u306a\u306e\u3067\u3001<strong>\u300caccuracy\u300d\u300cprecision_macro\u300d\u300crecall_macro\u300d\u300cf1_macro\u300d<\/strong>\u306e4\u3064\u3092\u51fa\u3057\u3066\u307f\u307e\u3059\u3002<br>\u3053\u308c\u3089\u306e\u610f\u5473\u3084\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/analysis-navi.com\/?p=553\">\u6df7\u540c\u884c\u5217\u306e\u8a18\u4e8b<\/a>\u3082\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u56de\u5e30\u30bf\u30b9\u30af(\u4e88\u6e2c\u3059\u308b\u3082\u306e\u304c\u6570\u5024)\u306a\u3089\u3070\u3001<strong>\u300cmax_error\u300d\u300cneg_mean_squared_error\u300d<\/strong>\u306a\u3069\u306e\u6307\u6a19\u3092\u9078\u629e\u3057\u307e\u3059\u3002<br>\u3053\u308c\u3089\u306e\u610f\u5473\u3084\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/analysis-navi.com\/?p=2875\">\u8aa4\u5dee\u6307\u6a19\u306e\u8a18\u4e8b<\/a>\u3082\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u30fb\u30fb\u30fb\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b66\u7fd2\u30e2\u30c7\u30eb\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#\u5b66\u7fd2\nimport xgboost as xgb\nfrom sklearn.model_selection import cross_validate,cross_val_predict, StratifiedKFold\n\nsplits = 5\nskf = StratifiedKFold(n_splits=splits, shuffle=True, random_state=42)\nscore_funcs = [\"accuracy\",\"precision_macro\",\"recall_macro\",\"f1_macro\"]\n\nclf = xgb.XGBClassifier(objective=\"binary:logistic\")\n\nscore = cross_validate(clf, X, y, cv=skf, scoring=score_funcs,return_estimator=True)\n\nprint(score[\"test_accuracy\"].mean())\nprint(score[\"test_precision_macro\"].mean())\nprint(score[\"test_recall_macro\"].mean())\nprint(score[\"test_f1_macro\"].mean())<\/pre>\n\n\n\n<p>\u3057\u3070\u3089\u304f\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7d50\u679c\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0.9613081954597924\n0.9605032686950473\n0.9566712939133509\n0.9584412931360962<\/pre>\n\n\n\n<p>\u3069\u306e\u6307\u6a19\u3092\u898b\u3066\u3082\u975e\u5e38\u306b\u9ad8\u3044\u6027\u80fd\u304c\u51fa\u3066\u3044\u308b\u3068\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u3001cross_validate\u306e\u5b9f\u884c\u6642\u306b<strong>\u300creturn_estimator=True\u300d<\/strong>\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u91cd\u8981\u8996\u3057\u3066\u3044\u308b\u5909\u6570\u306a\u3069\u30e2\u30c7\u30eb\u306e\u4e2d\u8eab\u306e\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u91cd\u8981\u5909\u6570\u306e\u78ba\u8a8d<\/h3>\n\n\n\n<p>\u3055\u3066\u3001\u3053\u308c\u3067\u5b66\u7fd2\u30e2\u30c7\u30eb\u304c\u5b8c\u6210\u3057\u307e\u3057\u305f\u3002<br>\u3067\u306f\u3001\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u304c\u3001<strong><span style=\"background-color: #87cefa;\">\u5206\u985e\u306b\u6df1\u304f\u95a2\u308f\u3063\u3066\u304f\u308b\u306e\u306f\u5909\u6570\u306f\u3069\u308c<\/span><\/strong>\u3068\u5224\u65ad\u3057\u305f\u306e\u304b\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#\u91cd\u8981\u5909\u6570\nimport pandas as pd\n\nsum_score = np.zeros(len(X_cols ),)\n\nfor i in range(splits):\n&nbsp; &nbsp; sum_score += score[\"estimator\"][i].feature_importances_\n\ndf_score = pd.DataFrame(sum_score\/splits,index=X_cols,columns=[\"score\"])\n\ndf_score.sort_values(\"score\",ascending=False) #\u5f71\u97ff\u304c\u5927\u304d\u3044\u9806\u306b\u8868\u793a<\/pre>\n\n\n\n<p>\u4ea4\u5dee\u691c\u8a3c\u3092\u884c\u3063\u305f\u306e\u3067\u3001\u5206\u5272\u3057\u305f5\u3064\u306e\u5206\u985e\u5668\u305d\u308c\u305e\u308c\u3067\u7d50\u679c\u304c\u51fa\u3066\u3044\u307e\u3059\u3002<br>\u306a\u306e\u3067\u3001\u3059\u3079\u3066\u306e\u7d50\u679c\u3092\u5e73\u5747\u3057\u3066\u3001\u6700\u5f8c\u306b\u30bd\u30fc\u30c8\u3057\u3066\u5927\u304d\u3044\u9806\u306b\u4e26\u3073\u66ff\u3048\u307e\u3057\u305f\u3002<br>\u5b9f\u884c\u3059\u308b\u3068\u30fb\u30fb\u30fb<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"236\" height=\"350\" src=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2020\/03\/1bc64aa5eb90b5ad2f3bc50aec9c58e8.png\" alt=\"\" class=\"wp-image-3197\" srcset=\"https:\/\/analysis-navi.com\/wp-content\/uploads\/2020\/03\/1bc64aa5eb90b5ad2f3bc50aec9c58e8.png 236w, https:\/\/analysis-navi.com\/wp-content\/uploads\/2020\/03\/1bc64aa5eb90b5ad2f3bc50aec9c58e8-202x300.png 202w\" sizes=\"(max-width: 236px) 100vw, 236px\" \/><\/figure>\n\n\n\n\n\n\n\n<p><strong><span style=\"background-color: #87cefa;\">\u6700\u3082\u91cd\u8981\u306a\u8aac\u660e\u5909\u6570\u306f\u300cworst perimeter\u300d<\/span><\/strong>\u3068\u5224\u65ad\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<br>\u3053\u3046\u3044\u3063\u305f\u60c5\u5831\u304c\u7c21\u5358\u306b\u53d6\u308c\u308b\u306e\u3082\u6709\u96e3\u3044\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ab\u30c6\u30b4\u30ea\u4e88\u6e2c<\/h3>\n\n\n\n<p>\u6700\u5f8c\u306b\u3001\u4f5c\u6210\u3057\u305f\u5b66\u7fd2\u30e2\u30c7\u30eb\u3092\u4f7f\u3063\u3066\u4e88\u6e2c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#\u4e88\u6e2c\nsample = X[0] + np.random.rand(len(X[0])) #\u9069\u5f53\u306a\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\n\nscore[\"estimator\"][0].predict([sample])<\/pre>\n\n\n\n<p>\u5165\u529b\u30c7\u30fc\u30bf\u306e0\u756a\u76ee\u306b\u9069\u5f53\u306a\u6570\u5024\u3092\u8db3\u3057\u7b97\u3057\u305f\u30c0\u30df\u30fc\u30c7\u30fc\u30bf\u3092\u4f5c\u308a\u3001\u30ab\u30c6\u30b4\u30ea\u3092\u4e88\u6e2c\u3055\u305b\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u5206\u985e\u5668\u306f5\u500b\u3042\u308b\u306e\u3067\u3001\u4e88\u6e2c\u3059\u308b\u5834\u5408\u306f\u3069\u308c\u304b1\u3064\u9078\u3076\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u591a\u6570\u6c7a\u3067\u6c7a\u3081\u308b\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\uff09<br>\u4eca\u56de\u306f<strong>score[&#8220;estimator&#8221;][0]<\/strong>\u3068\u30010\u756a\u76ee\u306e\u3082\u306e\u3092\u9078\u3093\u3067\u3044\u307e\u3059\u3002<br>\u7d50\u679c\u306f\u30fb\u30fb\u30fb<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">array([0])<\/pre>\n\n\n\n<p>\u300c0\u300d\u3001\u3064\u307e\u308a<strong><span style=\"background-color: #87cefa;\">\u3053\u306e\u30c7\u30fc\u30bf\u306e\u60a3\u8005\u306f\u4e73\u304c\u3093\u3067\u306f\u7121\u3044<\/span><\/strong>\u3068\u5224\u65ad\u3057\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u304a\u308f\u308a\u306b<\/h2>\n\n\n\n<p>\u4ee5\u4e0a\u304c\u3001\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u306e\u5b9f\u88c5\u65b9\u6cd5\u3067\u3057\u305f\u3002<br>\u512a\u79c0\u306a\u4e0a\u306b\u5b9f\u88c5\u3082\u7c21\u5358\u306a\u306e\u3067\u3001\u78ba\u5b9f\u306b\u6291\u3048\u3066\u304a\u304d\u305f\u3044\u6a5f\u68b0\u5b66\u7fd2\u306e\u3072\u3068\u3064\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5\u300c\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u300d\u306f\u3001\u30c7\u30fc\u30bf\u5206\u6790\u30b3\u30f3\u30da\u30c6\u30a3\u30b7\u30e7\u30f3\u300cKaggle\u300d\u3067\u826f\u3044\u6027\u80fd\u3092\u51fa\u3059\u4e8b\u304c\u591a\u304f\u3001\u4e00\u6c17\u306b\u591a\u7528\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u500b\u4eba\u306e\u4e3b\u89b3\u3068\u3057\u3066\u3082\u300c\u6570\u91cf\u30c7\u30fc\u30bf\u5206\u6790\u306b\u304a\u3051\u308b\u6700\u5f37\u306e\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5\u300d\u3067\u306f\u306a\u3044\u304b\u3068\u8003\u3048 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4973,"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],"class_list":["post-2753","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-study","tag-ml"],"_links":{"self":[{"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/posts\/2753","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=2753"}],"version-history":[{"count":27,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/posts\/2753\/revisions"}],"predecessor-version":[{"id":5045,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/posts\/2753\/revisions\/5045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=\/wp\/v2\/media\/4973"}],"wp:attachment":[{"href":"https:\/\/analysis-navi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/analysis-navi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}