You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Glad to see you're trying the algorithms described in the book. However, I would recommend adding more context to your questions: page? chapter? section? class? method?? what input values did you use (if any)? and even better, the actual script you used.
Based on the traceback, I assume you are in chapter 2, "Implementing a perceptron learning algorithm in Python". I implemented that one some time ago and it worked just fine. Therefore, my first assumption is that you have some typo in your script (we would only know if you provide your actual code).
The type of error you mentioned is typical of trying to multiply by a string (e.g., '1.0' * 1.). Check your code and post more questions (and more context) if required.
I agree with @Lijantropique : a bit more information would help, and I suspect a typo somewhere in the code. I just checked the code notebook and it seems to work fine with the most recent NumPy version.
and check if that works. Then, I would recommend comparing the Perceptron code in ch02.py with your script to find out any differences that may be causing your issue.
I am getting this error at the np.dot for the Iris data set. Can you explain the solution ?
Following is traceback :
Traceback (most recent call last):
File "Perceptron.py", line 61, in
ppn.train(x, y)
File "Perceptron.py", line 24, in train
update = self.eta * (target - self.predict(xi))
File "Perceptron.py", line 35, in predict
return np.where(self.net_input(X) >= 0.0, 1, -1)
File "Perceptron.py", line 32, in net_input
return np.dot(X, self.w_[1:]) + self.w_[0]
The text was updated successfully, but these errors were encountered: