Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
closes #35583
What does this implement/fix? Explain your changes.
fitvalidatesXwithdtype=[xp.float64, xp.float32], butscore_samples,predictandpredict_probacallvalidate_data(self, X, reset=False)without adtype, so integer
Xstays integer. Withcovariance_type="full",_estimate_log_gaussian_proballocateslog_probwithdtype=X.dtype, so thesquared Mahalanobis distances are truncated to integers. This gives wrong
score_samples,scoreandbic/aic, and can changepredictandpredict_proba.On
main:With this PR(1.10.dev0)

The fix passes the same
dtypetovalidate_datain the three inferencemethods, so inference converts
Xthe same wayfitdoes.scoregoes throughscore_samples, andBayesianGaussianMixturesharesBaseMixture, so both arecovered. Fixing the validation step, rather than the allocation in
_estimate_log_gaussian_prob, fixes the root cause: inference should see thesame input dtype as
fit.Float input is unchanged: float32 and float64 pass through as before.
The new test in
test_mixture.pychecks that both estimators, with all fourcovariance types, give the same
score_samples,predict_probaandpredictfor integer
Xand the same data as float64. Without the fix, the two"full"cases fail.
Introduce yourself
Hello, I am Unique. I use scikit-learn to build machine learning systems and quickly experiment with my ideas. I have contributed to scikit-learn before (#33117, #33118), and I fixed this too..
AI usage disclosure
I used AI assistance for:
Any other comments?