Description Usage Arguments Value Examples
View source: R/all_models_fit.R
Fit list of models on the entire dataset.
1 2 | all_models_fit(data, target, models, model_params, model_args,
preproc_funs)
|
data |
data.table with all input data. |
target |
Target variable name (character). |
models |
Named list of fit functions from |
model_params |
List of data.table's with tunable model parameters. |
model_args |
List of unchangeable model parameters. |
preproc_funs |
List of preprocessing functions (one function per model)
which takes data.table |
List of model objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # Input data
dt <- as.data.table(mtcars)
# List of models
models <- list("xgboost" = xgb_fit, "catboost" = catboost_fit)
# Model parameters (turn off early stopping)
xgb_params <- data.table(
max_depth = 6,
eta = 0.025,
colsample_bytree = 0.9,
subsample = 0.8,
gamma = 0,
min_child_weight = 5,
alpha = 0,
lambda = 1
)
xgb_args <- list(
nrounds = 50,
booster = "gbtree",
eval_metric = "rmse",
objective = "reg:linear",
verbose = 0
)
catboost_params <- data.table(
iterations = 100,
learning_rate = 0.05,
depth = 8,
loss_function = "RMSE",
eval_metric = "RMSE",
random_seed = 42,
logging_level = "Silent"
)
catboost_args <- NULL
model_params <- list(xgb_params, catboost_params)
model_args <- list(xgb_args, catboost_args)
# Dumb preprocessing function
# Real function will contain imputation, feature engineering etc.
# with all statistics computed on train folds and applied to validation fold
preproc_fun_example <- function(data) return(data[])
# List of preprocessing fuctions for each model
preproc_funs <- list(preproc_fun_example, preproc_fun_example)
all_models <- all_models_fit(data = dt,
target = "hp",
models = models,
model_params = model_params,
model_args = model_args,
preproc_funs = preproc_funs)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.