Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Perceptron in Python v. 1
import numpy as np
from perceptron import Perceptron
training_inputs = []
training_inputs.append(np.array([1, 1]))
training_inputs.append(np.array([1, 0]))
training_inputs.append(np.array([0, 1]))
training_inputs.append(np.array([0, 0]))
labels = np.array([1, 0, 0, 0])
perceptron = Perceptron(2)
perceptron.train(training_inputs, labels)
inputs = np.array([1, 1])
perceptron.predict(inputs)
#=> 1
inputs = np.array([0, 1])
perceptron.predict(inputs)
#=> 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment