⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sprobnn.m

📁 支持向量机(SVM)实现的分类算法源码(matlab)
💻 M
字号:
function [raw,poutput] = sprobnn(train,clsinfo,pred,smooth)
% SPROBNN  simple probabalistic neural network
% Author:	Ron Shaffer
% Revisions:	Version 1.0 3/21/96 (original code)
%
% Syntax
% [raw,poutput] = sprobnn(train,clsinfo,pred,smooth)
%
% raw:		matrix of raw outputs (number of patterns in test X ncls)
% poutput:	matrix of class probabilities (number of patterns in test x ncls)
% train:	training set patterns (number of patterns x number of sensors) 
% clsinfo:	number of patterns in each class (vector)
% pred:		test set patterns (number of patterns x number of sensors)
% smooth:	smoothing factor

% For additional information on probabilist neural networks (PNN) see:
% D.F. Specht, "Probabilistic Neural Networks", Neural Networks, 3, 1990, 110-118.
% Timothy Masters "Advanced Algorithms for Neural Networks", Wiley, 1995.
%
% Ron Shaffer 
% shaffer@ccf.nrl.navy.mil
% NRC-NRL PostDoctoral Research Associate
% Naval Research Laboratory
% Chemistry Division, Code 6110
% Washington DC 20375

%
%
% set constants
%
[npat_t,ndim] = size(train);
[npat_p,junk] = size(pred);
nhcel = npat_t;
temp = size(clsinfo);
ncls = max(temp);
smooth_sqr = smooth * smooth;
%
% normalize training and prediction patterns (using normr method of
% Mark Beale from Mathworks in neural net toolbox)
%
workt = sqrt(ones./(sum((train.*train)')))'*ones(1,ndim).*train;
workp = sqrt(ones./(sum((pred.*pred)')))'*ones(1,ndim).*pred;
%
% move training data to hidden units (i.e., training)
%
hcel = workt;
%
% now perform prediction by propagating prediction patterns through network
%
% 
% first perform dot product calculation
% NOTE:  other distance calculations can be used.  For example, the euclidean 
% distance calculation is often employed.  If you want to change to another
% distance calculation replace [hcel*workp'] with your distance measure.
%
hold = hcel*workp'; 
propmat = exp((hold - 1)/smooth_sqr);
hold = hold';
propmat  = propmat';
%
for i = 1:npat_p

%	summation for each output layer

	count = 0;
	for j = 1:ncls
		output(i,j) = 0;
		for k = 1:clsinfo(j)
			count = count + 1;
			output(i,j) = output(i,j) + propmat(i,count);
		end
	end
end
%
% compute probability for each class (assume equal a prior probabilities)
%
raw = output;
holdvector = sum(raw')';
for i = 1:npat_p
	poutput(i,1:ncls) = output(i,1:ncls) / holdvector(i);
end
%


	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -