Description Usage Arguments Details Value Examples
View source: R/classification.R
Given a vector of values of parameters, return classification errors and confusion matrices of a classifier model for each combination.
1 2 | gridclassifier(data, model, formula, params, k = 1, repetitions = 1,
verbose = FALSE, writeto = NULL)
|
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. |
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.
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 |
1 | #
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.