{"id":5729,"date":"2024-10-28T14:17:34","date_gmt":"2024-10-28T05:17:34","guid":{"rendered":"https:\/\/blog.since2020.jp\/?p=5729"},"modified":"2024-10-28T14:56:23","modified_gmt":"2024-10-28T05:56:23","slug":"shapley-additive-explanations","status":"publish","type":"post","link":"https:\/\/since2020.jp\/media\/shapley-additive-explanations\/","title":{"rendered":"SHAP: \u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\u304c\u51fa\u529b\u3059\u308b\u500b\u5225\u306e\u4e88\u6e2c\u5024\u306e\u7406\u7531\u3092\u8aac\u660e\u3059\u308b"},"content":{"rendered":"\n<p>\u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\u3092\u89e3\u91c8\u3059\u308b\u624b\u6cd5\u306e\u4e00\u3064\u3068\u3057\u3066\u3001\u300c\u4e88\u6e2c\u30e2\u30c7\u30eb\u306e\u7279\u5b9a\u306e\u51fa\u529b\u5024\u304c\u3069\u306e\u7279\u5fb4\u91cf\u306b\u3088\u3063\u3066\u3082\u305f\u3089\u3055\u308c\u305f\u306e\u304b\u300d\u3092\u8a08\u7b97\u3059\u308bSHAP\u304c\u3042\u308a\u307e\u3059\u3002\u672c\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001SHAP\u306e\u8a08\u7b97\u65b9\u6cd5\u3084Python\u306b\u3088\u308b\u5b9f\u884c\u4f8b\u3001\u5229\u70b9\u3068\u6ce8\u610f\u70b9\u306a\u3069\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>Deep Neural Network\u3084LightGBM\u306a\u3069\u306e\u9ad8\u5ea6\u306a\u6a5f\u68b0\u5b66\u7fd2\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306f\u9ad8\u3044\u4e88\u6e2c\u7cbe\u5ea6\u3092\u3082\u305f\u3089\u3059\u4e00\u65b9\u3067\u89e3\u91c8\u6027\u304c\u4f4e\u3044\u50be\u5411\u306b\u3042\u308a\u307e\u3059\u3002\u30d3\u30b8\u30cd\u30b9\u3067\u305d\u308c\u3089\u306e\u6a5f\u68b0\u5b66\u7fd2\u624b\u6cd5\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u30e2\u30c7\u30eb\u306e\u6319\u52d5\u306b\u3064\u3044\u3066\u8aac\u660e\u3067\u304d\u308b\u307b\u3046\u304c\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\r\n<p>\u904e\u53bb\u306e\u8a18\u4e8b\u3067\u3001\u300c\u7279\u5fb4\u91cf\u91cd\u8981\u5ea6\u300d\u3092\u8a08\u7b97\u3059\u308bPermutaiton Importance (PI) \u3084\u300c\u30e2\u30c7\u30eb\u306e\u4e88\u6e2c\u5024\u3068\u7279\u5fb4\u91cf\u306e\u5e73\u5747\u7684\u306a\u95a2\u4fc2\u300d\u3092\u53ef\u8996\u5316\u3059\u308bPartial Dependence Plot (PDP) \u306e\u6982\u8981\u3092\u8aac\u660e\u3057\u307e\u3057\u305f\u3002<a href=\"https:\/\/blog.since2020.jp\/ai\/permutation-importance\/\"><\/a><a href=\"https:\/\/blog.since2020.jp\/ai\/partial-dependence\/\"><\/a><\/p>\r\n<p>[blogcard url=&#8221;https:\/\/blog.since2020.jp\/ai\/permutation-importance\/&#8221;][blogcard url=&#8221;https:\/\/blog.since2020.jp\/ai\/partial-dependence\/&#8221;]<\/p>\r\n<p>PI\u3084PDP\u306f\u30e2\u30c7\u30eb\u3068\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u5168\u4f53\u3068\u306e\u30b0\u30ed\u30fc\u30d0\u30eb\u306a\u95a2\u4fc2\u3092\u6349\u3048\u308b\u624b\u6cd5\u3067\u3042\u308b\u305f\u3081\u3001\u30e2\u30c7\u30eb\u304c\u51fa\u529b\u3057\u305f\u500b\u5225\u306e\u4e88\u6e2c\u5024\u306b\u5bfe\u3057\u3066\u3001\u500b\u5225\u306e\u30c7\u30fc\u30bf\u70b9\u3054\u3068\u306e\u7570\u8cea\u6027\u3092\u8003\u616e\u3057\u3066\u89e3\u91c8\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<strong>\u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\u304c\u51fa\u529b\u3057\u305f\u500b\u5225\u306e\u4e88\u6e2c\u5024\u304c\u3069\u306e\u7279\u5fb4\u91cf\u306b\u3088\u3063\u3066\u3082\u305f\u3089\u3055\u308c\u305f\u306e\u304b<\/strong>\u3092\u8a08\u7b97\u3059\u308b\u624b\u6cd5\u3068\u3057\u3066\u3001<strong>SHapley Additive eXplanations (SHAP)<\/strong> \u304c\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\r\n<p>\u672c\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001SHAP\u306e\u8a08\u7b97\u65b9\u6cd5\u3084Python\u306b\u3088\u308b\u5b9f\u884c\u4f8b\u3001\u5b9f\u969b\u306b\u5229\u7528\u3059\u308b\u969b\u306e\u6ce8\u610f\u70b9\u306a\u3069\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\r\n<p><!-- notionvc: 24238b04-63b9-49ba-8156-61303a2a7331 --><\/p>\n\n<h2>SHAP\u306e\u8a08\u7b97\u65b9\u6cd5<\/h2>\n<p><strong><span style=\"text-decoration: underline;font-size: 14pt\">SHAP\u306e\u30a2\u30a4\u30c7\u30a2<\/span><br \/>\r\n<\/strong>SHAP\u306f\u3001\u30e2\u30c7\u30eb\u304c\u51fa\u529b\u3059\u308b<strong>\u500b\u5225\u306e\u4e88\u6e2c\u5024<\/strong>\u3092<strong>\u5404\u7279\u5fb4\u91cf\u306e\u8ca2\u732e\u5ea6<\/strong>\u306b\u5206\u89e3\u3059\u308b\u624b\u6cd5\u3067\u3059\u3002<\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-algo.png\" alt=\"\" width=\"1662\" height=\"420\" class=\"aligncenter size-full wp-image-5730\" srcset=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-algo.png 1662w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-algo-300x76.png 300w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-algo-1024x259.png 1024w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-algo-768x194.png 768w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-algo-1536x388.png 1536w\" sizes=\"(max-width: 1662px) 100vw, 1662px\" \/><br \/>\r\n\u68ee\u4e0b (2021)\u300e\u6a5f\u68b0\u5b66\u7fd2\u3092\u89e3\u91c8\u3059\u308b\u6280\u8853\u300f\u3092\u5143\u306b\u4f5c\u6210\uff09<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><strong><span style=\"text-decoration: underline;font-size: 14pt\">\u8ca2\u732e\u5ea6\u306e\u8a08\u7b97\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0<\/span><br \/>\r\n<\/strong>\u5404\u7279\u5fb4\u91cf\u306e\u8ca2\u732e\u5ea6\uff08SHAP\u5024\uff09\u306e\u5177\u4f53\u7684\u306a\u7b97\u51fa\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u304c\u53c2\u8003\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\r\n<p>[blogcard url=&#8221;https:\/\/christophm.github.io\/interpretable-ml-book\/shapley.html&#8221;][blogcard url=&#8221;https:\/\/hacarus.github.io\/interpretable-ml-book-ja\/shapley.html&#8221;][blogcard url=&#8221;https:\/\/www.datarobot.com\/jp\/blog\/explain-machine-learning-models-using-shap\/&#8221;]<\/p>\r\n<p><!-- notionvc: 099a4f6f-b1c6-409a-87f4-0d263133db8b --><\/p>\r\n<p><!-- notionvc: 5b9e4259-e1f7-42f6-9541-a6c85e9db2ca --><\/p>\n\n<h2>Python\u3067\u306e\u5b9f\u884c\u4f8b<\/h2>\n<p><strong><span style=\"text-decoration: underline;font-size: 14pt\">\u5b9f\u884c\u74b0\u5883<\/span><br \/>\r\n<\/strong>Python 3.11.9<\/p>\r\n<p><span style=\"text-decoration: underline\"><span style=\"font-size: 14pt\"><strong>\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/strong><\/span><\/span><\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># \u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\r\nimport numpy as np\r\nimport pandas as pd\r\nimport matplotlib.pyplot as plt\r\nimport japanize_matplotlib\r\nfrom sklearn.datasets import fetch_california_housing\r\nfrom sklearn.ensemble import GradientBoostingRegressor\r\nfrom sklearn.model_selection import train_test_split\r\nimport shap<\/code><\/pre>\r\n<\/div>\r\n<p><strong><span style=\"text-decoration: underline\"><span style=\"font-size: 14pt\">\u30c7\u30fc\u30bf\u306e\u6e96\u5099<\/span><\/span><br \/>\r\n<\/strong>\u3053\u3053\u3067\u306f\u3001scikit-learn\u306e <a href=\"https:\/\/scikit-learn.org\/1.5\/modules\/generated\/sklearn.datasets.fetch_california_housing.html\"><strong>fetch_california_housing<\/strong><\/a> \u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u3053\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u542b\u307e\u308c\u308b\u69d8\u3005\u306a\u7279\u5fb4\u91cf\u304b\u3089\u3001\u30ab\u30ea\u30d5\u30a9\u30eb\u30cb\u30a2\u5dde\u306e\u4f4f\u5b85\u4fa1\u683c\u3092\u4e88\u6e2c\u3059\u308b\u56de\u5e30\u30e2\u30c7\u30eb\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002<\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># \u30ab\u30ea\u30d5\u30a9\u30eb\u30cb\u30a2\u4f4f\u5b85\u4fa1\u683c\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u8aad\u307f\u8fbc\u3080\r\ncalifornia = fetch_california_housing()\r\n\r\n# \u30c7\u30fc\u30bf\u3092DataFrame\u306b\u5909\u63db\r\ndf = pd.DataFrame(california.data, columns=california.feature_names)\r\n\r\n# \u30ab\u30e9\u30e0\u540d\u3092\u65e5\u672c\u8a9e\u306b\u5909\u66f4\r\njapanese_columns = {\r\n    'MedInc': '\u4e16\u5e2f\u306e\u4e2d\u592e\u5024\u53ce\u5165',\r\n    'HouseAge': '\u4f4f\u5b85\u306e\u7bc9\u5e74\u6570',\r\n    'AveRooms': '\u5e73\u5747\u90e8\u5c4b\u6570',\r\n    'AveBedrms': '\u5e73\u5747\u5bdd\u5ba4\u6570',\r\n    'Population': '\u4eba\u53e3',\r\n    'AveOccup': '\u4e16\u5e2f\u306e\u5e73\u5747\u4eba\u6570',\r\n    'Latitude': '\u7def\u5ea6',\r\n    'Longitude': '\u7d4c\u5ea6',\r\n}\r\ndf.rename(columns=japanese_columns, inplace=True)\r\ndf['\u4f4f\u5b85\u4fa1\u683c'] = california.target\r\n\r\n# \u7279\u5fb4\u91cf\u3068\u30bf\u30fc\u30b2\u30c3\u30c8\u306b\u5206\u3051\u308b\r\nX = df.drop('\u4f4f\u5b85\u4fa1\u683c', axis=1)\r\ny = df['\u4f4f\u5b85\u4fa1\u683c']\r\n\r\n# \u30c7\u30fc\u30bf\u3092\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30bb\u30c3\u30c8\u3068\u30c6\u30b9\u30c8\u30bb\u30c3\u30c8\u306b\u5206\u5272\uff088:2\uff09\r\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<\/code><\/pre>\r\n<\/div>\r\n<p><span style=\"text-decoration: underline\"><strong><span style=\"font-size: 14pt\">\u5b66\u7fd2\u6e08\u307f\u30e2\u30c7\u30eb\u306e\u6e96\u5099<\/span><\/strong><\/span><\/p>\r\n<p>\u4eca\u56de\u306f\u3001scikit-learn\u306e <strong><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.ensemble.GradientBoostingRegressor.html\">GradientBoostingRegressor<\/a><\/strong>\u00a0\u3092\u7528\u3044\u3066\u4e88\u6e2c\u30e2\u30c7\u30eb\u3092\u5b66\u7fd2\u3057\u307e\u3059\u3002<\/p>\r\n<p>SHAP\u306f\u30e2\u30c7\u30eb\u306e\u5b66\u7fd2\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u4f9d\u5b58\u3057\u306a\u3044\u305f\u3081\u3001\u89e3\u304d\u305f\u3044\u554f\u984c\u8a2d\u5b9a\u306b\u5fdc\u3058\u3066\u4ed6\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># \u30e2\u30c7\u30eb\u306e\u69cb\u7bc9\r\ngbr = GradientBoostingRegressor()\r\n\r\n# \u30e2\u30c7\u30eb\u306e\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\r\ngbr.fit(X_train, y_train)<\/code><\/pre>\r\n<\/div>\r\n<p><span style=\"font-size: 14pt\"><strong><span style=\"text-decoration: underline\">SHAP\u306e\u8a08\u7b97\u3068\u53ef\u8996\u5316<\/span><\/strong><\/span><strong><\/strong><\/p>\r\n<p>Python\u3067\u306f\u3001\u7c21\u5358\u306bSHAP\u3092\u5b9f\u884c\u3067\u304d\u308b\u30e9\u30a4\u30d6\u30e9\u30ea <code>shap<\/code> \u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002[blogcard url=&#8221;https:\/\/shap.readthedocs.io\/en\/latest\/#&#8221;]<\/p>\r\n<p>\u3053\u3053\u3067\u306f\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306b\u304a\u3051\u308b1\u884c\u76ee\u306e\u30c7\u30fc\u30bf\u70b9\u3092\u5bfe\u8c61\u306b\u3001\u30e2\u30c7\u30eb\u306e\u4e88\u6e2c\u5024\u306b\u5bfe\u3059\u308b\u7279\u5fb4\u91cf\u306e\u8ca2\u732e\u5ea6\u3092\u53ef\u8996\u5316\u3057\u307e\u3059\u3002<\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># SHAP\u5024\u306e\u8a08\u7b97 \r\nexplainer = shap.Explainer(gbr, X_test) \r\nshap_values = explainer(X_test.iloc[0:1]) # \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf1\u884c\u76ee\u306eSHAP\u5024\u3092\u8a08\u7b97 \r\n\r\n# SHAP\u5024\u306e\u53ef\u8996\u5316 \r\nshap.initjs() # JavaScript\u306e\u521d\u671f\u5316 \r\nshap.waterfall_plot(shap_values[0]) # 1\u884c\u76ee\u306e\u30c7\u30fc\u30bf\u306b\u5bfe\u3059\u308bSHAP\u5024\u3092\u53ef\u8996\u5316<\/code><\/pre>\r\n<\/div>\r\n<p>\u51fa\u529b\u3055\u308c\u308b\u30b0\u30e9\u30d5\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002 \u500b\u5225\u306e\u4e88\u6e2c\u5024 <span class=\"notion-text-equation-token\">f(X)<\/span> \u3068\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u5168\u4f53\u306b\u304a\u3051\u308b\u4e88\u6e2c\u5024\u306e\u671f\u5f85\u5024 <span class=\"notion-text-equation-token\">E[f(X)]<\/span> \u306e\u5dee\u3092\u5404\u7279\u5fb4\u91cf\u306e\u8ca2\u732e\u5ea6\u306b\u5206\u89e3\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<!-- notionvc: a897d222-d31d-4246-a3de-0bd5d81903db --><\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig1.png\" alt=\"\" width=\"880\" height=\"521\" class=\"aligncenter size-full wp-image-5731\" srcset=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig1.png 880w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig1-300x178.png 300w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig1-768x455.png 768w\" sizes=\"(max-width: 880px) 100vw, 880px\" \/><\/p>\r\n<p>SHAP\u306f\u3001\u500b\u5225\u306e\u30c7\u30fc\u30bf\u70b9\u306b\u5bfe\u3059\u308bSHAP\u5024\u3092\u5e73\u5747\u3057\u305f\u308a\u3001\u5206\u5e03\u3068\u3057\u3066\u53ef\u8996\u5316\u3059\u308b\u3053\u3068\u3067\u3001\u30e2\u30c7\u30eb\u3092\u30b0\u30ed\u30fc\u30d0\u30eb\u306b\u89e3\u91c8\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\r\n<p>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u5168\u4f53\u306b\u5bfe\u3059\u308bSHAP\u5024\uff08\u306e\u7d76\u5bfe\u5024\uff09\u306e\u5e73\u5747\u3092\u6c42\u3081\u308b\u3053\u3068\u3067\u3001\u7279\u5fb4\u91cf\u91cd\u8981\u5ea6\u3092\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002<\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># \u30de\u30af\u30ed\u306a\u89e3\u91c8\uff08\u5e73\u5747\uff09 \r\nexplainer = shap.Explainer(gbr, X_test) \r\nshap_values = explainer(X_test) # \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u5168\u4f53\u306eSHAP\u5024\u3092\u8a08\u7b97 \r\n\r\n# \u5e73\u5747\u7684\u306a\u91cd\u8981\u5ea6\u3092\u53ef\u8996\u5316 \r\nshap.summary_plot(shap_values, X_test, plot_type='bar')<\/code><\/pre>\r\n<\/div>\r\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b0\u30e9\u30d5\u306b\u3088\u3063\u3066\u3001\u30e2\u30c7\u30eb\u5168\u4f53\u306b\u304a\u3051\u308b\u7279\u5fb4\u91cf\u306e\u91cd\u8981\u5ea6\u304c\u53ef\u8996\u5316\u3055\u308c\u307e\u3059\u3002<\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig2.png\" alt=\"\" width=\"790\" height=\"459\" class=\"aligncenter size-full wp-image-5732\" srcset=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig2.png 790w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig2-300x174.png 300w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig2-768x446.png 768w\" sizes=\"(max-width: 790px) 100vw, 790px\" \/><\/p>\r\n<p>\u6b21\u306b\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u5168\u4f53\u306b\u304a\u3051\u308bSHAP\u5024\u306e\u5206\u5e03\u3092\u53ef\u8996\u5316\u3057\u307e\u3059\u3002<\/p>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># \u30de\u30af\u30ed\u306a\u89e3\u91c8\uff08\u5206\u5e03\uff09 \r\nexplainer = shap.Explainer(gbr, X_test) \r\nshap_values = explainer(X_test) # \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u5168\u4f53\u306eSHAP\u5024\u3092\u8a08\u7b97 \r\n\r\n# SHAP\u5024\u306e\u5206\u5e03\u3092\u53ef\u8996\u5316 \r\nshap.summary_plot(shap_values, X_test)<\/code><\/pre>\r\n<\/div>\r\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b0\u30e9\u30d5\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<br \/>\r\n<img decoding=\"async\" src=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig3.png\" alt=\"\" width=\"759\" height=\"459\" class=\"aligncenter size-full wp-image-5733\" srcset=\"https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig3.png 759w, https:\/\/since2020.jp\/media\/wp-content\/uploads\/2024\/10\/shap-fig3-300x181.png 300w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><\/p>\r\n<p><!-- notionvc: a50b858d-284f-4b85-901b-9833c2de5467 --><\/p>\r\n<p><!-- notionvc: 71433965-2cf4-4e3e-a78b-a5995dfbfe9b --><\/p>\n\n<h2>\u5229\u70b9\u3068\u8ab2\u984c<\/h2>\n<p>SHAP\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\r\n<p style=\"padding-left: 40px\">\u30fb \u4e88\u6e2c\u30e2\u30c7\u30eb\u306e\u5b66\u7fd2\u5f8c\u306b\u9069\u7528\u3055\u308c\u308b\u305f\u3081\u3001\u30e2\u30c7\u30eb\u306e\u5b66\u7fd2\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u4f9d\u5b58\u3057\u306a\u3044<\/p>\r\n<p style=\"padding-left: 40px\">\u30fb \u500b\u5225\u306e\u30c7\u30fc\u30bf\u306b\u5bfe\u3059\u308b\u30e2\u30c7\u30eb\u306e\u4e88\u6e2c\u5024\u3078\u306e\u30df\u30af\u30ed\u306a\u89e3\u91c8\u306b\u52a0\u3048\u3066\u3001\u9069\u5207\u306a\u7c92\u5ea6\u3067\u5e73\u5747\u5316\u3057\u305f\u308a\u96c6\u8a08\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u3067\u30de\u30af\u30ed\u306a\u89e3\u91c8\u3082\u53ef\u80fd<\/p>\r\n<p>\u4e00\u65b9\u3067\u3001\u6b21\u306e\u3088\u3046\u306a\u9650\u754c\u3082\u3042\u308b\u305f\u3081\u6ce8\u610f\u3057\u3066\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u5927\u5207\u3067\u3059\u3002<\/p>\r\n<p style=\"padding-left: 40px\">\u30fb \u5927\u898f\u6a21\u306a\u30c7\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u9069\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u8a08\u7b97\u30b3\u30b9\u30c8\u304c\u5927\u304d\u3044\u3002<\/p>\r\n<p style=\"padding-left: 40px\">\u30fb \u8a08\u7b97\u65b9\u6cd5\u304c\u8907\u96d1\u3067\u3042\u308b\u305f\u3081\u3001\u4ed6\u306e\u624b\u6cd5\uff08Permutation Importance\u306a\u3069\uff09\u3068\u6bd4\u3079\u3066\u30e2\u30c7\u30eb\u4f7f\u7528\u8005\u3078\u306e\u8aac\u660e\u304c\u96e3\u3057\u3044\u3002<\/p>\r\n<p><!-- notionvc: b51a7b74-8046-458c-8327-39edf6809657 --><\/p>\n\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001SHAP\uff08SHapley Additive exPlanations\uff09\u306e\u8a08\u7b97\u65b9\u6cd5\u306e\u30a2\u30a4\u30c7\u30a2\u3084Python\u3067\u306e\u5b9f\u884c\u4f8b\u3001\u5229\u70b9\u3068\u8ab2\u984c\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002SHAP\u306f\u3001\u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\u306e\u4e88\u6e2c\u5024\u3092\u5404\u7279\u5fb4\u91cf\u306e\u8ca2\u732e\u5ea6\u306b\u5206\u89e3\u3059\u308b\u624b\u6cd5\u3067\u3042\u308a\u3001\u7279\u306b\u500b\u5225\u306e\u4e88\u6e2c\u5024\u306b\u5bfe\u3059\u308b\u89e3\u91c8\u304c\u53ef\u80fd\u3067\u3042\u308b\u3068\u3044\u3046\u5f37\u307f\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002\u4e00\u65b9\u3067\u3001\u8a08\u7b97\u30b3\u30b9\u30c8\u304c\u5927\u304d\u3044\u70b9\u3084\u975e\u5c02\u9580\u5bb6\u3078\u306e\u8aac\u660e\u304c\u96e3\u3057\u3044\u70b9\u306a\u3069\u3001\u3044\u304f\u3064\u304b\u306e\u9650\u754c\u3082\u5b58\u5728\u3057\u307e\u3059\u3002SHAP\u306e\u8ab2\u984c\u3092\u7406\u89e3\u3057\u305f\u3046\u3048\u3067\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u8aa4\u89e3\u3092\u62db\u304f\u30e2\u30c7\u30eb\u306e\u89e3\u91c8\u3092\u9632\u3050\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n<h2>\u53c2\u8003\u8cc7\u6599<\/h2>\n<p>\u68ee\u4e0b\uff082021\uff09\u300e\u6a5f\u68b0\u5b66\u7fd2\u3092\u89e3\u91c8\u3059\u308b\u6280\u8853\u300f\u6280\u8853\u8a55\u8ad6\u793e[blogcard url=&#8221;https:\/\/gihyo.jp\/book\/2021\/978-4-297-12226-3&#8243;]<!-- notionvc: e7d0da10-17c9-46e4-888e-89c57f364378 --><\/p>\r\n<p><span style=\"font-weight: 500\">Christoph Molnar (2024) Interpretable Machine Learning.<\/span>[blogcard url=&#8221;https:\/\/christophm.github.io\/interpretable-ml-book\/&#8221;]<\/p>","protected":false},"excerpt":{"rendered":"<p>\u6a5f\u68b0\u5b66\u7fd2\u30e2\u30c7\u30eb\u3092\u89e3\u91c8\u3059\u308b\u624b\u6cd5\u306e\u4e00\u3064\u3068\u3057\u3066\u3001\u300c\u4e88\u6e2c\u30e2\u30c7\u30eb\u306e\u7279\u5b9a\u306e\u51fa\u529b\u5024\u304c\u3069\u306e\u7279\u5fb4\u91cf\u306b\u3088\u3063\u3066\u3082\u305f\u3089\u3055\u308c\u305f\u306e\u304b\u300d\u3092\u8a08\u7b97\u3059\u308bSHAP\u304c\u3042\u308a\u307e\u3059\u3002\u672c\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001SHAP\u306e\u8a08\u7b97\u65b9\u6cd5\u3084Python\u306b\u3088\u308b\u5b9f\u884c\u4f8b\u3001\u5229\u70b9\u3068\u6ce8\u610f\u70b9\u306a\u3069\u306b\u3064 [&hellip;]<\/p>\n","protected":false},"author":46,"featured_media":5731,"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":[96,331,748,39,749],"class_list":["post-5729","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge","tag-ai","tag-python","tag-xai","tag-39"],"_links":{"self":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/5729","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\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/comments?post=5729"}],"version-history":[{"count":0,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/5729\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media\/5731"}],"wp:attachment":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media?parent=5729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/categories?post=5729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/tags?post=5729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}