rasbt / python-machine-learning-book-3rd-edition

The "Python Machine Learning (3rd edition)" book code repository
https://www.amazon.com/Python-Machine-Learning-scikit-learn-TensorFlow/dp/1789955750/
MIT License
4.6k stars 1.98k forks source link

NameError: name 'Perceptron' is not defined #141

Closed daledet closed 3 years ago

daledet commented 3 years ago

NameError Traceback (most recent call last)

in ----> 1 ppn = Perceptron(eta=0.1, n_iter=10) 2 ppn.fit(X,y) 3 plt.plot(range(1, len(ppn.errors_) + 1), 4 ppn.errors_, marker='o') 5 plt.xlabel('Epochs') NameError: name 'Perceptron' is not defined
rasbt commented 3 years ago

Hi there,

in which chapter did you get the error?

daledet commented 3 years ago

Chapter 2 Page 33 It looks like it is calling the Perceptron class, but for some reason it cannot be found.

rasbt commented 3 years ago

Thanks. Should be defined on pg. 27. Maybe you accidentally skipped it.

Screen Shot 2020-12-10 at 9 21 01 AM
daledet commented 3 years ago

I have the Perceptron class in my code, but it is not working.

rasbt commented 3 years ago

Maybe there is a typo somewhere? When you use the code from https://github.com/rasbt/python-machine-learning-book-3rd-edition/tree/master/ch02 it works?