当我使用SVM处理二进制分类问题时,我发现了两种交叉验证方式,我不知道哪种方法最有效?
使用
android {
...
signingConfigs {
config {
keyPassword 'android'
storeFile file(<path to debug keystore>)
storePassword 'android'
keyAlias 'androiddebugkey'
}
}
...
}
并循环的第一种方法:
crossvalind
相反,使用k = 10;
cvFolds = crossvalind('Kfold', data_lables, k); %# get indices of 10-fold
cp = classperf(data_lables);
for i = 1:k %# for each fold
testIdx = (cvFolds == i); %# get indices of test instances
trainIdx = ~testIdx; %# get indices training instances
%# train an SVM model over training instances
X= features(trainIdx,:);
Y = data_lables(trainIdx);
svmModel = fitcsvm(X,Y,'Standardize',true,'KernelFunction','RBF','KernelScale','auto');
%# test using test instances
Z = features(testIdx,:);
pred = predict(svmModel,Z);
%# evaluate and update performance object
cp = classperf(cp, pred, testIdx);
end
cvpartition