| Model_data | R Documentation | 
R6 class to represent data to be used in estimating a model
R6 class to represent data to be used in estimating a model
This class provides consistent names and interfaces to data which will be used in a supervised regression / classification model.
labelThe labels for the eventual model as a vector.
featuresThe matrix representation of the data to be used for model fitting.
Constructed using stats::model.matrix.
model_frameThe data-frame representation of the data as constructed by
stats::model.frame.
split_idThe split identifiers as a vector.
num_splitsThe integer number of splits in the data.
clusterA cluster ID as a vector, constructed using the unit identifiers.
weightsThe case-weights as a vector.
new()Creates an R6 object to represent data to be used in a prediction model.
Model_data$new(data, label_col, ..., .weight_col = NULL)
dataThe full dataset to populate the class with.
label_colThe unquoted name of the column to use as the label in supervised learning models.
...The unquoted names of features to use in the model.
.weight_colThe unquoted name of the column to use as case-weights in subsequent models.
A Model_data object.
library("dplyr")
df <- dplyr::tibble(
    uid = 1:100,
    x1 = rnorm(100),
    x2 = rnorm(100),
    x3 = sample(4, 100, replace = TRUE)
) %>% dplyr::mutate(
    y = x1 + x2 + x3 + rnorm(100),
    x3 = factor(x3)
)
df <- make_splits(df, uid, .num_splits = 5)
data <- Model_data$new(df, y, x1, x2, x3)
SL_cv_control()A helper function to create the cross-validation options to be used by SuperLearner.
Model_data$SL_cv_control()
clone()The objects of this class are cloneable with this method.
Model_data$clone(deep = FALSE)
deepWhether to make a deep clone.
SuperLearner::SuperLearner.CV.control
## ------------------------------------------------
## Method `Model_data$new`
## ------------------------------------------------
library("dplyr")
df <- dplyr::tibble(
    uid = 1:100,
    x1 = rnorm(100),
    x2 = rnorm(100),
    x3 = sample(4, 100, replace = TRUE)
) %>% dplyr::mutate(
    y = x1 + x2 + x3 + rnorm(100),
    x3 = factor(x3)
)
df <- make_splits(df, uid, .num_splits = 5)
data <- Model_data$new(df, y, x1, x2, x3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.