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

FIX do not report wrong iteration number when initialization of EM does not converge #26837

Merged
merged 9 commits into from Mar 11, 2024

Conversation

krstopro
Copy link
Contributor

@krstopro krstopro commented Jul 14, 2023

Fixes #26621

When the EM best iteration does not converge, a warning message is raised, indicating a wrong iteration number. As discussed in #26621, we don't need to indicate the number but rather mention that the convergence did not happen.

@github-actions
Copy link

github-actions bot commented Jul 14, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

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

@betatim
Copy link
Member

betatim commented Jul 17, 2023

Hi @krstopro, thanks for opening the Pull Request. Could you please add a short section to your description that explains "What does this implement/fix?" as well as explaining your changes. The title also needs improving to be more descriptive.

All this helps people know what the PR is about, what needs doing, etc which will reduce the time it takes for things to get reviewed and merged.

@glemaitre glemaitre self-requested a review November 3, 2023 11:03
@glemaitre glemaitre changed the title Bug fix. FIX show number of the best iteration when EM does not converge Nov 3, 2023
@glemaitre glemaitre changed the title FIX show number of the best iteration when EM does not converge FIX show the index of the best initialization when EM does not converge Nov 3, 2023
"""Print verbose message on the end of iteration."""
if self.verbose == 1:
print("Initialization converged: %s" % self.converged_)
print("Initialization converged: %s" % converged)
Copy link
Member

Choose a reason for hiding this comment

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

The message will look weird because we will get: "Initialization converged: False"
It would be better to report that the convergence did not happen using a proper English sentence based on converged.

Also I would prefer init_has_converged instead of converged

Copy link
Member

Choose a reason for hiding this comment

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

However, we can mention that the "Initialization ended".

Copy link
Member

Choose a reason for hiding this comment

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

We should not have strong test regarding the verbosing. It would make sense to strengthen test_gaussian_mixture_verbose.

sklearn/mixture/_base.py Outdated Show resolved Hide resolved
@glemaitre glemaitre changed the title FIX show the index of the best initialization when EM does not converge FIX do not report wrong iteration number when initialization of EM does not converge Nov 3, 2023
@glemaitre
Copy link
Member

I am going to add the stalled label since I don't see activity after @betatim message.
@krstopro if you wish to pursue this PR, I will remove the tag and I'll be happy to give follow-up review to have this PR merged.

@glemaitre
Copy link
Member

We also need a what's new entry in 1.4 to acknowledge that the error message is fixed.

Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

I pushed the requested changes and fixed the doc of the converged_ attribute.

LGTM on my side.

@glemaitre wanna have another look ?

@jeremiedbb jeremiedbb added this to the 1.4.2 milestone Mar 7, 2024
@jeremiedbb jeremiedbb added To backport PR merged in master that need a backport to a release branch defined based on the milestone. and removed Stalled labels Mar 7, 2024
@glemaitre
Copy link
Member

@jeremiedbb I'll have a new look. Thanks

Copy link
Member

@glemaitre glemaitre 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 @jeremiedbb and @krstopro

@glemaitre glemaitre merged commit 9d85052 into scikit-learn:main Mar 11, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:mixture To backport PR merged in master that need a backport to a release branch defined based on the milestone.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reporting that the EM algorithm didn't converge for a single initialization
4 participants