| proj_results | R Documentation |
proj_results globs the RDS result files in the project
directory, and combines them into a result table via rbindlist().
proj_results_save saves that result table to results.rds
and results.csv.
proj_results(proj_dir)
proj_results_save(proj_dir)
proj_dir |
Project directory created via |
This is Step 3 out of the typical 3 step pipeline (init grid, submit, read results).
Actually, if step 2 worked as intended, the last proj_compute
calls proj_results_save, which saves up to three result files to disk
that you can read directly:
results.csvcontains test measures for each split, and
can be read via fread()
results.rdscontains additional list columns for learner
and pred (useful for model interpretation), and can be read via
readRDS()
learners.csvonly exists if learner column is a
data frame, in which case it contains the atomic columns, along
with meta-data describing each split.
proj_results returns a data table with all columns, whereas
proj_results_save returns the same table with only atomic columns.
Toby Dylan Hocking
N <- 80
library(data.table)
set.seed(1)
reg.dt <- data.table(
x=runif(N, -2, 2),
person=factor(rep(c("Alice","Bob"), each=0.5*N)))
reg.pattern.list <- list(
easy=function(x, person)x^2,
impossible=function(x, person)(x^2)*(-1)^as.integer(person))
SOAK <- mlr3resampling::ResamplingSameOtherSizesCV$new()
reg.task.list <- list()
for(pattern in names(reg.pattern.list)){
f <- reg.pattern.list[[pattern]]
task.dt <- data.table(reg.dt)[
, y := f(x,person)+rnorm(N, sd=0.5)
][]
task.obj <- mlr3::TaskRegr$new(
pattern, task.dt, target="y")
task.obj$col_roles$feature <- "x"
task.obj$col_roles$stratum <- "person"
task.obj$col_roles$subset <- "person"
reg.task.list[[pattern]] <- task.obj
}
reg.learner.list <- list(
featureless=mlr3::LearnerRegrFeatureless$new())
if(requireNamespace("rpart")){
reg.learner.list$rpart <- mlr3::LearnerRegrRpart$new()
}
pkg.proj.dir <- tempfile()
mlr3resampling::proj_grid(
pkg.proj.dir,
reg.task.list,
reg.learner.list,
SOAK,
order_jobs = function(DT)1:2, # for CRAN.
score_args=mlr3::msrs(c("regr.rmse", "regr.mae")))
mlr3resampling::proj_compute_until_done(pkg.proj.dir)
fread(file.path(pkg.proj.dir, "results.csv"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.