Skip to content

Commit

Permalink
Better error message when _cext is missing
Browse files Browse the repository at this point in the history
Addresses #96
  • Loading branch information
slundberg committed May 22, 2018
1 parent da3380e commit 7f95ae8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run_setup(with_binary):

setup(
name='shap',
version='0.16.1',
version='0.16.2',
description='A unified approach to explain the output of any machine learning model.',
url='http://github.com/slundberg/shap',
author='Scott Lundberg',
Expand Down
5 changes: 4 additions & 1 deletion shap/explainers/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import multiprocessing
import sys

have_cext = False
try:
from .. import _cext
have_cext = True
except ImportError:
pass
except:
Expand Down Expand Up @@ -167,8 +169,8 @@ def _tree_shap_ind(self, i):
return phi

def tree_shap(self, tree, x, x_missing, phi, condition=0, condition_feature=0):

# start the recursive algorithm
assert have_cext, "C extension was not built during install!"
_cext.tree_shap(
tree.max_depth, tree.children_left, tree.children_right, tree.children_default, tree.features,
tree.thresholds, tree.values, tree.node_sample_weight,
Expand All @@ -187,6 +189,7 @@ def __init__(self, children_left, children_right, children_default, feature, thr
self.node_sample_weight = node_sample_weight

# we compute the expectations to make sure they follow the SHAP logic
assert have_cext, "C extension was not built during install!"
self.max_depth = _cext.compute_expectations(
self.children_left, self.children_right, self.node_sample_weight,
self.values
Expand Down

0 comments on commit 7f95ae8

Please sign in to comment.