The perceptron algorithm belongs to a relatively simple classifier algorithm, but it belongs to the construction classification super plane as the logistic regression and support vector machine.
the difference is that the perceptual machine uses the distance of the split-error sample and the classified super-plane as the loss function, The following algorithm is based on the stochastic gradient descent method, and the convergence State is achieved by asynchronous method.
function [W,b]=perceptionlearn (X,y,learningrate,maxepoch)% Perception learn algorithm% x, y row is a sample, Y value { -1,+1}[m,n]= Size (x); W=zeros (n,1); b=0;finish=true;for Epoch=1:maxepoch for samlendex=1:m if sign (x (Samlendex,:) *w+b) ~= Y (samlendex) finish=false; W=w+learningrate*y (Samlendex) *x (samlendex,:) ' %w=w/(w ' *w); B=b+learningrate*y (Samlendex) end End if finish==true break ; EndEnd
Test function:
CLEAR;CLC;X=[3,3;4,3;1,1];Y=[1,1,-1]; [W,b]=perceptionlearn (x,y,1,20)
Perceptual machine Algorithm (MATLAB)