天天看點

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.