-1

我有这个代码:

import pandas as pd
import shap
import xgboost 

df = pd.read_clipboard(sep=",")
labels=df.pop('target')

model = xgboost.XGBClassifier().fit(df, labels)

# compute SHAP values
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(df)

df=df.apply(pd.to_numeric)
shap.dependence_plot(1, shap_values, df)

我的数据是:

Cat1,Cat2,Age,Cat3,Cat4,target
0,0,18,1,0,1
0,0,17,1,0,1
0,0,15,1,1,1
0,0,15,1,0,1
0,0,16,1,0,1
0,1,16,1,1,1
0,1,16,1,1,1
0,0,17,1,0,1
0,1,15,1,1,1
0,1,15,1,0,1
0,0,15,1,0,1
0,0,15,1,0,1
0,1,15,1,1,1
0,1,15,1,0,1
0,1,15,1,0,1
0,0,16,1,0,1
0,0,16,1,0,1
0,0,16,1,0,1
0,1,17,1,0,0
0,1,16,1,1,1
0,1,15,1,0,1
0,1,15,1,0,1
0,1,16,1,1,1
0,1,16,1,1,1
0,0,15,0,0,1
0,0,16,1,0,1
0,1,15,1,0,1

当我运行此代码时,我收到此错误:

Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it.

错误在这个函数的深处,我不确定我的数据如何改变它。

我该如何解决这个问题?

4

1 回答 1

1

尝试将matplotlib降级到3.2.2或明确设置 interaction_index 对我有用。

于 2022-01-11T10:28:42.190 回答