Answered step by step
Verified Expert Solution
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!
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 CODEStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started