Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
145 views
in Technique[技术] by (71.8m points)

r - How to access parameters fitted by benchmark?

This is a really basic question, but I haven't found the answer on other sites, so I am kind of forced to ask about it here.

I fitted my "classif.ranger" learner usin benchmark(design,store_models) function form mlr3 library and I need to acces the fitted parameters (obv). I found nothing about it in the benchmark documentation, so I tried to do it the hard way: -> I set store_models to TRUE -> I tried to acces the model using fitted(), but it returned NULL.

I know the question is basic and that I probably am doing smth stupid (for ex. misreading the documentation or smth like that) but I just have no idea of how to acctualy access the parameters... please help.

If it is needed in such (probably) trivial situation, here comes the code:

library(data.table)
library(mlr3)
library(mlr3learners)
library(mlr3filters)
library(mlr3fselect)
library(mlr3tuning)
library(ranger)
library(paradox)

Here is some code that is irrelevant to the question Now the relevant code:

measure = msr("classif.auc")

tuner = tnr("random_search")

ranger_space = ParamSet$new(list(
  ParamInt$new("num.trees", lower = 700, upper = 2000),
  ParamInt$new("mtry", lower = 1, upper = 15)
))

rf_learner <- lrn("classif.ranger", predict_type = "prob")

at = AutoTuner$new(
    learner = rf_learner,
    resampling = rsmp("holdout"),
    measure = measure,
    search_space = ranger_space,
    terminator = trm("evals", n_evals = 25),
    tuner = tuner
  )

pred_task <- TaskClassif$new(id = "predict", backend = dataSet, target = "will_it_sell")

grid = benchmark_grid(
    task = pred_task,
    learner = list(at, rf_learner),
    resampling = rsmp("cv", folds = 3)
  )
  
rf_benchmark = benchmark(design = grid, store_models = TRUE)
result = rf_benchmark$aggregate(measure)
result
question from:https://stackoverflow.com/questions/65835419/how-to-access-parameters-fitted-by-benchmark

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The mlr3book is the documentation for mlr3 and it has a section about your question: https://mlr3book.mlr-org.com/benchmarking.html#bm-resamp

And please do not mix R and RStudio, they are two different things. RStudio never has any function.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...