Skip to content

Conversation

@Valavanca
Copy link
Contributor

@Valavanca Valavanca commented Feb 11, 2022

Reference Issues/PRs

What does this implement/fix? Explain your changes.

  • fix notebook-style and add more descriptions
  • small refactoring for the plot function

Any other comments?


for name, estimator, center in estimators:
print("Extracting the top %d %s..." % (n_components, name))
print("- Extracting the top %d '%s'..." % (n_components, name))
Copy link
Member

Choose a reason for hiding this comment

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

I propose to break this for loop and instead create a cell where:

  • we define the model
  • and plot the gallery

It will have the benefit to remove the if/else for switching the behaviour depending of the estimator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the idea. Done in 43d4a5b.

# #############################################################################
# Various positivity constraints applied to dictionary learning.
estimators = [
dict_estimators = [
Copy link
Member

Choose a reason for hiding this comment

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

Could you as well break the for loop into three different cells?

Copy link
Contributor Author

@Valavanca Valavanca Feb 13, 2022

Choose a reason for hiding this comment

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

Also done in 43d4a5b.

@Valavanca
Copy link
Contributor Author

Due to the changed order of generated images, it was also necessary to change the links to the images in the decomposition documentation.

@Valavanca Valavanca requested a review from glemaitre February 14, 2022 13:11
# subcomponents that are maximally independent.

# %%
ica_estimator = decomposition.FastICA(n_components=n_components, whiten=True)
Copy link
Member

Choose a reason for hiding this comment

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

We can remove the FutureWarning.

Suggested change
ica_estimator = decomposition.FastICA(n_components=n_components, whiten=True)
ica_estimator = decomposition.FastICA(
n_components=n_components, whiten='arbitrary-variance'
)

Regarding the ConvergenceWarning, could you increase the number of iterations (or maybe increase the tolerance) such that we don't get this warning anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. increased max_iter and tol

Comment on lines 141 to 142
# Sparse comp. - MiniBatchSparsePCA
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
# Sparse comp. - MiniBatchSparsePCA
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Sparse components - MiniBatchSparsePCA
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


# %%
# Independent components - FastICA
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed all similar problems


# %%
# Non-negative components - NMF
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


# %%
# Eigenfaces - PCA using randomized SVD
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Comment on lines 251 to 252
# Dictionary learning - positive dictionary
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
# Dictionary learning - positive dictionary
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Dictionary learning - positive dictionary
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Comment on lines 272 to 273
# Dictionary learning - positive code
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
# Dictionary learning - positive code
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Dictionary learning - positive code
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Comment on lines 294 to 295
# Dictionary learning - positive dictionary & code
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
# Dictionary learning - positive dictionary & code
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Dictionary learning - positive dictionary & code
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#

# %%
Copy link
Member

Choose a reason for hiding this comment

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

In this section and the subsequent ones, it could be cool to add a small summary of what constraint we imposed in the model and how it translates into the components. No need to add long discussion but this is currently slightly rough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a bit of a description to the dictionary learning cells. But there is a slight nuance that I didn't find a comprehensive explanation of code in the documentation. But as far as I understand it is coding coefficients from sparse coding. Added so for now.

n_components=n_components, svd_solver="randomized", whiten=True
)
pca_estimator.fit(faces_centered)
plot_gallery(
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should probably plot a colorbar with the min/max values.
Without it, I find it complex to grasp that a lot of components are zeros in SparsePCA for instance. I could have the same comment with only positive components.

So the colorbar could solve those ambuiguities.

Copy link
Contributor Author

@Valavanca Valavanca Feb 20, 2022

Choose a reason for hiding this comment

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

Added colorbar, now plots look more informative.

@lesteve lesteve mentioned this pull request Feb 15, 2022
47 tasks
@lesteve
Copy link
Member

lesteve commented Feb 15, 2022

Due to the changed order of generated images, it was also necessary to change the links to the images in the decomposition documentation.

Oh wow, good catch @Valavanca! This is quite easy to overlook and definitely something to keep in mind for other PRs on this issue.

@lesteve lesteve added the Quick Review For PRs that are quick to review label Feb 22, 2022
@glemaitre glemaitre merged commit 2577dc9 into scikit-learn:main Mar 2, 2022
@glemaitre
Copy link
Member

Thanks @Valavanca The example is much nicer now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Quick Review For PRs that are quick to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants