フィルターのクリア

Below is the probabilistic neural network for classification, but it is not working fine. Can someone help to improve it? especially how to recalculate training, validation and test performance.

1 回表示 (過去 30 日間)
close all; clear; clc data = dlmread('iris.dat'); %data=dlmread('Dermatology.txt'); %data=[data(:,1) data(:,3:8) data(:,2)]; % inputs=[data(:,1) data(:,3:8)]; % targets=data(:,2); %inputs = thyroidInputs; %targets = thyroidTargets; B= data(:,1:end-1); B = B';
C = data(:,end);
n_class = max(C); class = 1:1:n_class; CC = zeros(n_class,size(data,1));
for k = 1:n_class
for i = 1:size(data,1)
if C(i)==k
CC(k,i) = 1;
else
CC(k,i) = 0;
end
end
end
inputs=data';
targets=CC; %T=ind2vec(C'); spread=1;
net = newpnn(data',targets,spread);
% % Choose Input and Output Pre/Post-Processing Functions % % For a list of all processing functions type: help nnprocess %net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'}; %net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% simulate PNN on training data
output= sim(net,data');
% convert PNN outputs
%output = vec2ind(output);
view(net)
net.trainFcn = 'trainlm'; % Choose Plot Functions
% Choose a Performance Function % For a list of all performance functions type: help nnperformance net.performFcn = 'mse'; % Mean squared error
% For a list of all plot functions type: help nnplot net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotregression', 'plotfit'}; [ent,tr]=train(net,data',CC);
% Setup Division of Data for Training, Validation, Testing % For a list of all data division functions type: help nndivide net.divideFcn = 'dividerand'; % Divide data randomly net.divideMode = 'sample'; % Divide up every sample net.divideParam.trainRatio = 50/100; net.divideParam.valRatio = 25/100; net.divideParam.testRatio = 25/100;
nntraintool % plotperform(tr)
%testting the classifier % Test the Network outputs = net(inputs); errors = gsubtract(targets,outputs); performance = perform(net,targets,outputs)
% Recalculate Training, Validation and Test Performance trainTargets = targets .* tr.trainMask{1}; valTargets = targets .* tr.valMask{1}; testTargets = targets .* tr.testMask{1}; trainPerformance = perform(net,trainTargets,outputs) valPerformance = perform(net,valTargets,outputs) testPerformance = perform(net,testTargets,outputs)
% Plots % Uncomment these lines to enable various plots. figure, plotperform(tr) figure, plottrainstate(tr) figure, plotconfusion(targets,outputs)
  1 件のコメント
Greg Heath
Greg Heath 2015 年 1 月 20 日
1. Reformat your code so that it runs when cut and pasted into the command line.
2. Use one of the MATLAB example data sets
help nndatasets
doc nndatasets
Hope this helps.
Greg

サインインしてコメントする。

採用された回答

Greg Heath
Greg Heath 2015 年 1 月 21 日
NEWPNN is created, not trained.
help newpnn
doc newpnn
Try NEWRB, it trains itself.
help newrb
doc newrb
Search in NEWSGROUP and ANSWERS
greg newrb
Hope this helps
Thank you for formally accepting my answer
Greg

その他の回答 (3 件)

davykol
davykol 2015 年 1 月 20 日
編集済み: davykol 2015 年 1 月 20 日
Try this one may be it will work:
close all; clear all; clc
data=[ 5.1000 3.5000 1.4000 0.2000 1.0000 4.9000 3.0000 1.4000 0.2000 1.0000 4.6000 3.1000 1.5000 0.2000 1.0000 5.0000 3.6000 1.4000 0.2000 1.0000 5.4000 3.9000 1.7000 0.4000 1.0000 4.6000 3.4000 1.4000 0.3000 1.0000 5.0000 3.4000 1.5000 0.2000 1.0000 4.4000 2.9000 1.4000 0.2000 1.0000 5.4000 3.7000 1.5000 0.2000 1.0000 4.8000 3.4000 1.6000 0.2000 1.0000 4.8000 3.0000 1.4000 0.1000 1.0000 4.3000 3.0000 1.1000 0.1000 1.0000 5.7000 4.4000 1.5000 0.4000 1.0000 5.4000 3.9000 1.3000 0.4000 1.0000 5.1000 3.5000 1.4000 0.3000 1.0000 5.7000 3.8000 1.7000 0.3000 1.0000 5.1000 3.8000 1.5000 0.3000 1.0000 5.4000 3.4000 1.7000 0.2000 1.0000 5.1000 3.7000 1.5000 0.4000 1.0000 4.6000 3.6000 1.0000 0.2000 1.0000 5.1000 3.3000 1.7000 0.5000 1.0000 4.8000 3.4000 1.9000 0.2000 1.0000 5.0000 3.0000 1.6000 0.2000 1.0000 5.0000 3.4000 1.6000 0.4000 1.0000 5.2000 3.5000 1.5000 0.2000 1.0000 5.2000 3.4000 1.4000 0.2000 1.0000 4.7000 3.2000 1.6000 0.2000 1.0000 4.8000 3.1000 1.6000 0.2000 1.0000 5.4000 3.4000 1.5000 0.4000 1.0000 5.2000 4.1000 1.5000 0.1000 1.0000 5.5000 4.2000 1.4000 0.2000 1.0000 4.9000 3.1000 1.5000 0.1000 1.0000 5.0000 3.2000 1.2000 0.2000 1.0000 5.5000 3.5000 1.3000 0.2000 1.0000 4.9000 3.1000 1.5000 0.1000 1.0000 4.4000 3.0000 1.3000 0.2000 1.0000 5.1000 3.4000 1.5000 0.2000 1.0000 5.0000 3.5000 1.3000 0.3000 1.0000 4.5000 2.3000 1.3000 0.3000 1.0000 5.1000 3.8000 1.9000 0.4000 1.0000 4.8000 3.0000 1.4000 0.3000 1.0000 5.1000 3.8000 1.6000 0.2000 1.0000 4.6000 3.2000 1.4000 0.2000 1.0000 5.3000 3.7000 1.5000 0.2000 1.0000 5.0000 3.3000 1.4000 0.2000 1.0000 7.0000 3.2000 4.7000 1.4000 2.0000 6.4000 3.2000 4.5000 1.5000 2.0000 6.9000 3.1000 4.9000 1.5000 2.0000 5.5000 2.3000 4.0000 1.3000 2.0000 5.7000 2.8000 4.5000 1.3000 2.0000 6.3000 3.3000 4.7000 1.6000 2.0000 4.9000 2.4000 3.3000 1.0000 2.0000 5.2000 2.7000 3.9000 1.4000 2.0000 5.0000 2.0000 3.5000 1.0000 2.0000 5.9000 3.0000 4.2000 1.5000 2.0000 6.0000 2.2000 4.0000 1.0000 2.0000 6.1000 2.9000 4.7000 1.4000 2.0000 5.6000 2.9000 3.6000 1.3000 2.0000 6.7000 3.1000 4.4000 1.4000 2.0000 5.6000 3.0000 4.5000 1.5000 2.0000 5.8000 2.7000 4.1000 1.0000 2.0000 6.2000 2.2000 4.5000 1.5000 2.0000 5.6000 2.5000 3.9000 1.1000 2.0000 5.9000 3.2000 4.8000 1.8000 2.0000 6.1000 2.8000 4.0000 1.3000 2.0000 6.3000 2.5000 4.9000 1.5000 2.0000 6.1000 2.8000 4.7000 1.2000 2.0000 6.4000 2.9000 4.3000 1.3000 2.0000 6.6000 3.0000 4.4000 1.4000 2.0000 6.7000 3.0000 5.0000 1.7000 2.0000 5.7000 2.6000 3.5000 1.0000 2.0000 5.5000 2.4000 3.8000 1.1000 2.0000 5.5000 2.4000 3.7000 1.0000 2.0000 5.8000 2.7000 3.9000 1.2000 2.0000 6.0000 2.7000 5.1000 1.6000 2.0000 5.4000 3.0000 4.5000 1.5000 2.0000 6.7000 3.1000 4.7000 1.5000 2.0000 6.3000 2.3000 4.4000 1.3000 2.0000 5.6000 3.0000 4.1000 1.3000 2.0000 5.5000 2.5000 4.0000 1.3000 2.0000 5.5000 2.6000 4.4000 1.2000 2.0000 6.1000 3.0000 4.6000 1.4000 2.0000 5.8000 2.6000 4.0000 1.2000 2.0000 5.0000 2.3000 3.3000 1.0000 2.0000 5.6000 2.7000 4.2000 1.3000 2.0000 5.7000 3.0000 4.2000 1.2000 2.0000 5.7000 2.9000 4.2000 1.3000 2.0000 6.2000 2.9000 4.3000 1.3000 2.0000 5.1000 2.5000 3.0000 1.1000 2.0000 5.7000 2.8000 4.1000 1.3000 2.0000 6.3000 3.3000 6.0000 2.5000 3.0000 5.8000 2.7000 5.1000 1.9000 3.0000 7.1000 3.0000 5.9000 2.1000 3.0000 6.3000 2.9000 5.6000 1.8000 3.0000 6.5000 3.0000 5.8000 2.2000 3.0000 7.6000 3.0000 6.6000 2.1000 3.0000 4.9000 2.5000 4.5000 1.7000 3.0000 7.3000 2.9000 6.3000 1.8000 3.0000 6.7000 2.5000 5.8000 1.8000 3.0000 7.2000 3.6000 6.1000 2.5000 3.0000 6.5000 3.2000 5.1000 2.0000 3.0000 6.4000 2.7000 5.3000 1.9000 3.0000 6.8000 3.0000 5.5000 2.1000 3.0000 5.7000 2.5000 5.0000 2.0000 3.0000 5.8000 2.8000 5.1000 2.4000 3.0000 6.4000 3.2000 5.3000 2.3000 3.0000 7.7000 3.8000 6.7000 2.2000 3.0000 5.6000 2.8000 4.9000 2.0000 3.0000 7.7000 2.8000 6.7000 2.0000 3.0000 6.3000 2.7000 4.9000 1.8000 3.0000 6.7000 3.3000 5.7000 2.1000 3.0000 7.2000 3.2000 6.0000 1.8000 3.0000 6.1000 3.0000 4.9000 1.8000 3.0000 6.4000 2.8000 5.6000 2.1000 3.0000 7.2000 3.0000 5.8000 1.6000 3.0000 7.4000 2.8000 6.1000 1.9000 3.0000 7.9000 3.8000 6.4000 2.0000 3.0000 6.4000 2.8000 5.6000 2.2000 3.0000 6.3000 2.8000 5.1000 1.5000 3.0000 6.1000 2.6000 5.6000 1.4000 3.0000 7.7000 3.0000 6.1000 2.3000 3.0000 6.3000 3.4000 5.6000 2.4000 3.0000 6.4000 3.1000 5.5000 1.8000 3.0000 6.0000 3.0000 4.8000 1.8000 3.0000 6.9000 3.1000 5.4000 2.1000 3.0000 6.7000 3.1000 5.6000 2.4000 3.0000 6.9000 3.1000 5.1000 2.3000 3.0000 5.8000 2.7000 5.1000 1.9000 3.0000 6.8000 3.2000 5.9000 2.3000 3.0000 6.7000 3.3000 5.7000 2.5000 3.0000 6.7000 3.0000 5.2000 2.3000 3.0000 6.3000 2.5000 5.0000 1.9000 3.0000 6.5000 3.0000 5.2000 2.0000 3.0000 6.2000 3.4000 5.4000 2.3000 3.0000 5.9000 3.0000 5.1000 1.8000 3.0000 4.7000 3.2000 1.3000 0.2000 1.0000 4.9000 3.1000 1.5000 0.1000 1.0000 5.8000 4.0000 1.2000 0.2000 1.0000 4.4000 3.2000 1.3000 0.2000 1.0000 5.0000 3.5000 1.6000 0.6000 1.0000 6.5000 2.8000 4.6000 1.5000 2.0000 6.6000 2.9000 4.6000 1.3000 2.0000 6.8000 2.8000 4.8000 1.4000 2.0000 6.0000 2.9000 4.5000 1.5000 2.0000 6.0000 3.4000 4.5000 1.6000 2.0000 6.5000 3.0000 5.5000 1.8000 3.0000 7.7000 2.6000 6.9000 2.3000 3.0000 6.0000 2.2000 5.0000 1.5000 3.0000 6.9000 3.2000 5.7000 2.3000 3.0000 6.2000 2.8000 4.8000 1.8000 3.0000];
B= data(:,1:end-1); B = B';
C = data(:,end);
n_class = max(C); class = 1:1:n_class; CC = zeros(n_class,size(data,1));
for k = 1:n_class
for i = 1:size(data,1)
if C(i)==k
CC(k,i) = 1;
else
CC(k,i) = 0;
end
end
end
inputs=data';
targets=CC;
spread=1;
net = newpnn(data',targets,spread);
output= sim(net,data');
view(net)
net.trainFcn = 'trainbr';
net.performFcn = 'mse';
net.plotFcns = {'plotperform','plottrainstate','ploterrhist','plotregression', 'plotfit'}; [ent,tr]=train(net,data',CC);
net.divideFcn = 'dividerand'; net.divideMode = 'sample';
net.divideParam.trainRatio = 50/100; net.divideParam.valRatio = 25/100; net.divideParam.testRatio = 25/100;
nntraintool
outputs = net(inputs); errors = gsubtract(targets,outputs); performance = perform(net,targets,outputs);
trainTargets = targets .* tr.trainMask{1}; valTargets = targets .* tr.valMask{1}; testTargets = targets .* tr.testMask{1}; trainPerformance = perform(net,trainTargets,outputs) valPerformance = perform(net,valTargets,outputs) testPerformance = perform(net,testTargets,outputs)
figure, plotperform(tr) figure, plottrainstate(tr) figure, plotconfusion(targets,outputs)
  1 件のコメント
Greg Heath
Greg Heath 2015 年 1 月 21 日
編集済み: Greg Heath 2015 年 1 月 21 日
The computer cannot read the data matrix because the lines have different lengths
size(data) = ? size(input) = ? size(target) = ? Number of classes?

サインインしてコメントする。


SreeHarish Muppirisetty
SreeHarish Muppirisetty 2015 年 1 月 21 日
You can try with the following steps:
1. Try increasing the number of hidden nodes, in general.
2. Design 10 neural networks, with varying num of hidden nodes..and randomly divide your training, test and validation sets (10 sets each of them). You can even change Performance functions, to see which gives you a good classification.
3. Compute standard error of Mean (SEM), and select the Neural network closest to SEM.
HTH

davykol
davykol 2015 年 1 月 23 日
Here is the codes. I tried to improve them. Can someone help with plotperform(tr) and plottrainstate(tr). Also how to improve it further
[x,t] = crab_dataset; %net = patternnet(10); spread=1.2; net = newpnn(x,t,spread); %net = train(net,x,t); view(net) net.trainFcn = 'trainbr'; y = net(x); [ent,tr]=train(net,x,t);
plotconfusion(t,y)
figure, plotperform(tr) figure, plottrainstate(tr)

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by