getValidation: Extract validation results from superClass objects

View source: R/getValidation.R

getValidationR Documentation

Extract validation results from superClass objects

Description

Extract validation results from superClass objects

Usage

getValidation(x, from = "testset", metrics = "overall")

Arguments

x

superClass object or caret::confusionMatrix

from

Character. 'testset' extracts the results from independent validation with testset. 'cv' extracts cross-validation results.

metrics

Character. Only relevant in classification mode (ignored for regression models). Select 'overall' for overall accuracy metrics, 'classwise' for classwise metrics, 'confmat' for the confusion matrix itself and 'caret' to return the whole caret::confusionMatrix object.

Value

Returns a data.frame with validation results. If metrics = 'confmat' or 'caret' will return a table or the full caret::confusionMatrix object, respectively.

Examples

library(pls)
## Fit classifier (splitting training into 70\% training data, 30\% validation data)
train <- readRDS(system.file("external/trainingPoints_rlogo.rds", package="RStoolbox"))
SC   <- superClass(rlogo, trainData = train, responseCol = "class",
                    model="pls", trainPartition = 0.7)
## Independent testset-validation
getValidation(SC)
getValidation(SC, metrics = "classwise")
## Cross-validation based 
getValidation(SC, from = "cv")

bleutner/RStoolbox documentation built on Nov. 30, 2024, 9:47 p.m.