SVM in Caret with multiple iteration

I wanted to run SVM (linear, polynomial, and radial kernel) with multiple iterations. I was running this code but was not getting 5 iterations as expected. It was only getting one iteration. Can someone please help? Thanks.

Here is the ode

library(readxl)
data <- read_excel("DATASET", sheet = "ALL2")
View(data)

View(data)
data <- data
str(data)
dim(data)

############### Required Library
install.packages("mlbench")
install.packages("caret")
install.packages("glmnet")
install.packages("psych")
install.packages("tidyverse")
library(caret)
library(glmnet)
library(mlbench)
library(psych)
liberty(tidyverse)

custom <- trainControl(method= "repeatedcv",
number=10,
repeats = 3,
verboseIter = T)
traits = 1
cycles = 5

accuracy_svml = matrix(nrow = cycles, ncol = traits)

model_resample_svml = matrix(nrow = cycles, ncol = traits)

model_R2_svml = matrix(nrow = cycles, ncol = traits)

svml_varImp<- matrix(nrow = cycles, ncol = traits)

for (r in 1:cycles)
{

ind <- createDataPartition(data$Y, p=0.6, list=FALSE)
train <- data[ind,]
test <- data[-ind,]

tunegridsvm = expand.grid(C = c(1:5))
svml <- train(Y ~ .,
data = train,
kernel = "linear",
scale = FALSE)
predicted_test_svml <- predict(svml,test)
accuracy_svml[r,1] <- cor(predicted_test_svml, test$ET, use="complete")
model_resample_svml[r,1] <- RMSE(predicted_test_svml, test$ET)
model_R2_svml[r,1] <- R2(predicted_test_svml, test[,1], form = "traditional")

varImpsvml <- varImp(svml, scale = T)$importance
varImpsvml[,2] <- rownames(varImpsvml)
svml_varImp[[r]]<- list(varImpsvml)
}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.