mlr3在哪里保存最终模型?

时间:2020-10-08 01:11:18

标签: r mlr3

训练了学习者-mlr3之后,learner$train(data)在哪里保存最终模型? “最终模型”是指类似于以下代码生成的列表:

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

有没有办法提取此列表/对象?


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)

1 个答案:

答案 0 :(得分:2)

在xgboost中,“模型”存储为:

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

在MLR3中,使用以下方法进行训练:

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)

相当于“模型”的存储为

gg$model$regr.xgboost$model