Description Usage Arguments Details Value Examples
View source: R/errorest-wrapper.r
We provide a wrapper function to estimate the error rate of a classifier using any of the following estimators:#'
errorest_cv
:Cross-validation Error Rate
errorest_boot
:Bootstrap Error Rate
errorest_632
:.632 Estimator from Efron (1983)
errorest_632plus
:.632+ Estimator from Efron and Tibshirani (1997)
errorest_bcv
:Bootstrap Cross-validation from Fu et al. (2005)
errorest_loo_boot
:Leave-One-Out Bootstrap Error Rate
errorest_apparent
:Apparent Error Rate
1 2 3 |
x |
a matrix of n observations and p features |
y |
a vector of n class labels. (Must to be a 'factor'.) |
estimator |
the estimator used to compute the error rate |
train |
a function that builds the classifier. (See details.) |
classify |
a function that classifies observations
from the constructed classifier from |
... |
additional arguments passed to the error-rate estimation code |
This wrapper function provides a common means to estimate classification error rates and is useful for simulation studies where multiple error-rate estimators are being considered.
For details about an individual error-rate estimator, please see its respective documentation.
an estimate of the classifier's error rate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | require('MASS')
iris_x <- data.matrix(iris[, -5])
iris_y <- iris[, 5]
# Because the \code{classify} function returns multiples objects in a list,
# we provide a wrapper function that returns only the class labels.
lda_wrapper <- function(object, newdata) { predict(object, newdata)$class }
# Cross-Validation (default)
errorest(x = iris_x, y = iris_y, train = MASS:::lda, classify = lda_wrapper)
# .632
errorest(x = iris_x, y = iris_y, estimator = "632", train = MASS:::lda,
classify = lda_wrapper)
# Bootstrap Error Rate
# The argument 'num_bootstraps' is passed on to 'errorest_boot'
errorest(x = iris_x, y = iris_y, estimator = "boot", train = MASS:::lda,
classify = lda_wrapper, num_bootstraps = 42)
|
Loading required package: MASS
[1] 0.02
[1] 0.02204862
[1] 0.01968254
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.