classModel: classModel

Description Usage Arguments Details Value See Also Examples

View source: R/classModel.R

Description

Derives a spatially-explicit predictive model as well as sample-wise validation.

Usage

1
classModel(x, y, z, mode = "classification", ...)

Arguments

x

Object of class data.frame.

y

A vector of class character or numeric.

z

A vector of class character or numeric.

mode

One of "classification" or "regression".

...

Arguments passed to train.

Details

Uses train to derive a predictive model based on x - which contains the predictors - and y - which contains information on the target classes (if mode is "classification") or values (if mode is "regression"). This method iterates through all samples making sure that all contribute for the final accuracy. To specify how the samples should be split, the user should provide the sample-wise identifiers through z. For each unique value in z, the function keeps it for validation and the remaining samples for training. This process is repeated for all sample groups and a final accuracy is estimated from the overall set of results. If mode is "classification", the function will estimate the overall accuracy for each unique value in y. If "regression" is set, the output will be an the coefficient of determination. The classification algorithm and additional commands can be set through ... using inputs of the train function. Apart from the accuracy assessment, the function stores the performance for each sample. If mode is "classification", the function will return a logical vector reporting on the correctly assigned classes. If mode is "regression", the function will report on the percent deviation between the original value and it's predicted value. The final output of the function is a list consisting of:

Value

A two element numeric vector.

See Also

raster2sample poly2sample ccLabel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{

require(raster)

# read raster data
r <- brick(system.file("extdata", "ndvi.tif", package="fieldRS"))

# read field data
data(fieldData)
fieldData <- fieldData[c(1:3, 10),]

# extract values for polygon centroid
c <- spCentroid(fieldData)
ev <- as.data.frame(extract(r, c))

cm <- classModel(ev, fieldData$crop, as.character(1:length(fieldData)), method="rf")

}

fieldRS documentation built on July 8, 2020, 5:37 p.m.