Question: I HAVE BEEN WORKING to implement this codes for 3 days and I need help: Thanks The fit function def fit(self, X, y, pocket =

I HAVE BEEN WORKING to implement this codes for 3 days and I need help:

Thanks

The fit function def fit(self, X, y, pocket = True, epochs = 100): if(self.degree > 1): X = z_transform(X, degree=self.degree) let n and d be the row count and column count of X Insert the bias column into X // use np.insert Init self.w to an (d+1) x 1 matrix of all 0. if not pocket: while the last epoch has made at lease one change to self.w for i in range(n): if X[i] is misclassifed: //use np.sign(matrix row @ self.w) update self.w using the PLA algorithm else: while last epoch has changed self.w and epochs > 0: epochs -= 1 for i in range(n): if X[i] is misclassifed: //use np.sign(matrix row @ self.w) update self.w using the PLA algorithm use self.w to calc total misclassified count //use @, np.sign, np.sum save self.w as best_w, if total misclassified count becomes smaller self.w = best_w

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!