Learn R Programming

ASML (version 1.1.0)

AStrain.as_data: Training models for posterior selection of algorithms

Description

For each algorithm (column) in the data, a model is trained to later predict the output (KPI) for that algorithm (using function ASpredict()).

Usage

# S3 method for as_data
AStrain(data_object, method = NULL, parallel = FALSE, f = NULL, ...)

Value

A list is returned of class as_train containing the trained models, one for each of the algorithms.

Arguments

data_object

object of class as_data.

method

name of the model to be used. The user can choose from any of the models provided by caret. See http://topepo.github.io/caret/train-models-by-tag.html for more information about the models supported.

parallel

boolean to control whether to parallelise the training or not (paralellization is handled by library snow).

f

function we want to use to train the models. If NULL, caret's function will be used.

...

arguments passed to the caret train function.

Examples

Run this code
data(branchingsmall)
# Partition and normalize the data
data_object <- partition_and_normalize(branchingsmall$x, branchingsmall$y, test_size = 0.3,
family_column = 1, split_by_family = TRUE)

# Example: training a regression decision tree
# with cross-validation control and basic hyperparameter tuning
train_control <- caret::trainControl(method = "cv", number = 5)
tune_grid <- expand.grid(cp = c(0.01, 0.05, 0.1))
training <- AStrain(
  data_object,
  method = "rpart",
  trControl = train_control,
  tuneGrid = tune_grid
)

# Example: training with glm and similar with custom function
training <- AStrain(data_object, method = "glm")

custom_function <- function(x, y) {
  glm.fit(x, y)
}
custom_training <- AStrain(data_object, f = "custom_function")

Run the code above in your browser using DataLab