Learn R Programming

rtemis (version 1.4.3)

plot_varimp: Plot a Model's Variable Importance

Description

Draw importance recorded by a rtemis Supervised or SupervisedRes object, or computed from a SHAP explanation by get_varimp, using rtemis.draw::draw_varimp().

Usage

plot_varimp(x, ...)

Value

htmlwidget: ECharts importance bars or fold distributions.

Arguments

x

rtemis::Supervised, rtemis::SupervisedRes or rtemis::SHAP: Fitted model result or explanation.

...

Additional arguments to rtemis.draw::draw_varimp(), including measure, type, top_n, rank_by, decreasing, bar_width, summary, and title. Fold IDs come from the model and cannot be overridden.

Details

Named measures and variable identities are preserved. Resampled records retain their fold IDs before summarizing. The first measure in the first available fold is selected when measure is omitted; columns missing in other folds are unavailable scores. The full fold list is passed to the renderer, including folds with no importance result.

Every producer reports a value for each predictor it scores, including zeros, so an NA value or a wholly unavailable fold is an unavailable score and is excluded from the summary. varimp_ranking() returns the summary and ranking drawn here.

Use type = "boxplot" for resampled fold distributions with all contributing scores overlaid. Summary bars remain the default. Both views share selection, ranking, and missing-score handling. Ordinary models have no fold distribution and require the bar view.

A SHAP explanation is drawn from the mean absolute contribution of each feature, with one measure per class for a multiclass outcome.

Models without any importance records produce an informative error. The default title names the algorithm; title = NULL omits it. See rtemis.draw::draw_varimp() for selection, ranking, and missing-score semantics.

Examples

Run this code
if (FALSE) { # interactive()
model <- train(
  mtcars[, c("wt", "hp", "mpg")],
  hyperparameters = setup_GLM(), verbosity = 0L
)
plot_varimp(model)
features <- mtcars[, c("wt", "hp")]
plot_varimp(explain(model, features, background = features, verbosity = 0L))
}

Run the code above in your browser using DataLab