[Home]
kPPC
A Matlab code for k-Proximal Plane Clustering. [Code]
Reference
Yuan-Hai Shao,Yan-Ru Guo, Zhen Wang, Zhi-Min Yang, and Nai-Yang Deng. k-Proximal Plane Clustering,2013,Submitted.
Main Function
Need stdata;kernelfun;Initialization11;GepOneSide;Getchushi8;GepCluster8 function.
pY =kPPC(X,rX,k,knn,W,FunPara);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% kPPC: k-Proximal Plane Clustering
%
% pY =kPPC(X,rX,k,knn,W,FunPara);
%
% Input: X - data points matrix. Each row vector of fea is a data point
% rX- the data points who is used to construct the initial plane
% k- number of cluster;
% knn- number of nearest neighbors;
% W- the construct the initial plane;
% FunPara - Struct value in Matlab. The fields in options that can be set:
% c: [0,inf] appropriate parameter to tune the weight.
% kerfPara: Kernel parameters. See kernelfun.m.
%
%
% Examples:
% X = rand(50,10);Y=[ones(20,1); ones(20,1)+1; ones(10,1)+2];
% c=0.01;k=3; kerfPara.type = 'lin';
% pY =kPPC(X,rX,k,knn,W,FunPara);
%
% Reference:
% Yuan-Hai Shao,Yan-Ru Guo and Zhen Wang. k-Proximal Plane Clustering,2013,Submitted.
%
% Version 1.0 --Dec/2013
%
% Written by Yan-Ru Guo ("Guoyanru211@163.com")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Initailization
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%tic;
m=size(X,1);Y1=zeros(m,1);book=sparse(m,m);cnt=sparse(m,m);d=1; knn=3;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Each data point is normalized with the mean 0 and standard deviation 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
stX=stdata(X);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% initialize the input stX to get the cluster Y1 and rX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Y1,rX]=Initialization11(stX,k,knn);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Construct the initial plane W
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
W=Getchushi8(rX,k,c);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Update plane W:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[s,t]=size(stX); pY=crossvalind('kfold',s,k);pYnew=zeros(s,1);z=0;
while(~isempty(find(pY~=pYnew, 1)) && z~=1000)
pYnew=pY;
z=z+1;
% update plane W
for i=1:k
tA=stX((pY==i),:);
tB=stX((pY~=i),:);
mi=size(tA,1);
if ~isempty(find(pY==i, 1))
W(i,:)=GepOneSide(tA,tB,c);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Predict and output
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if strcmp(kerfPara.type,'lin')
pY=abs(stX*W(:,1:t)'+ones(s,1)*W(:,t+1)');
else
pY=abs(stX*W(:,1:s)'+ones(s,1)*W(:,s+1)');
end
[tmp,pY]=min(pY');
pY=pY';
end
Any question or advice please email to shaoyuanhai21@163.com and Guoyanru211@163.com.
- Last updated: December 27, 2013