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

📄 proxm.m

📁 模式识别 MATLAB 的工具箱,比较实用,包括SVM,ICA,PCA,NN等等模式识别算法.
💻 M
字号:
%PROXM Proximity mapping% % 	W = proxm(A,type,p,g)% % Computation of the k*m proximity mapping (or kernel) defined by % the m*k dataset A. If B is a n*k dataset then B*W is the n*m % proximity matrix between B and A. The proximities are defined by % the following possible types: % % 	'polynomial'   | 'p': sign(a*b'+1).*(a*b'+1).^p% 	'exponential'  | 'e': exp(-(||a-b||)/p)% 	'radial_basis' | 'r': exp(-(||a-b||.^2)/(p*p))% 	'sigmoid'      | 's': sigm((sign(a*b').*(a*b'))/p)% 	'distance'     | 'd': ||a-b||.^p% % In the polynomial case and p not integer D is computed by D = % sign(d)*abs(d).^p in order to avoid problems with negative inner % products d. The features of the objects in A and B may be weighted % by the weights in the vector g (default 1).% % Default is the Euclidean distance: type = 'distance', p = 1% % See also mappings, datasets% Copyright: R.P.W. Duin, duin@ph.tn.tudelft.nl% Faculty of Applied Physics, Delft University of Technology% P.O. Box 5046, 2600 GA Delft, The Netherlandsfunction W = proxm(A,type,s,g)if nargin < 4, g = []; endif nargin < 3 | isempty(s), s = 1; endif nargin < 2 | isempty(type), type = 'd'; endif nargin < 1 | isempty(A)	W = mapping('proxm',{type,s,g});	returnend[m,k] = size(A);A = dataset(A);if isstr(type)	W = mapping('proxm',A,getlab(A),k,m,1,{type,s,g});	returnendif ~isa(type,'mapping')	error('Illegal arguments')end[B,lablist,t,kk,n,v,par] = mapping(type);B = dataset(B);type = par{1};s = par{2};g = par{3};if k ~= kk, error('Matrices should have equal numbers of columns'); endif ~isempty(g)	if length(g) ~= k, error('Weight vector has wrong length'); end	A = A.*(ones(m,1)*g(:)');	B = B.*(ones(n,1)*g(:)');endif strcmp(type,'polynomial') | strcmp(type,'p')	W = +(A*B'); 	W = W + ones(m,n);	if s ~= round(s)		W = sign(W).*abs(W).^s;	elseif s ~= 1		W = W.^s;	endelseif strcmp(type,'sigmoid') | strcmp(type,'s')	W = +(A*B'); 	W = sigm(W/s);else	W = ones(m,1)*sum(B'.*B',1); 	W = W  + sum(A'.*A',1)'*ones(1,n); 	W = W -2 .* (+A)*(+B)';	J = find(W<0);	W(J) = zeros(size(J));	if strcmp(type,'exponential') | strcmp(type,'e')				W = exp(-sqrt(W)/s);	elseif strcmp(type,'radial_basis') | strcmp(type,'r')		W = exp(-W/(s*s));	elseif strcmp(type,'distance') | strcmp(type,'d')		if s ~= 2			W = sqrt(W).^s;		end	else		error('Unknown proximity type')	endendif isa(A,'dataset') | isa(B,'dataset') 	if isa(A,'dataset'); laba = getlab(A); else laba = [1:m]; end	if isa(B,'dataset'); labb = getlab(B); else labb = [1:m]; end	W = dataset(W,laba,labb);end

⌨️ 快捷键说明

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