我有一个矩阵(在MatLab中可能称为结构体)或数据结构:
data: [150x4 double]
labels: [150x1 double]
以下是我的matrix.data文件的样子,假设我使用名为matrix的文件进行加载:
5.1000 3.5000 1.4000 0.2000
4.9000 3.0000 1.4000 0.2000
4.7000 3.2000 1.3000 0.2000
4.6000 3.1000 1.5000 0.2000
5.0000 3.6000 1.4000 0.2000
5.4000 3.9000 1.7000 0.4000
4.6000 3.4000 1.4000 0.3000
5.0000 3.4000 1.5000 0.2000
4.4000 2.9000 1.4000 0.2000
4.9000 3.1000 1.5000 0.1000
5.4000 3.7000 1.5000 0.2000
4.8000 3.4000 1.6000 0.2000
4.8000 3.0000 1.4000 0.1000
4.3000 3.0000 1.1000 0.1000
5.8000 4.0000 1.2000 0.2000
5.7000 4.4000 1.5000 0.4000
5.4000 3.9000 1.3000 0.4000
5.1000 3.5000 1.4000 0.3000
5.7000 3.8000 1.7000 0.3000
5.1000 3.8000 1.5000 0.3000
以下是我的 matrix.labels 的样式。
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
我正在尝试创建10折交叉验证,但不使用MatLab中的任何现有函数。由于我对MatLab知识非常有限,所以我在继续进行时遇到了困难。希望能得到帮助。
这是我目前的代码,我相信这可能不是Matlab的方式,但我对Matlab非常陌生。
function[output] = fisher(dataFile, number_of_folds)
data = load(dataFile);
%create random permutation indx
idx = randperm(150);
output = data.data(idx(1:15),:);
end