资源简介
AP聚类,Matlab程序,内附有Demo,可清晰演示聚类过程。
代码片段和文件信息
function [idx a r output] = affprop(s options)
%AFFPROP idenfities exemplar points using affinity propogation
%
% IDX = AFFPROP(S)
% returns IDX a m-vector of indices such that idx(i) is the index to
% the exemplar of the ith point. For exemple if x is an underlying data
% matrix then x(i:) is clustered with x(idx(i):) and x(idx(i)) is the
% exemplar.
% S is a m x m similarity matrix. It need not be symmetric. The diagonal
% indicates a prior preference that point s(ii) is an examplar. Points
% with higher values are more likely to be choosen
%
% IDX = AFFPROP(...OPTIONS)
% options is a structure that set properties for the search
% ‘MaxIter‘ 200... maximum number of iterative refinements
% ‘TolX‘ 1e-6 ... termination tolerance for norm of message matrices
% ‘StallIter‘ 20 ... cumulative number of generations for which
% IDX does not change
% ‘Dampening‘ .5 dampening factor (or 1-learning rate)
% ‘OutputFcn‘[] function called each iteration with message
% matrices fun(ar)
%
% [IDX R A OUTPUT] = AFFRPOP(...)
% also returns the message matrices R and A
% R is a ‘responsibility‘ matrix. R(i:) is a row vector of message
% from point i to the other points indicating how well suited point k
% is for being an exemplar for point i.
% A is an availability matrix. A(:k) is a
% column vector of messages from point k to the other points
% indicating how available point k is for being an exemplar.
% Availabilities and Responsibilities are added together to determine
% exemplars. The value k that maximizes a(ik) + r(ik) indicates the
% examplar for point i.
%
%Example - requires stats toolbox
% M = [5 0; 0 5; 2.5 2.5]; % true centers
% V = [1 .9; .9 1];
% L = chol(V);
% idx = repmat( 1:3 50 1 ); % true assignment
% x = M(idx(:):) + randn(1502)*L; % data points with noise
% m = size(x1);
% di = 1:(m+1):m*m; %index to diagonal elements
% d = -pdist(x ‘mah‘); %upper triangle similiarity
% s = squareform(d); %squareform
% s(di) = min(d(:));
% options.StallIter = 10;
% options.OutputFcn = @(ar) affprop_plot(arx‘k.‘);
% figure
% ex = affprop(s options );
%
%Example - for example that doesn‘t require stats toolbox ...
% See also affprop_demo
%
%Reference
% Frey and Dueck “Clustering by Passing Messages Between Data Points“
% Science 2007 315:972-976
% Copyright 2006 Mike Boedigheimer
% Amgen Inc.
% Department of Computational Biology
% mboedigh@amgen.com
m = size(s1);
defaultopt = struct( ‘MaxIter‘ 200...
‘StallIter‘ 20 ...
‘FunValCheck‘‘off‘ ...
‘Dampening‘ .5 ...
‘OutputFcn‘[]);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6107 2007-07-04 11:07 affinity_propagation\affprop.m
文件 1706 2007-07-09 21:34 affinity_propagation\affprop_demo.m
文件 923 2007-07-09 21:30 affinity_propagation\affprop_plot.m
- 上一篇:贝叶斯方法matlab画图GUI界面
- 下一篇:KPCA(经典的MATLAB程序)
评论
共有 条评论