preProcess

0th

Percentile

Pre-Processing of Predictors

Pre-processing transformation (centering, scaling etc) can be estimated from the training data and applied to any data set with the same variables.

Keywords
utilities
Usage
preProcess(x, ...)

## S3 method for class 'default': preProcess(x, method = c("center", "scale"), thresh = 0.95, na.remove = TRUE, k = 5, knnSummary = mean, ...)

## S3 method for class 'preProcess': predict(object, newdata, ...)

Arguments
x
a matrix or data frame. All variables must be numeric.
method
a character vector specifying the type of processing. Possible values are "center", "scale", "knnImpute", "bagImpute", "pca" "ica" and "spatialSign" (see Details below)
thresh
a cutoff for the cumulative percent of variance to be retained by PCA
na.remove
a logical; should missing values be removed from the calculations?
object
an object of class preProcess
newdata
a matrix or data frame of new data to be pre-processed
k
the number of nearest neighbors from the training set to use for imputation
knnSummary
function to average the neighbor values per column during imputation
...
additional arguments to pass to fastICA, such as n.comp
Details

The operations are applied in this order: imputation, centering, scaling, PCA, ICA then spatial sign.

If PCA is requested but centering and scaling are not, the values will still be centered and scaled. Similarly, when ICA is requested, the data are automatically centered and scaled.

$k$-nearest neighbor imputation is carried out by finding the k closest samples (Euclidian distance) in the training set. Imputation via bagging fits a bagged tree model for each predictor (as a function of all the others). This method is simple, accurate and accepts missing values, but it has much higher computational cost.

A warning is thrown if both PCA and ICA are requested. ICA, as implemented bt the fastICA package automatically does a PCA decomposition prior to finding the ICA scores.

The function will throw an error of any variables in x has less than two unique values.

Value

  • preProcess results in a list with elements
  • callthe function call
  • dimthe dimensions of x
  • meana vector of means (if centering was requested)
  • stda vector of standard deviations (if scaling or PCA was requested)
  • rotationa matrix of eigenvectors if PCA was requested
  • methodthe value ofmethod
  • threshthe value ofthresh
  • numCompthe number of principal components required of capture the specified amount of variance
  • icacontains values for the W and K matrix of the decomposition

References

Kuhn (2008), ``Building Predictive Models in R Using the caret'' (http://www.jstatsoft.org/v28/i05/)

See Also

prcomp, fastICA, spatialSign

Aliases
  • preProcess
  • preProcess.default
  • predict.preProcess
Examples
data(BloodBrain)
# one variable has one unique value
preProc <- preProcess(bbbDescr[1:100,])

preProc <- preProcess(bbbDescr[1:100,-3])
training <- predict(preProc, bbbDescr[1:100,-3])
test <- predict(preProc, bbbDescr[101:208,-3])
Documentation reproduced from package caret, version 4.75, License: GPL-2

Community examples

Looks like there are no examples yet.