即使在不同的运行之后,精度值也保持不变

数据挖掘 神经网络 监督学习 表现 matlab 准确性
2022-03-04 14:20:45

我正在使用 Matlab 的神经网络工具箱来训练一个网络。现在我的代码如下:

x = xdata.';
t = target1';
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
net.layers{2}.transferFcn = 'softmax';
net.divideFcn = 'dividerand';  % Divide data randomly
net.divideMode = 'sample';  % Divide up every sample
net.divideParam.trainRatio = 60/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 20/100;
net.trainFcn = 'trainscg';  % Scaled conjugate gradient
net.performFcn = 'mse';
net.performParam.regularization = 0.5;
%net.performParam.normalization = 0.01;
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
  'plotregression', 'plotfit', 'plotconfusion'};

% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
performance = perform(net,t,y)
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t  .* tr.valMask{1};


现在我应该通过不同的数据运行获得不同的精度,因为采样(将数据集划分为训练测试和验证集)是随机的。但我得到了一个恒定的准确度(89.7%)。变量“xdata”仅包含由特征选择算法选择的那些特征。我的准确度值是恒定的有什么原因吗?

我也用相同的数据集训练了一个 SVM。即使多次运行(94%),我也得到了陈旧的准确性

输出 y 包含 2 个值。这些值意味着什么?

1个回答

我看到您在代码的以下行中设置了随机数生成器(rng)种子:rng(1).

因此,无论运行哪种方式,这都会以相同的方式拆分数据。因此,这就是您获得相同错误值的原因。

尝试删除线。然后,数据将被随机分割(因为现在没有种子)。然后,您将得到不同的错误,具体取决于拆分的完成方式(即随机)。

一个泛化好的模型应该对种子的选择具有鲁棒性