0

How do I get importance scores? I tried this:

task = tsk("iris")
search_space = ParamSet$new(
  params = list(
  ParamDbl$new(id = "eta", lower = 0.2, upper = .4)))

at = AutoTuner$new(
  learner = lrn("classif.xgboost"),
  resampling = rsmp("holdout"),
  measure = msr("classif.ce"),
  terminator = trm("evals", n_evals = 2),
  tuner = tnr("grid_search"),
  search_space = search_space,
  store_tuning_instance = TRUE)

at$train(task)
at$importance
at$importance()

but it seems not to work.

Nip
  • 387
  • 4
  • 11

1 Answers1

2

You need to get the importance from the learner, not the tuner:

> at$learner$importance()
 Petal.Width Petal.Length 
   0.5028937    0.4971063
Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
  • When using a `GraphLearner`, https://stackoverflow.com/questions/66267945/importance-based-variable-reduction might be helpful. – Nip Aug 06 '21 at 19:54
  • 2
    Also note that the mlr3 team is working in simplifying this by implementing `$importance()` for `AutoTuner` and `GraphLearner`. – Michel Aug 09 '21 at 08:31