The variable importance measures a fitted model reports, or the mean
absolute contribution of each predictor in a SHAP explanation.
Value
VariableImportance object, a list of them (one per resample) for
a SupervisedRes, or NULL when the algorithm reports no importance.
Details
A VariableImportance object holds its measures by name in @measures.
Each measure states what it quantifies (@kind, for example split gain,
permutation, or coefficient), the cases it was computed on
(@computed_on), whether its values can be negative (@signed) or depend
on the units of the predictors (@scale_dependent), how it ranks
predictors (@direction), and what its values are for this model
(@description); @values holds the value for each predictor.
varimp_table combines the measures into one data.frame.
Examples
mod <- train(iris, hyperparameters = setup_LightRF())#> 2026-10-20 09:07:51
#> Checking data is ready for training...
#>
#> ✔
#> [check_supervised]
#> 2026-10-20 09:07:51
#> ▶
#> [train]
#> 2026-10-20 09:07:51
#> Training set: 150 cases x 4 features.
#> [summarize_supervised]
#> 2026-10-20 09:07:51
#> // CPU (auto-selected) | future (mirai_multisession) | 7 workers: algorithm 7 threads, tuning 1, outer resampling 1
#> [msg_resources]
#> 2026-10-20 09:07:51
#> Shared memory (auto): not sharing training data (7.3 kB) -- this run transfers nothing to workers.
#> [report_shared_memory]
#> 2026-10-20 09:07:51
#> Training LightRF Classification...
#> [train]
#> 2026-10-20 09:07:51
#> Checking data is ready for training...
#>
#> ✔
#> [check_supervised]
#> 2026-10-20 09:07:51
#> Converting 1 factor to integer...
#> [preprocess_data]
#> 2026-10-20 09:07:51
#> Preprocessing done.
#> [preprocess_data]
#>
#> <Classification>
#> LightRF (LightGBM random forest)
#>
#> <Training Classification Metrics>
#> Predicted
#> Reference setosa versicolor virginica
#> setosa 50 0 0
#> versicolor 1 44 5
#> virginica 0 1 49
#>
#> Overall
#> Balanced Accuracy 0.953
#> F1 0.953
#> Accuracy 0.953
#> Setosa Versicolor Virginica
#> Sensitivity 1.000 0.880 0.980
#> Specificity 0.990 0.990 0.950
#> Balanced Accuracy 0.995 0.935 0.965
#> PPV 0.980 0.978 0.907
#> NPV 1.000 0.943 0.990
#> F1 0.990 0.926 0.942
#>
#> 2026-10-20 09:07:53
#> Done in 1.70 seconds.
#> [train]get_varimp(mod)#> <VariableImportance>
#> Gain (split_gain, 4 entries): Share of the total gain of all splits, over all trees, that comes from splits on the predictor, on the training cases (lightgbm). Predictors in no split are omitted.
#> Cover (split_cover, 4 entries): Share of the training cases reaching split nodes, summed over all splits of all trees, that reach splits on the predictor (lightgbm). Predictors in no split are omitted.
#> Frequency (split_frequency, 4 entries): Share of all splits, over all trees, that use the predictor (lightgbm). Predictors in no split are omitted.