| 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 one or more CSV files (redundant with RDS data, but more
convenient).
proj_fread reads the CSV files, adding columns from
results.csv to learners*.csv.
proj_results(proj_dir, verbose=FALSE)
proj_results_save(proj_dir, verbose=FALSE)
proj_fread(proj_dir)
proj_dir |
Project directory created via
|
verbose |
logical: cat progress? (default FALSE) |
This is Step 3 out of the typical 3 step pipeline (init grid, submit, read results).
Actually, if step 2 worked as intended, then
proj_results_save is called at the end of step 2,
which saves result files to disk that you can read directly:
results.csvcontains test measures for each split.
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.
learners_*.csvonly exists if learner column is
a named list of data frames: star in file name is expanded using
list names, with CSV data taken from atomic columns.
proj_results returns a data table with all columns, whereas
proj_results_save returns the same table with only atomic columns.
proj_fread returns a list
with names corresponding to CSV files in the test directory, and
values are the data tables that result from fread.
Toby Dylan Hocking
N <- 80
library(data.table)
set.seed(1)
reg.dt <- data.table(
x=runif(N, -2, 2),
noise=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 <- c("x","noise")
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,
save_learner=function(L){
if(inherits(L, "LearnerRegrRpart")){
list(rpart=L$model$frame)
}
},
order_jobs = function(DT)which(DT$iteration==1)[1:2], # for CRAN.
score_args=mlr3::msrs(c("regr.rmse", "regr.mae")))
computed <- mlr3resampling::proj_compute_all(pkg.proj.dir)
result_list <- mlr3resampling::proj_fread(pkg.proj.dir)
result_list$learners_rpart.csv # one row per node in decision tree.
result_list$results.csv # test error in regr.* columns.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.