{"id":9956,"date":"2026-10-07T10:17:20","date_gmt":"2026-10-07T01:17:20","guid":{"rendered":"https:\/\/since2020.jp\/media\/?p=9956"},"modified":"2026-10-07T10:17:21","modified_gmt":"2026-10-07T01:17:21","slug":"tree-model-extrapolation","status":"publish","type":"post","link":"https:\/\/since2020.jp\/media\/tree-model-extrapolation\/","title":{"rendered":"\u6728\u30e2\u30c7\u30eb\u306f\u5916\u633f\u3067\u304d\u306a\u3044\uff1aRandomForest\u3068LightGBM\u306f\u3001\u307f\u305f\u3053\u3068\u306e\u306a\u3044\u7bc4\u56f2\u3067\u982d\u6253\u3061\u306b\u306a\u308b"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u306f\u3058\u3081\u306b<\/h2>\n\n\n\n<p>RandomForest\u3084LightGBM\u306f\u3001\u8868\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u306e\u4e88\u6e2c\u3067\u5f37\u529b\u3067\u3059\u3002\u3067\u306f\u3001\u8a13\u7df4\u30c7\u30fc\u30bf\u3088\u308a\u5927\u304d\u3044\u5024\u3092\u4e88\u6e2c\u3055\u305b\u308b\u3068\u3001\u3069\u3046\u306a\u308b\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u7c21\u5358\u306a\u30c7\u30fc\u30bf\u3067\u5b9f\u9a13\u3057\u3066\u3001\u6b21\u306e\uff13\u70b9\u3092\u78ba\u304b\u3081\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8a13\u7df4\u30c7\u30fc\u30bf\u306e\u7bc4\u56f2\u306e\u5916\u3092\u4e88\u6e2c\u3059\u308b\u3068\u3001\u4e88\u6e2c\u5024\u304c\u6a2a\u3070\u3044\u306b\u306a\u308b<\/li>\n\n\n\n<li>\u305d\u306e\u539f\u56e0\u304c\u3001\u6728\u30e2\u30c7\u30eb\u306e\u4ed5\u7d44\u307f\u306e\u3069\u3053\u306b\u3042\u308b\u306e\u304b<\/li>\n\n\n\n<li>\u7bc4\u56f2\u5916\u3067\u3082\u5f53\u305f\u308b\u4e88\u6e2c\u306b\u3059\u308b\u65b9\u6cd5<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u9a13\u306e\u8a2d\u5b9a<\/h2>\n\n\n\n<p>\u771f\u306e\u95a2\u4fc2\u3092y = 2x(\u30ce\u30a4\u30ba\u3042\u308a)\u3068\u3057\u3001x \u304c 0\u301c10 \u306e\u30c7\u30fc\u30bf\u3060\u3051\u3067\u5b66\u7fd2\u3055\u305b\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001x=15 \u3068 x=20 \u3092\u4e88\u6e2c\u3055\u305b\u307e\u3059\u3002\u6bd4\u8f03\u3059\u308b\u306e\u306f\u3001\u7dda\u5f62\u56de\u5e30\u3001RandomForest\u3001LightGBM \u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.ensemble import RandomForestRegressor\nfrom lightgbm import LGBMRegressor\n\nrng = np.random.default_rng(42)\nx = rng.uniform(0, 10, 300)\ny = 2 * x + rng.normal(0, 1, 300)\nX_train = x.reshape(-1, 1)\n\nmodels = {\n    \"Linear\": LinearRegression(),\n    \"RandomForest\": RandomForestRegressor(n_estimators=200, random_state=0),\n    \"LightGBM\": LGBMRegressor(n_estimators=200, random_state=0, verbose=-1),\n}\nfor name, m in models.items():\n    m.fit(X_train, y)\n    print(name, m.predict(&#091;&#091;15.0], &#091;20.0]]))<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d50\u679c\uff1a\u7bc4\u56f2\u306e\u5916\u3067\u3001\u4e88\u6e2c\u304c\u6a2a\u3070\u3044\u306b\u306a\u308b<\/h2>\n\n\n\n<p>\u30c7\u30fc\u30bf\u306e\u4e71\u6570\u3092\u5909\u3048\u306620\u56de\u7e70\u308a\u8fd4\u3057\u305f\u5e73\u5747\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>x<\/td><td>\u771f\u306e\u5024<\/td><td>\u7dda\u5f62\u56de\u5e30<\/td><td>RandomForest<\/td><td>LightGBM<\/td><\/tr><tr><td>15<\/td><td>30<\/td><td>29.96<\/td><td>19.95<\/td><td>19.20<\/td><\/tr><tr><td>20<\/td><td>40<\/td><td>39.95<\/td><td>19.95<\/td><td>19.20<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2026\/10\/extrapolation_v2-1024x576.png\" alt=\"\" class=\"wp-image-9957\" srcset=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2026\/10\/extrapolation_v2-1024x576.png 1024w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2026\/10\/extrapolation_v2-300x169.png 300w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2026\/10\/extrapolation_v2-768x432.png 768w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2026\/10\/extrapolation_v2-1536x864.png 1536w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2026\/10\/extrapolation_v2.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u7dda\u5f62\u56de\u5e30\u306f\u3001\u7bc4\u56f2\u5916\u306e\u5916\u3067\u3082\u771f\u306e\u5024\u306b\u8fd1\u3044\u4e88\u6e2c\u3092\u51fa\u3057\u307e\u3059\u3002\u4e00\u65b9\u3001RandomForest\u3068LightGBM\u306f\u3001x=10\u3092\u8d85\u3048\u305f\u3068\u3053\u308d\u304b\u3089\u6a2a\u4e00\u76f4\u7dda\u306b\u306a\u308a\u307e\u3057\u305f\u3002x=20\u3067\u306f\u3001\u771f\u306e\u502440\u306b\u5bfe\u3057\u3066\u4e88\u6e2c\u306f\u7d0420\u3067\u3059\u3002\u534a\u5206\u306b\u3082\u5c4a\u304d\u307e\u305b\u3093\u300220\u56de\u306e\u3046\u3061\u3001\u3053\u306e\u50be\u5411\u304c\u5d29\u308c\u305f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u539f\u56e0\uff1a\u8449\u306e\u5e73\u5747\u3092\u8fd4\u3057\u3066\u3044\u308b\u3060\u3051<\/h2>\n\n\n\n<p>\u6728\u30e2\u30c7\u30eb\u306f\u3001\u7279\u5fb4\u91cf\u306e\u5024\u3067\u30c7\u30fc\u30bf\u3092\u5206\u5272\u3057\u3001\u5404\u30b0\u30eb\u30fc\u30d7\uff08\u8449\uff09\u306e\u8a13\u7df4\u30c7\u30fc\u30bf\u306e\u5e73\u5747\u3092\u4e88\u6e2c\u5024\u3068\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002x=15\u3084x=20\u306e\u30c7\u30fc\u30bf\u306f\u3001\u8a13\u7df4\u30c7\u30fc\u30bf\u3067\u3044\u3061\u3070\u3093\u53f3\u306b\u3042\u3063\u305f\u8449\u306b\u632f\u308a\u5206\u3051\u3089\u308c\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u4e88\u6e2c\u5024\u306f\u8a13\u7df4\u30c7\u30fc\u30bf\u306ey\u306e\u7bc4\u56f2\u3092\u8d85\u3048\u3089\u308c\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u6728\u306f\u95a2\u4fc2\u5f0f\u3092\u5b66\u7fd2\u3057\u3066\u3044\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u300c\u898b\u305f\u3053\u3068\u306e\u3042\u308b\u5024\u306e\u5e73\u5747\u300d\u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\u7dda\u5f62\u56de\u5e30\u306f\u3001\u50be\u304d\u3068\u3044\u3046\u95a2\u4fc2\u5f0f\u3092\u5b66\u7fd2\u3059\u308b\u306e\u3067\u3001\u7bc4\u56f2\u306e\u5916\u307e\u3067\u5ef6\u3070\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5bfe\u51e6\u6cd5\uff1a\u30c8\u30ec\u30f3\u30c9\u3092\u5148\u306b\u53d6\u308a\u9664\u304f<\/h2>\n\n\n\n<p>\u6728\u30e2\u30c7\u30eb\u306b\u4efb\u305b\u308b\u524d\u306b\u3001\u7dda\u5f62\u56de\u5e30\u3067\u9577\u671f\u306e\u50be\u304d\u3092\u3064\u304b\u307f\u307e\u3059\u3002\u6b8b\u308a\u306e\u305a\u308c\u3092\u6728\u30e2\u30c7\u30eb\u306b\u5b66\u7fd2\u3055\u305b\u3001\u6700\u5f8c\u306b\u8db3\u3057\u5408\u308f\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lin = LinearRegression().fit(X_train, y)\nrf = RandomForestRegressor(n_estimators=200, random_state=0)\nrf.fit(X_train, y - lin.predict(X_train))        # \u50be\u304d\u3092\u5f15\u3044\u305f\u6b8b\u308a\u3092\u5b66\u7fd2\n\nX_new = np.array(&#091;&#091;15.0], &#091;20.0]])\npred = lin.predict(X_new) + rf.predict(X_new)    # \u50be\u304d + \u6b8b\u308a\u306e\u4e88\u6e2c<\/code><\/pre>\n\n\n\n<p>\u540c\u305820\u56de\u306e\u5e73\u5747\u306f\u3001\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>x<\/td><td>\u771f\u306e\u5024<\/td><td>RandomForest\u5358\u4f53<\/td><td>\u30c8\u30ec\u30f3\u30c9\u9664\u53bb\uff0bRandomForest<\/td><\/tr><tr><td>15<\/td><td>30<\/td><td>19.95<\/td><td>30.03<\/td><\/tr><tr><td>20<\/td><td>40<\/td><td>19.95<\/td><td>40.02<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u7bc4\u56f2\u5916\u3067\u3082\u3001\u771f\u306e\u5024\u306b\u307b\u307c\u4e00\u81f4\u3057\u307e\u3057\u305f\u300220\u56de\u306e\u6700\u5c0f\u3068\u6700\u5927\u306f\u3001x=20\u306738.91~40.88\u3067\u3059\u3002<\/p>\n\n\n\n<p>LightGBM\u306elinear_tree=True\uff08\u8449\u306e\u4e2d\u3067\u7dda\u5f62\u56de\u5e30\u3092\u4f7f\u3046\u30aa\u30d7\u30b7\u30e7\u30f3\uff09\u3082\u8a66\u3057\u307e\u3057\u305f\u304c\u300120\u56de\u306e\u5e73\u5747\u306f42.42(x=20)\u3067\u3082\u3001\u6700\u5c0f21.24\u3001\u6700\u592757.88\u3068\u5927\u304d\u304f\u30d6\u30ec\u307e\u3057\u305f\u3002\u7bc4\u56f2\u5916\u306e\u4e88\u6e2c\u3092\u5b89\u5b9a\u3055\u305b\u305f\u3044\u306a\u3089\u3001\u30c8\u30ec\u30f3\u30c9\u3092\u5927\u304d\u304f\u53d6\u308a\u9664\u304f\u65b9\u6cd5\u306e\u65b9\u304c\u78ba\u5b9f\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>RandomForest\u3068LightGBM\u306f\u3001\u8a13\u7df4\u30c7\u30fc\u30bf\u306e\u7bc4\u56f2\u5916\u3067\u4e88\u6e2c\u304c\u982d\u6253\u3061\u306b\u306a\u308b\u3002x=20\u3067\u306f\u3001\u771f\u306e\u502440\u306b\u5bfe\u3057\u3066\u7d0420\u3060\u3063\u305f<\/li>\n\n\n\n<li>\u539f\u56e0\u306f\u3001\u8449\u3054\u3068\u306b\u8a13\u7df4\u30c7\u30fc\u30bf\u306e\u5e73\u5747\u3092\u8fd4\u3059\u4ed5\u7d44\u307f\u306b\u3042\u308b<\/li>\n\n\n\n<li>\u7dda\u5f62\u56de\u5e30\u3067\u30c8\u30ec\u30f3\u30c9\u3092\u53d6\u308a\u9664\u3044\u3066\u304b\u3089\u6728\u30e2\u30c7\u30eb\u3092\u4f7f\u3046\u3068\u3001\u7bc4\u56f2\u5916\u3067\u3082\u771f\u306e\u5024\u306b\u307b\u307c\u4e00\u81f4\u3057\u305f<\/li>\n<\/ul>\n\n\n\n<p>\u58f2\u4e0a\u3084\u30e6\u30fc\u30b6\u30fc\u6570\u306e\u3088\u3046\u306b\u3001\u5897\u3048\u7d9a\u3051\u308b\u91cf\u3092\u4e88\u6e2c\u3059\u308b\u3068\u304d\u306f\u3001\u6728\u30e2\u30c7\u30eb\u306b\u4e38\u3054\u3068\u4efb\u305b\u306a\u3044\u3002\u50be\u304d\u3092\u5148\u306b\u53d6\u308a\u51fa\u3057\u3066\u3001\u6b8b\u308a\u3092\u6728\u306b\u4efb\u305b\u308b\u3002\u3053\u308c\u304c\u3001\u3053\u306e\u843d\u3068\u3057\u7a74\u3078\u306e\u5bfe\u51e6\u6cd5\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b RandomForest\u3084LightGBM\u306f\u3001\u8868\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u306e\u4e88\u6e2c\u3067\u5f37\u529b\u3067\u3059\u3002\u3067\u306f\u3001\u8a13\u7df4\u30c7\u30fc\u30bf\u3088\u308a\u5927\u304d\u3044\u5024\u3092\u4e88\u6e2c\u3055\u305b\u308b\u3068\u3001\u3069\u3046\u306a\u308b\u3067\u3057\u3087\u3046\u304b\u3002 \u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u7c21\u5358\u306a\u30c7\u30fc\u30bf\u3067\u5b9f\u9a13\u3057\u3066\u3001\u6b21\u306e\uff13\u70b9\u3092\u78ba\u304b\u3081\u307e\u3059\u3002 \u5b9f\u9a13 [&hellip;]<\/p>\n","protected":false},"author":99,"featured_media":10053,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","swell_btn_cv_data":"","footnotes":"","_wp_rev_ctl_limit":""},"categories":[1249],"tags":[39,27,26],"class_list":["post-9956","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge","tag-39","tag-27","tag-26"],"_links":{"self":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/9956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/users\/99"}],"replies":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/comments?post=9956"}],"version-history":[{"count":1,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/9956\/revisions"}],"predecessor-version":[{"id":9963,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/9956\/revisions\/9963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media\/10053"}],"wp:attachment":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media?parent=9956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/categories?post=9956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/tags?post=9956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}