I want to loop over each Kernal for SVM regression Getting error 'kernel_name' not found also want output for each kernel in tabular form with Rsquare, AdjRsq and RMSE
library(e1071)
test_data = #upload test data here.
training_data= read.table('Digits_training.csv', sep =',', header = TRUE)
y = training_data$y
chosen_svm = function(y,training_data,kernel_name){
obj <- tune.svm(y~., data = training_data, gamma = 10^(-3:1), cost = 10^(-3:1), kernel = kernel_name)
gamma = obj$best.parameters$gamma
cost = obj$best.parameters$cost
model = svm(y~., data = training_data, gamma = gamma, cost = cost, kernel = kernel_name)
return(model)
}
radial_svm = chosen_svm(y,training_data,'radial')
lin_svm = chosen_svm(y,training_data,'linear')
pol_svm = chosen_svm(y,training_data,'polynomial')