[Home]


PCC

A Matlab code for proximal classifier with consistency. (You could Right-Click [Code] , and Save, then you can download the whole matlab code.)


Reference

Y.-H. Shao, N.-Y. Deng, W.-J. Chen. A proximal classifier with consistency, Knowledge-Based Systems,2013, 49:171-178


Main Function

Need kernel function.

function Predict_Y = PCC(TestX,DataTrain,FunPara) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PCC: A proximal classifier with consistency % % Predict_Y = PCC(TestX,DataTrain,FunPara) % % Input: % TestX - Test Data matrix. Each row vector of fea is a data point. % % DataTrain - Struct value in Matlab(Training data). % DataTrain.A: Positive input of Data matrix. % DataTrain.B: Negative input of Data matrix. % % FunPara - Struct value in Matlab. The fields in options that can be set: % c: [0,inf] Paramter to tune the weight. % mu: [0,inf] Paramter to tune the weight. % kerfPara:Kernel parameters. See kernelfun.m. % % Output: % Predict_Y - Predict value of the TestX. % % Examples: % DataTrain.A = rand(50,10); % DataTrain.B = rand(60,10); % TestX=rand(20,10); % FunPara.c=0.1; % FunPara.mu=0.1; % FunPara.kerfPara.type = 'lin'; % Predict_Y =PCC(TestX,DataTrain,FunPara); % % Reference: % Yuan-Hai Shao, Nai-Yang Deng and Wei-Jie Chen, "A proximal classifier % with consistency" Submitted 2013 % % Version 1.0 --Apr/2013 % % Written by Wei-Jie Chen (wjcper2008@126.com) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Initailization %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %tic; Xpos = DataTrain.A; Xneg = DataTrain.B; c = FunPara.c; mu = FunPara.mu; kerfPara = FunPara.kerfPara; m1=size(Xpos,1);m2=size(Xneg,1); e1=ones(m1,1);e2=ones(m2,1); TrainX=[Xpos;Xneg]; [m,n]=size(TestX); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Compute Kernel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if ~strcmp(kerfPara.type,'lin') Xpos=kernelfun(Xpos,kerfPara,TrainX); Xneg=kernelfun(Xneg,kerfPara,TrainX); TestX=kernelfun(TestX,kerfPara,TrainX); end Hpos=[Xpos e1]'*[Xpos e1]; Hneg=[Xneg e2]'*[Xneg e2]; M=Hpos-mu*Hneg; N=Hneg-mu*Hpos; if ~strcmp(kerfPara.type,'lin') M=M+c*eye(m1+m2+1); N=N+c*eye(m1+m2+1); else M=M+c*eye(n+1); N=N+c*eye(n+1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Compute (w1,b1) and (w2,b2) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%