rmachine-learningsvmr-caret

Error in SVM model: Pre-processing methods are limited to: BoxCox, YeoJohnson in R


I am trying to run an SVM model, but I get the error:

Error: pre-processing methods are limited to: BoxCox, YeoJohnson, expoTrans, invHyperbolicSine, center, scale, range, knnImpute, bagImpute, medianImpute, pca, ica, spatialSign, ignore, keep, remove, zv, nzv, conditionalX, corr

I don't understand what is going wrong.

svm.model_unigrams = train(outcome ~.
                           , data = training_set_unigrams
                           , trControl = training_controls
                           , method = "svmRadial"
                           , preProcess = (training_set_unigrams, method = c("center", "scale"))
                           , na.action = na.pass)

Solution

  • As you have not provided any data, so, I am using IRIS data.

    library(caret)
    data(iris)
    
    svm.model_unigrams = train(Species ~., data = iris,
                                trControl = trainControl(method = "cv",
                                                          number = 5,
                                                          allowParallel = TRUE),
                                method = "svmRadial",
                                preProc = c("center", "scale"),
                                na.action = na.pass)
    

    Similarly, you can use other methods like

    train(Species ~., data = iris,
                               trControl = trainControl(method = "cv",
                                                        number = 5,
                                                        allowParallel = TRUE),
                               method = "svmRadial",
                               preProc = c("BoxCox"),
                               na.action = na.pass)