www.pudn.com > kernelSVM.rar > SMO_algorithm.m


function outPutPar = SMO_algorithm(class_one,class_two,kPar,C)
% the function for generating the two_class based classification
% InputPar:
% class_one: the first class data;
% class_two: the second class data;
% sizeTrainClassOne: the size of the training number of the first class
% data;
% sizeTrainClassTwo: the size of the training number of the second class
% data;
% OutputPar:
% outPutPar.w:
% outPutPar.b;
% outPutPar.alpha;
% Written by WangZhe on 2005-04-05;
size_class_one = size(class_one,1);
size_class_two = size(class_two,1);
Y=[ones(size_class_one,1);-1*ones(size_class_two,1)];
% input data completed

X=[class_one;class_two];

mat_kernel=(X*X'+1).^kPar;
% calculate the kernel use a kernel

trainSampleNum = size_class_one+size_class_two;
alpha=zeros(trainSampleNum,1);
b=0;
% set the value of alpha ,b and C

littleValue=10^(-7);
% the little value control the precison of this programj

% the allowed times that is against KKT conditions
loop_times=0;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

while(loop_times<5000)
    sup_index = find(alpha>littleValue & alphalittleValue));
outPutPar.w=((alpha.*Y)'*X)';
outPutPar.b=b;
outPutPar.alpha=alpha;