代码之家  ›  专栏  ›  技术社区  ›  mans

SHAP:dependence_plot无法处理与函数内部深处相关的错误

  •  0
  • mans  · 技术社区  · 2 年前

    我有这个代码:

    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.
    

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

    如何解决此问题?

    0 回复  |  直到 2 年前
        1
  •  1
  •   Rahul Rahatal liz liu    2 年前

    尝试降级 matplotlib 3.2.2 或者明确地设置interaction_ index对我有效。

    推荐文章