Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pls help answer the quesion in the screenshot below, filling the code to satisfied the requirement. All the data set was in my computer already.

Pls help answer the quesion in the screenshot below, filling the code to satisfied the requirement. All the data set was in my computer already. Thanks!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Complete the Perceptron class. You can test your accuracy results using the "test_accuracy" function in "main.py". Perceptron(object): ef _init__(self, max_iter): self.max_iter = max_iter ef fit(self,X,y) : "" "Train perceptron model on data (X,y). Args: X: An array of shape [n_samples, n_features]. y : An array of shape [n_samples,]. Only contains 1 or 1. Returns: self: Returns an instance of self. \#\#\# YOUR CODE HERE \# After implementation, assign your weights w to self as below: # self.W =w \#\#\# END YOUR CODE return self def get_params(self): "" "Get parameters for this perceptron model. Returns: W: An array of shape [n_features,]. if self.W is None: print("Run fit first!") return self.W(-1) def predict(self, X): "" "Predict class labels for samples in X. Args : X: An array of shape [n_samples, n_features]. Returns: preds: An array of shape [n_samples,]. Only contains 1 or 1. \#\#\# YOUR CODE HERE \#\#\# END YOUR CODE lef score(self, x,y) : "" "Returns the mean accuracy on the given test data and labels. Args: X: An array of shape [n_samples, nfeatures]. y : An array of shape [n_samples,]. Only contains 1 or 1. Returns: score: An float. Mean accuracy of self.predict(X) wrt. y. \#\#\# YOUR CODE HERE \#\#\# END YOUR CODE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions