Reputation: 301
I was given 5000 SIFT features for each grey-scale image of either a poodle dog or fried chicken, and asked to build a model for classification.
I ran preProcess function on the matrix of sift features:
mat1=preProcess(mat, method=c("pca", "zv"))
What I get is a class "preprocessed", and I do not know how to use this object mat1
in the following function call:
model_gbm <- train(ensembleData[,predictors], ensembleData[,labelName], method='gbm', trControl=myControl)
ensembleData[, predictors] used to contain the feature part of the sift features, and ensembleData[, labelName] contained the actual class (0 or 1) of the data.
I have thought about using the preProcess
function inside of the train
function, but I want to be able to use the same preprocessed data elsewhere in other models.
Thanks!
Upvotes: 1
Views: 1540
Reputation: 1491
According to the caret documentation
The function preProcess estimates the required parameters for each operation and predict.preProcess is used to apply them to specific data sets
So you need to apply the estimated parameters to your data like so:
mat1=preProcess(mat, method=c("pca", "zv"))
transformed = predict(mat1, mat)
model_gbm <- train(data=transformed, method='gbm', trControl=myControl)
Upvotes: 3