AI-For-Beginners
AI-For-Beginners copied to clipboard
Fix perceptron interactive learning rate to use scatter
Fix interactive learning rate code in Perceptron notebook
Fixes #726
Problem
In lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb, the interactive
learning rate experiment uses ax1.plot(...) with an s=100 argument:
ax1.plot(pos_examples[:, 0], pos_examples[:, 1], 'bo', label='Positive', s=100, alpha=0.6)
ax1.plot(neg_examples[:, 0], neg_examples[:, 1], 'ro', label='Negative', s=100, alpha=0.6)
matplotlib.pyplot.plot does not accept the s (marker size) parameter, which
belongs to scatter. This causes the interactive experiment to fail.
Fix
Replaced the plot calls with scatter, which properly supports s and draws
the positive/negative samples as a scatter plot:
ax1.scatter(pos_examples[:, 0], pos_examples[:, 1], color='blue', marker='o', s=100, alpha=0.6, label='Positive')
ax1.scatter(neg_examples[:, 0], neg_examples[:, 1], color='red', marker='o', s=100, alpha=0.6, label='Negative')
Files changed
lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb