支持向量机特征选择在R
我正在尝试使用R包在SVM中应用特征选择(例如递归特征选择)。我已经在LibSVM中安装了支持特征选择的Weka,但是我还没有找到任何支持向量机语法或类似的例子。举个简单的例子会很有帮助。在支持向量机特征选择在R,r,machine-learning,weka,svm,feature-selection,R,Machine Learning,Weka,Svm,Feature Selection,我正在尝试使用R包在SVM中应用特征选择(例如递归特征选择)。我已经在LibSVM中安装了支持特征选择的Weka,但是我还没有找到任何支持向量机语法或类似的例子。举个简单的例子会很有帮助。在caret包中的函数rfe对各种算法执行递归特征选择。下面是插入符号中的一个示例: 库(插入符号) 数据(血脑,package=“插入符号”) x这里的size=c(2,5,10,20)是什么?这是否意味着功能2、10和20?不,这是将要使用的功能的数量。rfe将尝试找到该向量中给出的每种尺寸的最佳模型。有关
caret
包中的函数rfe
对各种算法执行递归特征选择。下面是插入符号中的一个示例:
库(插入符号)
数据(血脑,package=“插入符号”)
x这里的size=c(2,5,10,20)
是什么?这是否意味着功能2、10和20?不,这是将要使用的功能的数量。rfe将尝试找到该向量中给出的每种尺寸的最佳模型。有关详细信息,请查看rfe文档。@DavidMarx感谢您的解释。rfe()
函数调用中number=200
的含义是什么?
library(caret)
data(BloodBrain, package="caret")
x <- scale(bbbDescr[,-nearZeroVar(bbbDescr)])
x <- x[, -findCorrelation(cor(x), .8)]
x <- as.data.frame(x)
svmProfile <- rfe(x, logBBB,
sizes = c(2, 5, 10, 20),
rfeControl = rfeControl(functions = caretFuncs,
number = 200),
## pass options to train()
method = "svmRadial")
# Here's what your results look like (this can take some time)
> svmProfile
Recursive feature selection
Outer resampling method: Bootstrap (200 reps)
Resampling performance over subset size:
Variables RMSE Rsquared RMSESD RsquaredSD Selected
2 0.6106 0.4013 0.05581 0.08162
5 0.5689 0.4777 0.05305 0.07665
10 0.5510 0.5086 0.05253 0.07222
20 0.5203 0.5628 0.04892 0.06721
71 0.5202 0.5630 0.04911 0.06703 *
The top 5 variables (out of 71):
fpsa3, tcsa, prx, tcpa, most_positive_charge