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

Added info and links to mixture examples for the GaussianMixture and BayesianGaussianMixture classes #30420

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

janeBrusilovsky
Copy link

@janeBrusilovsky janeBrusilovsky commented Dec 6, 2024

Reference Issues/PRs

This PR contributes towards issue #26927: Add links to examples from the docstrings and user guides. https://github.com/scikit-learn/scikit-learn/issues/26927

What does this implement/fix? Explain your changes.

This PR adds information and example links to the class GaussianMixture in sklearn/mixture/_gaussian_mixture.py from:

  • examples/mixture/plot_gmm_init.py
  • examples/mixture/plot_gmm_selection.py
  • examples/mixture/plot_gmm_covariances.py

This PR also adds information and example links to the class BayesianGaussianMixture in sklearn/mixture/_bayesian_mixture.py from examples/mixture/plot_concentration_prior.py.

Any other comments?

Files modified:

  • sklearn/mixture/_gaussian_mixture.py
  • sklearn/mixture/_bayesian_mixture.py

Copy link

github-actions bot commented Dec 6, 2024

❌ Linting issues

This PR is introducing linting issues. Here's a summary of the issues. Note that you can avoid having linting issues by enabling pre-commit hooks. Instructions to enable them can be found here.

You can see the details of the linting issues under the lint job here


ruff

ruff detected issues. Please run ruff check --fix --output-format=full . locally, fix the remaining issues, and push the changes. Here you can see the detected issues. Note that the installed ruff version is ruff=0.5.1.


sklearn/mixture/_bayesian_mixture.py:92:80: W291 Trailing whitespace
   |
90 |     Read more in the :ref:`User Guide <bgmm>`.
91 | 
92 |     For a detailed example of how the weight_concentration_prior_type parameter 
   |                                                                                ^ W291
93 |     influences the model's behaviour, please refer to:
94 |     :ref:`sphx_glr_auto_examples_mixture_plot_concentration_prior.py`
   |
   = help: Remove trailing whitespace

sklearn/mixture/_gaussian_mixture.py:517:68: W291 Trailing whitespace
    |
515 |     Read more in the :ref:`User Guide <gmm>`.
516 | 
517 |     For a detailed example of how the init_params parameter impacts 
    |                                                                    ^ W291
518 |     the model's convergence behaviour, refer to:
519 |     :ref:`sphx_glr_auto_examples_mixture_plot_gmm_init.py`
    |
    = help: Remove trailing whitespace

sklearn/mixture/_gaussian_mixture.py:525:64: W291 Trailing whitespace
    |
523 |     :ref:`sphx_glr_auto_examples_mixture_plot_gmm_selection.py`
524 | 
525 |     For a detailed example of how the covariance_type parameter 
    |                                                                ^ W291
526 |     impacts the model's performance, refer to:
527 |     :ref:`sphx_glr_auto_examples_mixture_plot_gmm_covariances.py`
    |
    = help: Remove trailing whitespace

Found 3 errors.
No fixes available (3 hidden fixes can be enabled with the `--unsafe-fixes` option).

Generated for commit: f8cbdad. Link to the linter CI: here

Copy link
Contributor

@virchan virchan left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @janeBrusilovsky! I have a few suggestions.

Comment on lines 92 to 93
For examples on how to implement the class model, please refer to:
:ref:`sphx_glr_auto_examples_mixture_plot_concentration_prior.py`
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to phrase it as:

"For a detailed example of how the weight_concentration_prior_type parameter influences the model's behaviour, see <example_link>."

Comment on lines 517 to 518
For examples on different methods of initialization, refer to:
:ref:`sphx_glr_auto_examples_mixture_plot_gmm_init.py`
Copy link
Contributor

Choose a reason for hiding this comment

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

"For a detailed example of how the init_params parameter impacts the model's convergence behaviour, see <example_link>."

Comment on lines 520 to 521
For examples on model selection with Gassian Mixture, refer to:
:ref:`sphx_glr_auto_examples_mixture_plot_gmm_selection.py`
Copy link
Contributor

Choose a reason for hiding this comment

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

"For a detailed example of how the n_components and covariance_type parameters influence the model's performance, see <example_link>."

Comment on lines 523 to 524
For example covariances types for Gaussian mixture models, see:
:ref:`sphx_glr_auto_examples_mixture_plot_gmm_covariances.py`
Copy link
Contributor

Choose a reason for hiding this comment

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

"For a detailed example of how the covariance_type parameter impacts the model's performance, see <example_link>."

@janeBrusilovsky
Copy link
Author

I've updated the wording to match the suggestions. Thanks for the feedback!

@StefanieSenger
Copy link
Contributor

Hi, @janeBrusilovsky!

Now you have to fix the linting issue.

Have you installed pre-commit, as recommended in the developer guide? It helps with issues like this one.

pip install pre-commit
pre-commit install

Copy link
Contributor

@virchan virchan left a comment

Choose a reason for hiding this comment

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

Thank you for the updates, @janeBrusilovsky! In addition to @StefanieSenger's comment, you can click on details under ci/circleci: lint in the code checks to view the error messages.

@@ -89,6 +89,10 @@ class BayesianGaussianMixture(BaseMixture):

Read more in the :ref:`User Guide <bgmm>`.

For a detailed example of how the weight_concentration_prior_type parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For a detailed example of how the weight_concentration_prior_type parameter
For a detailed example of how the `weight_concentration_prior_type` parameter

@@ -514,6 +514,18 @@ class GaussianMixture(BaseMixture):

Read more in the :ref:`User Guide <gmm>`.

For a detailed example of how the init_params parameter impacts
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For a detailed example of how the init_params parameter impacts
For a detailed example of how the `init_params` parameter impacts

Comment on lines +521 to +522
For a detailed example of how the n_components and covariance_type
parameters influence the model's performance, refer to:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For a detailed example of how the n_components and covariance_type
parameters influence the model's performance, refer to:
For a detailed example of how the `n_components` and `covariance_type`
parameters influence the model's performance, refer to:

parameters influence the model's performance, refer to:
:ref:`sphx_glr_auto_examples_mixture_plot_gmm_selection.py`

For a detailed example of how the covariance_type parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For a detailed example of how the covariance_type parameter
For a detailed example of how the `covariance_type` parameter

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.

3 participants