下面的代码表示基于10倍交叉验证应用的基于相关性的特征选择技术的实现,并由svm分类器评估如何在svm分类器中使用子集参数?任何解释将不胜感激
library(caret)
library(e1071)
library(FSelector)
data=iris
#split data into train and test
trainIndex <- createDataPartition(data$Cardio1M, p=0.7, list=FALSE)
data_train <- data[ trainIndex,]
data_test <- data[-trainIndex,]
set.seed(10)
subset <- cfs(Species~., data_train)
#Using selected features to train svm
svm_model<-svm(Species~subset,data_train[,subset],cost=.1,kernel="radial")
p<-predict(svm_model,data_test[,-5])
accuracy=mean(p==data_test[,5])