Learn R Programming

EZtune (version 1.0.0)

eztune: Supervised Learning Function

Description

eztune is a single function that will tune adaboost, support vector machines, and gradient boosting machines. It currently only tunes models with a binary response. An optimizer is used to find a good set of tuning parameters for the selected model. The function optimizes on either the resubstitution accuracy or the cross-validated accuracy.

Usage

eztune(x, y, type = "binary", method = "ada", optimizer = "optim",
  cv = FALSE, fold = 10)

Arguments

x

Matrix or data frame containing the dependent variables.

y

Numeric vector of 0s and 1s for the response.

type

Type of response (binary is the only option at this time).

method

Model to be fit. Choices are "ada" for adaboost, "gbm" for gradient boosting machines, and "svm" for support vector machines.

optimizer

Optimization method. Options are "ga" to use a genetic algorithm to optimize and "optim" to use a quasi-Newton-Raphson optimizer.

cv

Indicates if the cross-validation accuracy should be used to fit. FALSE to use resubstitution accuracy to optimize (faster but less accurate) and TRUE to use cross-validation accuracy (slower and more accurate).

fold

The number of folds to use for n-fold cross validation. This is ignored if cv = FALSE.

Value

Function returns a summary of the fitted tuning parameters, the accuracy, and the best model.

summary

Matrix that contains the values of the tuning parameters and the final accuracy.

accuracy

Best accuracy obtained by optimizing algorithm.

best.model

Model using optimized parameters. Adaboost model comes from package ada, gbm model comes from package gbm, svm model comes from package e1071.

iter

Tuning parameter for adaboost.

nu

Tuning parameter for adaboost.

loss

Loss used in adaboost fitting.

interaction.depth

Tuning parameter for gbm.

n.trees

Tuning parameter for gbm.

shrinkage

Tuning parameter for gbm.

cost

Tuning parameter for svm.

epsilon

Tuning parameter for svm.

kernel

Kernel used in svm fitting.

Examples

Run this code
# NOT RUN {
library(mlbench)
data(Glass)

glass <- Glass[as.numeric(as.character(Glass$Type)) < 3, ]
glass <- glass[sample(1:nrow(glass), 80), ]
y <- ifelse(glass$Type == 1, 0, 1)
x <- glass[, 1:9]

eztune(x, y, type = "binary", method = "gbm", optimizer = "optim")

# }

Run the code above in your browser using DataLab