train_classifier: Train a random forest or SVM classifier

Description Usage Arguments Details Value Examples

View source: R/train_classifier.R

Description

This function trains a Support Vector Machine (SVM) or Random Forest (RF) classifier for use in an image classification.

Usage

1
2
3
train_classifier(train_data, type = "rf", use_training_flag = TRUE,
  train_control = NULL, tune_grid = NULL, use_rfe = FALSE,
  factors = list(), ...)

Arguments

train_data

a link{pixel_data} object

type

either "svm" (to fit a support vector machine) or "rf" (to fit a random forest).

use_training_flag

indicates whether to exclude data flagged as testing data when training the classifier. For this to work the input train_data data.frame must have a column named 'training_flag' that indicates, for each pixel, whether that pixel is a training pixel (coded as TRUE) or testing pixel (coded as FALSE).

train_control

default is NULL (reasonable values will be set automatically). For details see trainControl.

tune_grid

the training grid to be used for training the classifier. See Details.

use_rfe

whether to use Recursive Feature Extraction (RFE) as implemented in the caret package to select a subset of the input features to be used in the classification. NOT YET SUPPORTED.

factors

a list of character vector giving the names of predictors (layer names from the images used to build train_data) that should be treated as factors, and specifying the levels of each factor. For example, factors=list(year=c(1990, 1995, 2000, 2005, 2010)).

...

additional arguments (such as ntree for random forest classifier) to pass to train

Details

For type='svm', tunegrid must be a data.frame with two columns: ".sigma" and ".C". For type='rf', must be a data.frame with one column: '.mtry'.

This function will run in parallel if a parallel backend is registered with foreach.

Value

a trained model (as a train object from the caret package)

Examples

1
2
3
train_data <- get_pixels(L5TSR_1986, L5TSR_1986_2001_training, "class_1986", 
                         training=.6)
model <- train_classifier(train_data)

azvoleff/teamlucc documentation built on June 4, 2017, 12:08 a.m.