ModelOriented / treeshap

Compute SHAP values for your tree-based models using the TreeSHAP algorithm
https://modeloriented.github.io/treeshap/
GNU General Public License v3.0
78 stars 23 forks source link

randomForest.unify error #23

Closed wilkinbp closed 1 year ago

wilkinbp commented 1 year ago

I am trying to unify my random forest model using the available function but am consistently getting the same error, "Error in Prediction/n : non-numeric argument to binary operator"

The random forest model is a binary classifier. I have ensured that there are no categorical variables in the predictor data (i.e., the data is completely numeric) and that all NA values have been removed. I have also reconstructed the random forest so that the labels for the binary classification are "0" and "1" respectively, to see if that made a difference. What is perplexing to me is that, within the randomForest package, the "predict" function executes just fine and gives a correct output.

Any idea where the error is originating and how to fix it? Thanks!

MargjeSchuur commented 1 year ago

I have the same issue when explaining a randomForest classification model. As far as I can see it is due to the fact that the target has to be a factor value and it ends up as such in the attribute list. All my other feautures are numerc. Fooling the message leads to an error later on. So currently it only works for regression, I guess?! I would love to use treeshap in R to explain classification models and cannot wait to see extended functionality on this. Margje

gibsok commented 1 year ago

Also having this same Issue.

krzyzinskim commented 1 year ago

@wilkinbp, @MargjeSchuur, @gibsok
randomForest.unify() function should now (https://github.com/ModelOriented/treeshap/pull/30) work for randomForest binary classifier that have a target that is a factor with levels 0 and 1.