Below code is the svm model with cross-validation. However, after obtaining the best model, I was not able to get the prediction of the probability values and getting error message. I am not sure whether, I am missing some thing here.
Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "c('svm.formula', 'svm')".
set.seed(123)
svm1_cv <- tune(
svm,
test_result ~ .,
data = trainDataFull,
kernel = "radial",
ranges = list(cost = 0.3, gamma = 0.1), # Single fixed values
tunecontrol = tune.control(cross = 10), # 10-fold CV
scale = TRUE,
class.weights = class_weights,
probability = TRUE
)
Trained model
best_svm_cv1 <- svm1_cv$best.model
prob_predictions1 <- predict(best_svm_cv1, trainDataFull, probability = TRUE)