# Machine Learning Meetup Notes Perceptron Matlab

From Noisebridge

% Perceptron Implementation (by Jean) % indata = [1,0,0;1,0,1;1,1,0;1,1,1]; expected = [1,1,1,0]; % Learning Rate LR = 0.1; % Initial set of weights. weights = [0,0,0]; threshold = 0.5; delta = 1; error = 1; % Outside loop to iterate weights. while (error ~= 0) error = 0; for i = 1:size(indata,1) % bias term is the threshold. if (dot(weights,indata(i,:)) > threshold) % dot(weights,indata(i,:)) out = 1; else out = 0; end % direction of learning direction = expected(i) - out; delta = direction * LR * indata(i,:); weights = weights + delta; if (norm(delta) ~= 0) error = 1; end end end % Display the final output weights. weights