Python编程语言学习:shap.force_plot函数的源码解读之详细攻略
目录
shap.force_plot函数的源码解读
shap.force_plot(explainer.expected_value[1], shap_values[1][0,:], X_display.iloc[0,:])解读
shap.force_plot函数的源码解读 shap.force_plot(explainer.expected_value[1], shap_values[1][0,:], X_display.iloc[0,:])解读def force(base_value, shap_values=None, features=None, feature_names=None, out_names=None, link="identity", plot_cmap="RdBu", matplotlib=False, show=True, figsize=(20,3), ordering_keys=None, ordering_keys_time_format=None, text_rotation=0, contribution_threshold=0.05):
功能
Visualize the given SHAP values with an additive force layout.
使用附加力图布局可视化给定的 SHAP 值。
参数
Parameters
----------
base_value : float,This is the reference value that the feature contributions start from. For SHAP values it should be the value of explainer.expected_value.
这是特征贡献开始时的参考值。 对于SHAP值,它应该是 explainer.expected_value 的值。
shap_values : numpy.array,Matrix of SHAP values (# features) or (# samples x # features). If this is a 1D array then a single force plot will be drawn, if it is a 2D array then a stacked force plot will be drawn.
SHAP 值矩阵(# features)或(# samples x # features)。 如果这是一维数组,则将绘制单个力图,如果是二维数组,则将绘制堆叠力图。
features : numpy.array,Matrix of feature values (# features) or (# samples x # features). This provides the values of all the features, and should be the same shape as the shap_values argument.
特征值矩阵(# features)或(# samples x # features)。 这提供了所有特征的值,并且应该与shap_values参数的形状相同。