LOCO: Leave-One-Covariate-Out (LOCO)

LOCOR Documentation

Leave-One-Covariate-Out (LOCO)

Description

Calculates Leave-One-Covariate-Out (LOCO) scores.

Details

LOCO measures feature importance by comparing model performance with and without each feature. For each feature, the model is retrained without that feature and the performance difference (reduced_model_loss - full_model_loss) indicates the feature's importance. Higher values indicate more important features.

Super classes

xplainfi::FeatureImportanceMethod -> xplainfi::WVIM -> LOCO

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage
LOCO$new(
  task,
  learner,
  measure = NULL,
  resampling = NULL,
  features = NULL,
  n_repeats = 30L
)
Arguments
task

(mlr3::Task) Task to compute importance for.

learner

(mlr3::Learner) Learner to use for prediction.

measure

(mlr3::Measure: NULL) Measure to use for scoring. Defaults to classif.ce for classification and regr.mse for regression.

resampling

(mlr3::Resampling) Resampling strategy. Defaults to holdout.

features

(character()) Features to compute importance for. Defaults to all features.

n_repeats

(integer(1): 30L) Number of refit iterations per resampling iteration.


Method compute()

Compute LOCO importances.

Usage
LOCO$compute(store_models = TRUE, store_backends = TRUE)
Arguments
store_models, store_backends

(logical(1): TRUE) Whether to store fitted models / data backends, passed to mlr3::resample internally


Method clone()

The objects of this class are cloneable with this method.

Usage
LOCO$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

Lei J, G'Sell M, Rinaldo A, Tibshirani R, Wasserman L (2018). “Distribution-Free Predictive Inference for Regression.” Journal of the American Statistical Association, 113(523), 1094–1111. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2017.1307116")}.

Examples

library(mlr3)
library(mlr3learners)

task <- sim_dgp_correlated(n = 500)

loco <- LOCO$new(
  task = task,
  learner = lrn("regr.rpart"),
  measure = msr("regr.mse"),
  n_repeats = 5
)
loco$compute()
loco$importance()

xplainfi documentation built on Feb. 27, 2026, 1:08 a.m.