Question: oblem 2) [Python] Perceptron learning in Python: a) Create class NeuralNetwork(): that creates a single neuron, train it, and test it. This class should have
![oblem 2) [Python] Perceptron learning in Python: a) Create class NeuralNetwork():](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3249a264db_64966f3249998d00.jpg)

oblem 2) [Python] Perceptron learning in Python: a) Create class NeuralNetwork(): that creates a single neuron, train it, and test it. This class should have the following function: i. def __init_(self): that initializes a 31 weight vector randomly and initializes the learning rate to 1 . ii. def hard_limiter(self, x) : that performs the hard-limiter activation on the nx1 vector x. iii. def forward_propagation(self, inputs): that performs the forward propagation by multiplying the inputs by the neuron weights and passing the output through the hard_limiter activation function. iv. def train(self, inputs, labels, num_train_iterations=10): that performs the perceptron learning rule for num_train_iterations times using the inputs and labels. v. def pred(self,inputs): classifies the inputs to either class 0 or 1 by multiplying them by the neuron weights, passing the output through the hard_limiter activation function and thresholding. b) Use the perceptron learning rule to train a single neuron on the data points given in problem 1: i. Create an np array of the shape of 52 that contains the inputs, and another array with the shape of 51 that contains the labels. ii. Add the bias to the input array to have a 53 shape. iii. Create the network with one perceptron using the class NeuralNetwork(), then train it using train(inputs, labels, 100) function. c) Plot the given data points with two different markers for each group. d) Using the trained perceptron weight, plot the classifier line in the same plot in (c). e) Using the trained perceptron, classify the test data samples given in the table below by calling the pred( ) function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
