gridclassifier: Grid-search through parameters of a classifier model

Description Usage Arguments Details Value Examples

View source: R/classification.R

Description

Given a vector of values of parameters, return classification errors and confusion matrices of a classifier model for each combination.

Usage

1
2
gridclassifier(data, model, formula, params, k = 1, repetitions = 1,
  verbose = FALSE, writeto = NULL)

Arguments

data

the data frame of data, containing the predictor columns and the outcome column

model

the function that executes the model, such as randomForest::randomForest or e1071::svm. The data frame argument of this function should be named "data", and the formula should be named "formula".

formula

the formula of the classifier, to be passed to the model

params

a list, each element is named as a parameter to be passed to the model and contains a vector of values to try.

k

a positive integer, the number of folds in the k-fold validation

repetitions

a positive integer, the number of repetitions in the k-fold validation

verbose

a logical, whether or not to print out progress

writeto

if not NULL, will rewrite results cumulatively after each combination of parameters is finished to the file with this path.

Details

All parameters of the classifier model, out of which the grid will be formed, are assumed to be passed to the classifier as single values (not vectors, matrices, etc). If you want to grid-search parameters that your model takes as, say, a vector, or if your model takes the formula and the data as arguments with different names, use a wrapper function for your model.

Value

a list with components, indexed in the same order:

class.err

matrix of classification errors per class (each class is a column)

total.err

a vector of total classification errors

confs

a list of confusion matrices

gridparam

a data frame of the grid of the parameters. It provides the connection between the index (common for the preceding list components) and the parameter values.

kfold

a list containing the number of folds and repetitions in the kfold validation

Examples

1
#

rushkin/bitsandends documentation built on Oct. 21, 2020, 11:43 a.m.