andosa / treeinterpreter

BSD 3-Clause "New" or "Revised" License
745 stars 140 forks source link

AxisError: axis 1 is out of bounds for array of dimension 1 while using RandomForestClassifier #19

Open erastogi opened 6 years ago

erastogi commented 6 years ago

here is the code to replicate the issue: inp = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])

model = sklearn.ensemble.RandomForestClassifier().fit(inp, [1,1,0,0]) predictions, bias, contributions = ti.predict(model, inp)

Error occurs at line 63 in treeinterpreter.py in _predict_tree(model, X, joint_contribution)

This is because not all model.estimator return tree values as 2D.

Marcnuth commented 5 years ago

This bug is fixed in the latest version, try to update.