본문 바로가기
Data Insider

[SHAP][python] waterfall.plot 'numpy.ndarray' object has no attribute 'base_values'이슈 해결

by Chandler.j 2022. 8. 12.
반응형

fig1. title

- shap.plots.waterfall

shap.plots.waterfall(shap_values[0])

 

https://shap.readthedocs.io/en/latest/example_notebooks/api_examples/plots/waterfall.html

 

에러남

AttributeError: 'numpy.ndarray' object has no attribute 'base_values'

AttributeError: 'numpy.ndarray' object has no attribute 'base_values'


- in my case(SHAP version 0.39.0)

# waterfall plot

#method1
shap.plots._waterfall.waterfall_legacy(shap.TreeExplainer(model=model_new, data=X_test_features_ev, model_output='probability').expected_value, shap_values_t3[534])

# method2
explainer = shap.TreeExplainer(model=model_new, data=X_test_features_ev, model_output='probability')
shap.plots._waterfall.waterfall_legacy(explainer.expected_value, shap_values_t3[534])

 

 

 


TOP

Designed by 티스토리