Learn R Programming

mlr3 (version 0.9.0)

as_result_data: Manually construct an object of type ResultData

Description

This function allows to manually construct a ResampleResult or BenchmarkResult by combining the individual components to an object of class ResultData, mlr3's internal container object. A ResampleResult or BenchmarkResult can then be initialized with the returned object. Note that ResampleResults can be converted to a BenchmarkResult with as_benchmark_result() and multiple BenchmarkResults can be combined to a larger BenchmarkResult.

Usage

as_result_data(
  task,
  learners,
  resampling,
  iterations,
  predictions,
  learner_states = NULL
)

Arguments

task

(Task).

learners

(list of trained Learners).

resampling
iterations

(integer()).

predictions

(list of Predictions).

learner_states

(list()) Learner states. If not provided, the states of learners are automatically extracted.

Value

ResultData object which can be passed to the constructor of ResampleResult.

Examples

Run this code
# NOT RUN {
task = tsk("iris")
learner = lrn("classif.rpart")
resampling = rsmp("cv", folds = 2)$instantiate(task)
iterations = seq_len(resampling$iters)

# manually train two learners.
# store learners and predictions
learners = list()
predictions = list()
for (i in iterations) {
  l = learner$clone(deep = TRUE)
  learners[[i]] = l$train(task, row_ids = resampling$train_set(i))
  predictions[[i]] = l$predict(task, row_ids = resampling$test_set(i))
}

rdata = as_result_data(task, learners, resampling, iterations, predictions)
ResampleResult$new(rdata)
# }

Run the code above in your browser using DataLab