linkedin / linkedin/FastTreeSHAP
The notebook example is not working
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 566
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
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)
in ()
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the notebook example that contains the shown TreeExplainer and num_leaves snippet, then reproduce the AttributeError with LightGBM 3.3.5. Update the example so it runs with that version and verify the notebook completes while reporting the total number of leaves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100