Can we optain VIP()- variable importance from lightGbm or catBoost the tidy-way?

If anybody is interested in doing it without vip with catBoost/treesnip/tidymodels...

myModel<-extract_fit_engine(final_fitted_wf)
impObj <- catboost.get_feature_importance(myModel, 
  pool = NULL, 
  type = 'FeatureImportance',
  thread_count = -1)

Output (pretty ugly):
[,1]
ms_sub_class 1.24522954
ms_zoning 1.12307172
lot_frontage 2.94193678
lot_area 2.01862041
lot_shape 0.90817355
lot_config 0.35386407
[...]

PS: Suprise suprise...this also works with lightGbm/treesnip/tidymodels...

myModel<-extract_fit_engine(final_fitted_wf); impObj <- lgb.importance(myModel, percentage =FALSE)

Output (pretty fine):
Feature Gain Cover Frequency
1: myXreg32 28304.0115 39998 72
2: myXreg52 14347.0080 23272 41
3: myXreg31 10914.2301 34374 56
4: myXreg33 10746.1890 53054 96
5: myXreg7 10681.6466 30822 54
6: myXreg4 10121.8224 34187 60
7: myXreg46 9604.2502 30287 54
8: myXreg23 9591.9631 40724 72
9: myXreg6 9545.2380 47203 84
10: myXreg17 9544.5662 34146 58
[...]

1 Like