我现在正在混淆使用Matlab实现带有交叉验证的SVM.stackoverflow上有很多帖子提到了有关SVM及其交叉验证的信息; 然而,即使使用最简单的"fisheriris"数据集也没有完整的例子.
我总结了这些帖子的问题如下:
一个.二进制和多类SVM:由matlab中的支持向量机回答, 但没有交叉验证的例子.
湾 使用SVM进行交叉验证: 在MATLAB中进行10倍SVM分类的 示例,但没有多类SVM的示例.
C.一对一和一对一的SVM:1-against-1可以在matlab中的支持向量机上找到 1-against-all可以在libsvm Multi-Class SVM中的多类分类中找到 (一对一) 没有交叉验证的例子
d.libSVM和Matlab内置SVM(统计工具箱)使用libSVM的部分完整示例可以 在一对一SVM中使用10倍交叉验证(使用LibSVM)
即 参数优化 使用libsvm进行交叉验证后重新训练
但是,对于一个人来说,学习并最终为他们的真正问题部署SVM的事情真的很复杂,只要查看这些以前的帖子就会出现问题和错误.至少我是愚蠢的解决拼图问题.
为什么我们不一起为具有以下功能的SVM构建易于理解的代码?
A.只需使用'fisheriris'数据.
B.可以用于二元和多类问题(fisheriris可以选择二进制).
C.实施交叉验证.
D.实施一对一和一对一.
E.两个版本分别使用libSVM和Matlab内置SVM.由于svmtrain与两个包的名称相同,我建议在使用之前将其更改为libsvmtrain和MEX.然后我们也可以比较这两种方法.
F.目前,由于训练/测试数据分离,结果并不总是可重复的.我们能解决这个问题吗
F.(可选)添加参数优化.
G.(可选)添加ROC分析.
我的开始是一些代码,如:
#% libSVM version_1
clc; clear all;
load fisheriris
[~,~,labels] = unique(species); % Labels: 1/2/3
data = zscore(meas); % Scale features
numInst = size(data,1);
numLabels = max(labels);
%# Split training/testing
idx = randperm(numInst);
numTrain = 100;
numTest …Run Code Online (Sandbox Code Playgroud) 你能举一个在matlab中使用支持向量机(SVM)对4个类进行分类的例子:
atribute_1 atribute_2 atribute_3 atribute_4 class
1 2 3 4 0
1 2 3 5 0
0 2 6 4 1
0 3 3 8 1
7 2 6 4 2
9 1 7 10 3
Run Code Online (Sandbox Code Playgroud) matlab artificial-intelligence classification machine-learning svm
可能重复:
如何使用显示的颜色和值显示矩阵?
我NxN在MATLAB中基本上有一个(编辑:N可以达到80)矩阵的双重和我将它绘制为一个数组(我想看到数字)和一些单元格应该是彩色的(决定如何我为我的数字着色与数字无关).
我想到了不同的方法:
创建一个网格作为一个图像并用文本覆盖它,但MATLAB的图将是可怕的,因为它将删除一些像素来调整图像的大小(我的矩阵可以在周围80x80).
出口到excel?我不知道如何为细胞着色.
有帮助吗?
因为图像有时更有帮助:

我正在寻找一个在神经网络中应用10倍交叉验证的例子.我需要这个问题的链接答案:MATLAB中10倍SVM分类的例子
我想对所有3个类进行分类,而在示例中只考虑了两个类.
编辑:这是我为iris示例编写的代码
load fisheriris %# load iris dataset
k=10;
cvFolds = crossvalind('Kfold', species, k); %# get indices of 10-fold CV
net = feedforwardnet(10);
for i = 1:k %# for each fold
testIdx = (cvFolds == i); %# get indices of test instances
trainIdx = ~testIdx; %# get indices training instances
%# train
net = train(net,meas(trainIdx,:)',species(trainIdx)');
%# test
outputs = net(meas(trainIdx,:)');
errors = gsubtract(species(trainIdx)',outputs);
performance = perform(net,species(trainIdx)',outputs)
figure, plotconfusion(species(trainIdx)',outputs)
end
Run Code Online (Sandbox Code Playgroud)
matlab给出的错误:
Error using nntraining.setup>setupPerWorker (line 62)
Targets T{1,1} is …Run Code Online (Sandbox Code Playgroud) matlab classification machine-learning neural-network cross-validation