Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG] improving plot_digits_pipe.py by adjusting parameters and making the graph more clear #14346

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

Merged
merged 6 commits into from
Oct 29, 2019

Conversation

Timsaur
Copy link
Contributor

@Timsaur Timsaur commented Jul 13, 2019

Reference Issues/PRs

What does this implement/fix? Explain your changes.

changed hyperparameters from:

'pca__n_components': [5, 20, 30, 40, 50, 64],
'logistic__alpha': np.logspace(-4, 4, 5),

to:

'pca__n_components': [5, 15, 30, 45, 64],
'logistic__alpha': np.logspace(-4, 4, 4),

Any other comments?

the outputs for the original hyperparameters:

Best parameter (CV score=0.919):
{'logistic__alpha': 0.01, 'pca__n_components': 64}

time = 5.745687007904053

after changes:

Best parameter (CV score=0.914):
{'logistic__alpha': 0.046415888336127774, 'pca__n_components': 64}

time = 3.6879332065582275

@qinhanmin2014
Copy link
Member

thanks for the PR, then run time of this example is <10s, so we don't need to make it faster.

@NicolasHug
Copy link
Member

I'll respectfully re-open: this example was listed as "needs speed up" in the original issue #13383.

A small speed-up is always useful, especially when it comes from a new sprint attendee.


In addition to the proposed changes, I'd like to suggest a few more to improve the example:

  • the vertical bar is invisible right now. This can be improved by setting plt.xlim(-1, 70)
  • 'PCA explained variance' should be 'PCA explained variance ratio'
  • the PCA explained variance ratio plot should go from 1 to 64 instead of 0 to 63. This can be done with ax0.plot(1 + np.arange(64), pca.explained_variance_ratio_, '+', linewidth=2).

@Timsaur would you be able to handle these? Feel free to ask for help.

@NicolasHug NicolasHug reopened this Jul 14, 2019
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if all goes green, thanks @Timsaur!

@Timsaur Timsaur changed the title [MRG] make plot_digits_pipe.py faster by adjusting hyperparameters [MRG] improving plot_digits_pipe.py by adjusting parameters and making the graph more clear Jul 14, 2019
@@ -56,8 +56,8 @@
pca.fit(X_digits)

fig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True, figsize=(6, 6))
ax0.plot(pca.explained_variance_ratio_, linewidth=2)
ax0.set_ylabel('PCA explained variance')
ax0.plot(1 + np.arange(64), pca.explained_variance_ratio_, '+', linewidth=2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ax0.plot(1 + np.arange(64), pca.explained_variance_ratio_, '+', linewidth=2)
ax0.plot(np.arange(1, 65), pca.explained_variance_ratio_, '+', linewidth=2)

Copy link
Member

@TomDLT TomDLT Jul 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.arange(1, pca.n_components_ + 1) ?

@adrinjalali
Copy link
Member

@Timsaur could you please resolve the merge conflicts?

@NicolasHug
Copy link
Member

@Timsaur don't hesitate to ask if you need help with conflict resolution

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @Timsaur @rth

@adrinjalali adrinjalali merged commit 546c42d into scikit-learn:master Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants