資源簡介
基于MATLAB的密度聚類程序,DBSCAN.m,運行正確。
代碼片段和文件信息
function?[classtype]=dbscan(xMinpEps)
%?Function:?[classtype]=dbscan(xkEps)
%?基于密度的聚類算法(DBSCAN)
%?輸入:?
%?x?-?數據?設置為(mn);?m-目標數?n-變量數(維數)
%?Minp?-?number?of?objects?in?a?neighborhood?of?an?object?
%?(能夠被認為是一個類的最少目標數)
%?Eps?-?neighborhood?radius?if?not?known?put?[]
%
%?輸出:?
%?class?-?vector?specifying?belongingness?of?the?i-th?object?to?certain?cluster?(m1)
%?指定第i個目標所屬類的向量
%?type?-?vector?specifying?type?of?the?i-th?object?(core:?1?border:?0?outlier:?-1)
%?指定第i個目標的類型(中心:1,邊境:0,離群:-1)
%?Example?of?use:
%?x=[randn(302)*.4;randn(402)*.5+ones(401)*[4?4]];
%?[classtype]=dbscan(x5[])
%??????????
%?References:
%?[1]?M.?Ester?H.?Kriegel?J.?Sander?X.?Xu?A?density-based?algorithm?for?discovering?
%?clusters?in?large?spatial?databases?with?noise?proc.?2nd?Int.?Conf.
%?on?Knowledge?Discovery?and?Data?Mining?Portland?OR?1996?p.?226
%?available?from:?www.dbs.informatik.uni-muenchen.de/cgi-bin/papers?query=--CO
%?[2]?M.?Daszykowski?B.?Walczak?D.?L.?Massart?Looking?for?Natural?Patterns?in?Data.?
%?Part?1:?Density?based?Approach?Chemom.?Intell.?Lab.?Syst.?56?(2001)?83-92?
%?Michal?Daszykowski
%?Department?of?Chemometrics
%?The?University?of?Silesia
%?9?Szkolna?Street
%?40-006?Katowice?Poland
[mn]=size(x);
k=Minp;
if?nargin<3?||?isempty(Eps)
???[Eps]=epsilon(xk);
end
x=[(1:m)‘?x];
[mn]=size(x);
type=zeros(1m);
no=1;
touched=zeros(m1);
for?i=1:m
????if?touched(i)==0;
???????ob=x(i:);
???????D=dist(ob(2:n)x(:2:n));
???????ind=find(D<=Eps);
????
???????if?length(ind)>1?&&?length(ind) ??????????type(i)=0;
??????????class(i)=0;
???????end
???????if?length(ind)==1
??????????type(i)=-1;
??????????class(i)=-1;??
??????????touched(i)=1;
???????end
???????if?length(ind)>=k+1;?
??????????type(i)=1;
??????????class(ind)=ones(length(ind)1)*max(no);
??????????
評論
共有 條評論