📄 pnndemo.m
字号:
% PNNDEMO -- Probabilistic Neural Network Demo m-file
% Ron Shaffer
% Naval Research Laboratory
% 3-21-96
%
fprintf ('Probabilistic Neural Network Demo \n')
fprintf ('Ron Shaffer \n')
fprintf ('Naval Research Laboratory \n \n');
junk = input ('Hit any key to continue');
fprintf ('Loading Mark Andersons simulated surface acoustic wave chemical sensor data set. \n');
load ma.mat
fprintf ('The goal of this classification problem is to predict the classification \n');
fprintf ('of the vapors in the test set. The training set is a 300 by 3 matrix \n');
fprintf ('containing the responses for a three sensor array to 300 samples. In \n');
fprintf ('this matrix the first 100 samples were contained chemical vapor 1, the \n');
fprintf ('second 100 samples were chemical vapor 2, and the last 100 \n');
fprintf ('samples were chemical vapor 3. The test set is constructed in \n');
fprintf ('a similar manner but does not contain any samples found in the training set. \n');;
fprintf ('For more information about how this simulated data were constructed see \n');
fprintf ('Mark Anderson and Dave Venezsky, Investigation of Probabilistic Neural \n');
fprintf ('Networks for Sensor Array Pattern Recognition, NRL-Memorandum Report 7798 \n');
fprintf (', February 1996 or email: shaffer@ccf.nrl.navy.mil. \n');
junk = input ('Hit any key to continue');
fprintf ('Probabilistic Neural Networks (PNN) require little training! \n');
fprintf ('Training involves simply placing the patterns in the training set into the hidden units \n');
fprintf ('of the neural network. Although, for optimal performance, adjustment of the smoothing \n');
fprintf ('factor must be performed. Now we can predict the classification of the patterns \n');
fprintf ('in the prediction (test) set.\n');
smooth = input ('Input a smoothing factor for the PNN [I recommend 0.1] ');
class_info = [100 100 100];
[raw,prob] = sprobnn(inp,class_info,test,smooth);
prob = prob .* 100;
fprintf ('Finished classification of the patterns in the test set \n');
junk = input ('Hit any key to see results');
fprintf('Probability of each pattern belonging to each class (chemical vapor): \n');
fprintf('Sample # Vapor1 Vapor2 Vapor3 \n');
for j = 1:300
fprintf ('%d %7.4f %7.4f %7.4f \n',j,prob(j,1),prob(j,2),prob(j,3));
end
%
% compute percentage correct
%
hold1 = prob';
[hold2,winout] = max(hold1);
winout = winout';
junk = input ('Hit any key to see the number correctly classified for each chemical vapor');
%
%
% now compute the percentage correct for each output class
%
count = 0;
missedct = 0;
for i = 1:3
ncorrect(i) = 0;
for j = 1:100
count = count + 1;
if winout(count) == i
ncorrect(i) = ncorrect(i) + 1;
else
missedct = missedct + 1;
mispat(missedct,1) = count;
mispat(missedct,2:4) = raw(count,1:3);
mispat(missedct,5:7) = test(count,1:3);
end
end
end
%
fprintf('The percentage correct is: \n');
for i = 1:3
fprintf('Chemical Vapor %d \t %6.3f \n',i,ncorrect(i)');
end
fprintf ('End of PNN Demo \n');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -