mlr-org / mlr3

mlr3: Machine Learning in R - next generation
https://mlr3.mlr-org.com
GNU Lesser General Public License v3.0
947 stars 85 forks source link

feat: add function to extract information from a model #1213

Open be-marc opened 2 days ago

be-marc commented 2 days ago

Closes https://github.com/mlr-org/mlr3/issues/1013 and https://github.com/mlr-org/mlr3/issues/899

be-marc commented 1 day ago
learner = lrn("classif.rpart")
task = tsk("iris")
resampling = rsmp("cv", folds = 3)

extractor = function(learner) list(selected_features = setdiff(learner$model$frame$var, "<leaf>"))

rr = resample(task, learner, resampling, extractor = extractor)
rr$learners[[1]]$state$selected_features