天天看点

Python编程语言学习:shap.force_plot函数的源码解读之详细攻略

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.