preProcess {caret} | R Documentation |
Pre-processing transformation (centering, scaling etc) can be estimated from the training data and applied to any data set with the same variables.
preProcess(x, ...) ## Default S3 method: preProcess(x, method = c("center", "scale"), thresh = 0.95, na.remove = TRUE, ...) ## S3 method for class 'preProcess': predict(object, newdata, ...)
x |
a matrix or data frame |
method |
a character vector specifying the type of processing. Possible values are "center", "scale", "pca" and "spartialSign" |
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 |
... |
Additional arguments (currently this argument is not used) |
The operations are applied in this order: centering, scaling, PCA and spatial sign. If PCA is requested but scaling is not, the values will still be scaled.
The function will throw an error of any variables in x
has less than two unique values.
preProcess
results in a list with elements
call |
the function call |
dim |
the dimensions of x |
mean |
a vector of means (if centering was requested) |
std |
a vector of standard deviations (if scaling or PCA was requested) |
rotation |
a matrix of eigenvectors if PCA was requested |
method |
the value ofmethod |
thresh |
the value ofthresh |
numComp |
the number of principal components required of capture the specified amount of variance |
Max Kuhn
Kuhn (2008), ``Building Predictive Models in R Using the caret'' (http://www.jstatsoft.org/v28/i05/)
data(BloodBrain) # one variable has one unique value ## Not run: 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])