1 clear All;2 CLC;3%%4%algorithm5% Input: training data Set t ={(x1,y1), (X2,y2), ..., (Xn,yn)}; learning rate η6% output: w,b; Perceptron model f (x) = sign (w*x+b)7%(1) Select the initial value w0,b08%(2) Select data in the training set (Xi,yi)9%(3) if Yi (w*xi+b) <=0Ten% W = w+η*yi*XI One% B = C +Ηyi A%(4) Go to (2) until there are no mis-classification points in the training set -%% - the%Initialize -X = [3 3 1;4 3 1;1 1-1];%Training Set -[SN,FN] =size (X); -y =X (:, FN);% label +X (:, fn) = []; -fn = fn-1; +W = zeros (2,1); Ab =0; atYta =1;% parameter η -OK =0; -%% -%Loop Body - while(ok==0)%%%continuous scanning until all instances are met with an unmistakable classification point before the end - fori =1: SN in if(Y (i) * (w'*x (i,:)'+B) <=0) - tow = w + yta*y (i) *x (i,:)' +B = B + yta*y (i) - Else the if(i = = sn) ok=1; * Break $ EndPanax Notoginseng End - End the End + A%% the%Diagram +Figure1) -Plot (X (1,:), X (2,:),'R.') $ on $Plot (X (3,:),'*') %Sample -Xmin=min (X (:,1)); -Xmax=max (X (:,1)); the% Ymin=min (X (:,2)); -% Ymax=max (X (:,2)); Wuyixindex=xmin-1:(xmax-xmin)/ -: xmax+1; theYindex=w (1) *xindex+w (2) *xindex+b; -Plot (Xindex,yindex)% category polygons
Realization of perceptual machine algorithm based on MATLAB--Statistical learning comparisonof