Learn R Programming

modeval (version 0.1.3)

add_model: Add predictive models to Summary list.

Description

add_model Conduct model training and add each model fit to a summary list. The function ensures that the model and data supports classification. If model supports class probability, then the best model is choosen based on AUC. If model doesnt support class probabilities, the best model is choosen based on accuracy. We use 10-fold cross validation by default.

Usage

add_model(addTo, x, y, model = NULL, tuneLength = 5L, modelTag = NULL,
  tf = NULL, sampling = NULL)

Arguments

addTo
Summary list that will contain all model fit results.
x
A dataframe of input variables.
y
A vector or a dataframe of output variable.
model
A vector of model names to train.
tuneLength
the maximum number of tuning parameter combinations that will be generated by the random search
modelTag
A charactor value of tag that to be added to model name.
tf
A single charactor value for transformation options. tf1, tf2, and tf3. For details, see the suggest_transformation function.
sampling
A single character value to pass caret::trainControl. Values are "none", "down", "up", "smote", or "rose". The latter two values require the DMwR and ROSE packages, respectively.

Value

If input model and data supports classification, then the results of each model fittings are added to the summary list.

Examples

Run this code
## Not run: ------------------------------------
# library(mlbench)
# data(PimaIndiansDiabetes)
# index <- sample(seq_len(nrow(PimaIndiansDiabetes)), 500)
# trainingSet <- PimaIndiansDiabetes[index, ]
# testSet <- PimaIndiansDiabetes[-index, ]
# x <- trainingSet[, -9]
# y <- trainingSet[, 9]
# x_test <- testSet[, -9]
# y_test <- testSet[, 9]
# 
# sSummary <- list()
# sSummary <- add_model(sSummary, x, y)
# sSummary <- add_model(sSummary, x, y, model = c("C5.0Cost", "glmnet"), modelTag = "others")
# 
# # vignette("modeval") #check a vignette for further details
## ---------------------------------------------

Run the code above in your browser using DataLab