Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with scatter plot in chap 3 #151

Closed
austinofohio opened this issue May 25, 2021 · 2 comments
Closed

Issue with scatter plot in chap 3 #151

austinofohio opened this issue May 25, 2021 · 2 comments

Comments

@austinofohio
Copy link

austinofohio commented May 25, 2021

I'm working with the code in chapter 3 in windows powershell and I can't get the code to run. I'm working with the first part of the code where we are plotting the three flower cases while training the perceptron.

I am getting this error:

image

Here's the version of numpy, Python, matplotlib, pandas, and sklearn that I have currently unstalled:

Python: 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
numpy: 1.20.3
matplotlib: 3.4.2
pandas: 1.2.4
sklearn: 0.24.2

Please note that I am using the code provided on packt.com

@austinofohio
Copy link
Author

austinofohio commented May 25, 2021

I installed an older version of matplotlib, 3.3.0, and it worked. However I believe from versions 3.3.2 and on a explicit list will be needed in place of a string of single colors.

@rasbt
Copy link
Owner

rasbt commented May 26, 2021

Thanks for the note and looking into it! It seems that it is a matplotlib 3.4 issue indeed. Changing the c argument from

        if LooseVersion(matplotlib.__version__) < LooseVersion('0.3.4'):
            plt.scatter(X_test[:, 0],
                        X_test[:, 1],
                        c='',
                        edgecolor='black',
                        alpha=1.0,
                        linewidth=1,
                        marker='o',
                        s=100, 
                        label='test set')

to

            plt.scatter(X_test[:, 0],
                        X_test[:, 1],
                        c='none',
                        edgecolor='black',
                        alpha=1.0,
                        linewidth=1,
                        marker='o',
                        s=100, 
                        label='test set')        

fixes that. Updated it in the notebook.

@rasbt rasbt closed this as completed May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants