Professional Documents
Culture Documents
Sample Program:
import numpy as np
# Define the input data (X) and corresponding target labels (y) for OR gate
X = np.array([[0, 0],
[0, 1],
[1, 0],
[1, 1]])
y = np.array([0, 1, 1, 1]) # OR gate truth table
perceptron = Perceptron(random_state=42)
perceptron.fit(X, y)
# Make predictions
predictions = perceptron.predict(test_data)
for i in range(len(test_data)):
import numpy as np
# Define the input data (X) and corresponding target labels (y) for OR gate
X = np.array([[0, 0],
[0, 1],
[1, 0],
[1, 1]])
perceptron = Perceptron(random_state=42)
perceptron.fit(X, y)
# Make predictions
predictions = perceptron.predict(test_data)
for i in range(len(test_data)):