Skip to content

[MRG] added example to class sklearn.decomposition.DictionaryLearning #12209

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

Closed
wants to merge 4 commits into from

Conversation

ThaliaBarrera
Copy link

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Added example to sklearn.decomposition.DictionaryLearning

Any other comments?

... [1.,0.,0.],
... [2.,2.,2.],
... [2.,5.,4.]])
>>> dico = DictionaryLearning(n_components=3, alpha=1, random_state=1)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use n_components=2 so the shape of the result is clear?

Copy link
Member

@amueller amueller left a comment

Choose a reason for hiding this comment

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

Looks good. Let's merge once the tests are green.

>>> import numpy as np
>>> from sklearn.decomposition import DictionaryLearning
>>> X = np.array([[0., 0., 1.],
... [1.,0.,0.],
Copy link
Member

Choose a reason for hiding this comment

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

Please indent to match first line ("visual indentation")

>>> V = dico.fit(X).components_
>>> V
array([[-0.2981424 , -0.74535599, -0.59628479],
[ 0.57735027, 0.57735027, 0.57735027]])
Copy link
Member

Choose a reason for hiding this comment

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

Using ellipsis (...) and limiting the examples to max 4 digits of floating point precision helps when we compile and test things in different platforms, not all our examples follow this though, example. You could also simplify the last two lines and just have dico.fit(X).components_, with probably a commend if you like.

@sergulaydore
Copy link
Contributor

Hello @ThaliaBarrera ,

Thank you for participating in the WiMLDS/scikit sprint. We would love to merge all the PRs that were submitted. It would be great if you could follow up on the work that you started! For the PR you submitted, would you please update and re-submit? Please include #wimlds in your PR conversation.

Any questions:

  • see workflow for reference
  • ask on this PR conversation or the issue tracker
  • ask on wimlds gitter with a reference to this PR

cc: @reshamas

@reshamas
Copy link
Member

Since there has been no response from @ThaliaBarrera after multiple attempts to contact her (via github and meetup email), I will complete this PR.

cc: @sergulaydore

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

Successfully merging this pull request may close these issues.

6 participants