Realization of perceptual machine algorithm based on MATLAB--Statistical learning comparisonof

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.