我目前正在使用SHAP库,我已经使用每个要素的平均贡献生成了图表,但是我想知道绘制在图表上的确切值
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.datasets import load_boston
import shap
boston = load_boston()
regr = pd.DataFrame(boston.data)
regr.columns = boston.feature_names
regr['MEDV'] = boston.target
X = regr.drop('MEDV', axis = 1)
Y = regr['MEDV']
fit = LinearRegression().fit(X, Y)
explainer = shap.LinearExplainer(fit, X, feature_dependence = 'independent')
# I used 'independent' because the result is consistent with the ordinary
# shapely values where `correlated' is not
shap_values = explainer.shap_values(X)
shap.summary_plot(shap_values, X, plot_type = 'bar')
如何获得图表中描述的确切值?
3条答案
按热度按时间wpcxdonn1#
参考GitHub
brvekthn2#
试试看:
avwztpqn3#
所选答案错误,标签不正确。
以下是更正后的版本: