Search code examples
rmlr3

Where does mlr3 save the final model?


Where does mlr3 save the final model, after training a learner --- learner$train(data)? By "final model", I mean something like a list produced by the following code:

model <- xgboost::xgb.train(data = data_train, 
                                   max.depth = 8, nthread = 2, nrounds = 15,
                                   verbose = 0)  

Is there a way to extract this list/object?


task <- TaskRegr$new("data", data, "y")
learner <- lrn("regr.xgboost")
preprocess <- po("scale", param_vals = list(center = TRUE, scale = TRUE))
pp <- preprocess %>>% learner
gg<- GraphLearner$new(pp)
gg$train(task)

Solution

  • In xgboost the 'model' is stored as:

    model <- xgboost::xgb.train(data = data_train, 
                                       max.depth = 8, nthread = 2, nrounds = 15,
                                       verbose = 0)
    

    In MLR3, when trained using:

    task <- TaskRegr$new("data", data, "y")
    learner <- lrn("regr.xgboost")
    preprocess <- po("scale", param_vals = list(center = TRUE, scale = TRUE))
    pp <- preprocess %>>% learner
    gg<- GraphLearner$new(pp)
    gg$train(task)
    

    The equivalent to 'model' is stored as

    gg$model$regr.xgboost$model