hfshr / distill_blog

Blog and things
https://hfshr.xyz
9 stars 2 forks source link

posts/2020-06-07-variable-importance-with-fastshap/ #9

Open utterances-bot opened 9 months ago

utterances-bot commented 9 months ago

Data, Code & Coffee - Opening the black box: Exploring xgboost models with {fastshap} in R

Being able to understand and explain why a model makes certain predictions is important, particularly if your model is being used to make critical business decisions. This post takes a look into the inner workings of a xgboost model by using the {fastshap} package to compute shapely values for the different features in the dataset, allowing deeper insight into the models predictions.

https://www.hfshr.xyz/posts/2020-06-07-variable-importance-with-fastshap/

jgarrigan commented 9 months ago

Hi Harry, thanks for the great content. I'm exploring the fastshap package for my xgboost model in tidymodels and came across your blog while searching for help. I'm trying to run your code and I'm stuck at the autoplot of the shap object, I'm getting an error when I run autoplot(shap) which is "Objects of class are not supported by autoplot". Would you have any guidance on how I can resolve this? Thanks in advance. John

hfshr commented 9 months ago

Hi @jgarrigan, looks like fastshap has moved on somehwat since I last used it, I was able to use the autoplot function by installing an older version of fastshap

devtools::install_version("fastshap", "0.0.5") 

Seems like the newest version of fastshap has depricated autoplot in favour of using the shapviz package as noted here: https://bgreenwell.github.io/fastshap/news/index.html , so you might have some luck with this approach if you can adapt the code from the blog.

Hope that helps!

jgarrigan commented 8 months ago

Thanks Harry, I'll check out the shapviz package. Thanks again for the great content.