Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab:10倍交叉,重复相同的折叠 我在问题的底部附加了数据:我有下面的代码返回一个单元格中的10倍,这样一种方式,细胞{1,1}考虑了训练数据和细胞{1,2}测试数据,但是出于某种原因,超出了细胞{1,1},{{1,1,}}…有相同的数据一遍又一遍地重复。我真的不知道为什么会这样。我调试了这么多轮,无法找出原因_Matlab_Machine Learning_Cell - Fatal编程技术网

Matlab:10倍交叉,重复相同的折叠 我在问题的底部附加了数据:我有下面的代码返回一个单元格中的10倍,这样一种方式,细胞{1,1}考虑了训练数据和细胞{1,2}测试数据,但是出于某种原因,超出了细胞{1,1},{{1,1,}}…有相同的数据一遍又一遍地重复。我真的不知道为什么会这样。我调试了这么多轮,无法找出原因

Matlab:10倍交叉,重复相同的折叠 我在问题的底部附加了数据:我有下面的代码返回一个单元格中的10倍,这样一种方式,细胞{1,1}考虑了训练数据和细胞{1,2}测试数据,但是出于某种原因,超出了细胞{1,1},{{1,1,}}…有相同的数据一遍又一遍地重复。我真的不知道为什么会这样。我调试了这么多轮,无法找出原因,matlab,machine-learning,cell,Matlab,Machine Learning,Cell,这是密码 %Function that accept data file as a name and the number of folds %For the cross fold function [results_cell] = GetTenFold(dataFile, x) %loading the data file dataMatrix = load(dataFile); %combine the data and labels as one matrix X = [dataMatri

这是密码

%Function that accept data file as a name and the number of folds
%For the cross fold
function [results_cell] = GetTenFold(dataFile, x)
%loading the data file
dataMatrix = load(dataFile);
%combine the data and labels as one matrix
X = [dataMatrix.data dataMatrix.labels];
%geting the length of the of matrix
dataRowNumber = length(dataMatrix.data);
%shuffle the matrix while keeping rows intact 
shuffledMatrix = X(randperm(size(X,1)),:);
crossValidationFolds = x;
%Assinging number of rows per fold
numberOfRowsPerFold = dataRowNumber / crossValidationFolds;
%Assigning 10X2 cell to hold each fold as training and test data
results_cell = cell(10,2);
    %starting from the first row and segment it based on folds
    i = 1;
    for startOfRow = 1:numberOfRowsPerFold:dataRowNumber
        testRows = startOfRow:startOfRow+numberOfRowsPerFold-1;
        if (startOfRow == 1)
            trainRows = (max(testRows)+1:dataRowNumber);
        else
            trainRows = [1:startOfRow-1 max(testRows)+1:dataRowNumber];
            i = i + 1;
        end
        %for i=1:10
        results_cell{i,1} = shuffledMatrix(trainRows ,:);
        results_cell{i,2} = shuffledMatrix(testRows ,:);
    end
end
data

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
5.4000    3.4000    1.7000    0.2000
5.1000    3.7000    1.5000    0.4000
4.6000    3.6000    1.0000    0.2000
5.1000    3.3000    1.7000    0.5000
4.8000    3.4000    1.9000    0.2000
5.0000    3.0000    1.6000    0.2000
5.0000    3.4000    1.6000    0.4000
5.2000    3.5000    1.5000    0.2000
5.2000    3.4000    1.4000    0.2000
4.7000    3.2000    1.6000    0.2000
4.8000    3.1000    1.6000    0.2000
5.4000    3.4000    1.5000    0.4000
5.2000    4.1000    1.5000    0.1000
5.5000    4.2000    1.4000    0.2000
4.9000    3.1000    1.5000    0.1000
5.0000    3.2000    1.2000    0.2000
5.5000    3.5000    1.3000    0.2000
4.9000    3.1000    1.5000    0.1000
4.4000    3.0000    1.3000    0.2000
5.1000    3.4000    1.5000    0.2000
5.0000    3.5000    1.3000    0.3000
4.5000    2.3000    1.3000    0.3000
4.4000    3.2000    1.3000    0.2000
5.0000    3.5000    1.6000    0.6000
5.1000    3.8000    1.9000    0.4000
4.8000    3.0000    1.4000    0.3000
5.1000    3.8000    1.6000    0.2000
4.6000    3.2000    1.4000    0.2000
5.3000    3.7000    1.5000    0.2000
5.0000    3.3000    1.4000    0.2000
7.0000    3.2000    4.7000    1.4000
6.4000    3.2000    4.5000    1.5000
6.9000    3.1000    4.9000    1.5000
5.5000    2.3000    4.0000    1.3000
6.5000    2.8000    4.6000    1.5000
5.7000    2.8000    4.5000    1.3000
6.3000    3.3000    4.7000    1.6000
4.9000    2.4000    3.3000    1.0000
6.6000    2.9000    4.6000    1.3000
5.2000    2.7000    3.9000    1.4000
5.0000    2.0000    3.5000    1.0000
5.9000    3.0000    4.2000    1.5000
6.0000    2.2000    4.0000    1.0000
6.1000    2.9000    4.7000    1.4000
5.6000    2.9000    3.6000    1.3000
6.7000    3.1000    4.4000    1.4000
5.6000    3.0000    4.5000    1.5000
5.8000    2.7000    4.1000    1.0000
6.2000    2.2000    4.5000    1.5000
5.6000    2.5000    3.9000    1.1000
5.9000    3.2000    4.8000    1.8000
6.1000    2.8000    4.0000    1.3000
6.3000    2.5000    4.9000    1.5000
6.1000    2.8000    4.7000    1.2000
6.4000    2.9000    4.3000    1.3000
6.6000    3.0000    4.4000    1.4000
6.8000    2.8000    4.8000    1.4000
6.7000    3.0000    5.0000    1.7000
6.0000    2.9000    4.5000    1.5000
5.7000    2.6000    3.5000    1.0000
5.5000    2.4000    3.8000    1.1000
5.5000    2.4000    3.7000    1.0000
5.8000    2.7000    3.9000    1.2000
6.0000    2.7000    5.1000    1.6000
5.4000    3.0000    4.5000    1.5000
6.0000    3.4000    4.5000    1.6000
6.7000    3.1000    4.7000    1.5000
6.3000    2.3000    4.4000    1.3000
5.6000    3.0000    4.1000    1.3000
5.5000    2.5000    4.0000    1.3000
5.5000    2.6000    4.4000    1.2000
6.1000    3.0000    4.6000    1.4000
5.8000    2.6000    4.0000    1.2000
5.0000    2.3000    3.3000    1.0000
5.6000    2.7000    4.2000    1.3000
5.7000    3.0000    4.2000    1.2000
5.7000    2.9000    4.2000    1.3000
6.2000    2.9000    4.3000    1.3000
5.1000    2.5000    3.0000    1.1000
5.7000    2.8000    4.1000    1.3000
6.3000    3.3000    6.0000    2.5000
5.8000    2.7000    5.1000    1.9000
7.1000    3.0000    5.9000    2.1000
6.3000    2.9000    5.6000    1.8000
6.5000    3.0000    5.8000    2.2000
7.6000    3.0000    6.6000    2.1000
4.9000    2.5000    4.5000    1.7000
7.3000    2.9000    6.3000    1.8000
6.7000    2.5000    5.8000    1.8000
7.2000    3.6000    6.1000    2.5000
6.5000    3.2000    5.1000    2.0000
6.4000    2.7000    5.3000    1.9000
6.8000    3.0000    5.5000    2.1000
5.7000    2.5000    5.0000    2.0000
5.8000    2.8000    5.1000    2.4000
6.4000    3.2000    5.3000    2.3000
6.5000    3.0000    5.5000    1.8000
7.7000    3.8000    6.7000    2.2000
7.7000    2.6000    6.9000    2.3000
6.0000    2.2000    5.0000    1.5000
6.9000    3.2000    5.7000    2.3000
5.6000    2.8000    4.9000    2.0000
7.7000    2.8000    6.7000    2.0000
6.3000    2.7000    4.9000    1.8000
6.7000    3.3000    5.7000    2.1000
7.2000    3.2000    6.0000    1.8000
6.2000    2.8000    4.8000    1.8000
6.1000    3.0000    4.9000    1.8000
6.4000    2.8000    5.6000    2.1000
7.2000    3.0000    5.8000    1.6000
7.4000    2.8000    6.1000    1.9000
7.9000    3.8000    6.4000    2.0000
6.4000    2.8000    5.6000    2.2000
6.3000    2.8000    5.1000    1.5000
6.1000    2.6000    5.6000    1.4000
7.7000    3.0000    6.1000    2.3000
6.3000    3.4000    5.6000    2.4000
6.4000    3.1000    5.5000    1.8000
6.0000    3.0000    4.8000    1.8000
6.9000    3.1000    5.4000    2.1000
6.7000    3.1000    5.6000    2.4000
6.9000    3.1000    5.1000    2.3000
5.8000    2.7000    5.1000    1.9000
6.8000    3.2000    5.9000    2.3000
6.7000    3.3000    5.7000    2.5000
6.7000    3.0000    5.2000    2.3000
6.3000    2.5000    5.0000    1.9000
6.5000    3.0000    5.2000    2.0000
6.2000    3.4000    5.4000    2.3000
5.9000    3.0000    5.1000    1.8000
标签=

 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 2
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3
 3

我建议您进行调试,并确定实际语句的行为不符合您的预期。然后问这个问题。你能澄清一下“在单元格{1,1}之外,{1,2}……哪个单元格有重复的相同数据?”?您的代码对我来说很有用,可以为不同的折叠创建非重叠和训练/测试集以及不同的分区。