FastTreeSHAP
FastTreeSHAP copied to clipboard
The notebook example is not working
I tried to run the notebook example with the following code snippet:
shap_explainer = fasttreeshap.TreeExplainer(lgb_model)
num_leaves = sum(shap_explainer.model.num_nodes) - sum(sum(shap_explainer.model.children_left > 0))
print("Total number of leaves is {}.".format(num_leaves))
But got the error:
AttributeError Traceback (most recent call last)
<command-4123838717328114> in <cell line: 2>()
1 shap_explainer = fasttreeshap.TreeExplainer(lgb_model)
----> 2 num_leaves = sum(shap_explainer.model.num_nodes) - sum(sum(shap_explainer.model.children_left > 0))
3 print("Total number of leaves is {}.".format(num_leaves))
AttributeError: 'TreeEnsemble' object has no attribute 'num_nodes'
The lightbgm library version is '3.3.5'. Maybe you want to update the notebook correspondingly.