The Perceptron is one of the fundamental concepts of Neural Networks. Being based off a single neuron, the perceptron is an algorithm for supervised learning of binary classifiers. It is a type of linear classifier, i.e. a classification algorithm that makes its predictions based on a linear predictor function combining a set of weights with the feature vector. The algorithm allows for online learning, in that it processes elements in the training set one at a time.
My first experience of programming ML concepts was the perceptron, training it to take in two binary inputs and predict the output for AND and OR gates.
Python code for Perceptron
sampleData=[[0,0,0],[0,1,0],[1,0,0],[1,1,1]]#each item includes input1, input2 and the expected result for an AND gate
sampleData=[[0,0,0],[0,1,1],[1,0,1],[1,1,1]]#each item includes input1, input2 and the expected result for an OR gate
print("Unrecognised value for TYPE.")
for item in sampleData:
total=item*weights+item*weights#calculates dot product of two vectors
if total>=threshold and item==0:
modifier=-1 #if dot product>threshold, modifier used to lower weightings
print("input1: "+str(item)+" input2: "+str(item)+" --> "+str(output)+" (should be "+str(item)+")")