validate: Check the accuracy of a model using independent validation...

Description Usage Arguments Value See Also Examples

View source: R/Models.R

Description

This function is a wrapper for classAcc that, given an independent validation dataset, uses the model to come up with new predicted values. It then calls classAcc with these two validation datasets (the one generated by the model and the true values) to report class accuracies.

Usage

1
validate(model, valid, ...)

Arguments

model

the model to test.

valid

the validation dataset; must contain all the parameters used in the model.

...

other variables to pass to classAcc.

Value

Returns the result from classAcc

See Also

classAcc

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
data ('siteData')
# With categorical data
gen <- sample(1:nrow(siteData),floor(nrow(siteData)*0.5))
modelRun <- generateModels(data = siteData[sort(gen),],
                           modelTypes = suppModels,
                           x = c('brtns','grnns','wetns','dem','slp','asp','hsd'),
                           y = 'ecoType',
                           grouping = ecoGroup[['identity','transform']],
                           echo = FALSE)
valid <- siteData[-gen,]
valid$ecoType <- as.factor(ecoGroup[['identity','transform']][valid$ecoType])
validate(modelRun[[2]],valid)
validModels(modelRun,valid)

# With continuous data
gen <- sample(1:nrow(siteData),floor(nrow(siteData)*0.5))
modelRun <- generateModels(data = siteData[sort(gen),],
                           modelTypes = contModels,
                           x = c('brtns','grnns','wetns','dem','slp','asp','hsd'),
                           y = 'easting',
                           echo = FALSE)
valid <- siteData[-gen,]
validate(modelRun[[2]],valid)
modelsValid(modelRun,valid)

henkelstone/NPEL.Classification documentation built on May 17, 2019, 3:42 p.m.