Repository navigation
Description
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 would like to report and fix this too..
Describe the bug and give evidence about its user-facing impact
I ran the same GaussianMixture code on Google Colab (1.6.1) and on my local machine (1.9.1, latest) and got different results for integer data, with no warnings.
on colab
on my local machine
on pip version(1.9.1)
The float results are the same in all three. Only the integer results changed.
I found that fit converts X to float, but score_samples, predict and predict_proba don't. For covariance_type= "full", _estimate_log_gaussian_prob then does:
log_prob = xp.empty((n_samples, n_components), dtype=X.dtype, device=device)with int64 X this is an integer array so, the squared distances written into it are truncated. dtype= X.dtype was added in #30415. This is not an int overflow.
using AI assistance I also ran these checks
- 1.5.2 and 1.6.1 are correct; 1.7.2, 1.8.0, 1.9.1 and main are not, so it
looks like a regression. - On 200 random integer datasets (on main),
predictgave different labels for
int and float X in 46, and BIC picked a different number of components
(1 to 4) in 18. So it can change the model a user chooses. BayesianGaussianMixtureis affected too.
using the same dtype in those three validate_data calls as in fit should fix it. I would like to open a PR if u agree.
Steps/Code to Reproduce
import numpy as np
import sklearn
from sklearn.mixture import GaussianMixture
rng = np.random.RandomState(0)
X = np.r_[rng.randint(0, 8, (40, 2)), rng.randint(5, 14, (40, 2))]
m = GaussianMixture(n_components=2, random_state=0).fit(X)
print(m.bic(X), m.bic(X.astype(float)))
print(m.score(X), m.score(X.astype(float)))
print(sklearn.__version__)Expected Results
Integer and float X give the same values:
872.5069400975487 872.5069400975487
-5.151904044475851 -5.151904044475851
Actual Results
839.0390007466375 872.5069400975487
-4.942729423532655 -5.151904044475851
1.9.1
Versions
System:
python: 3.12.14 (main, Sep 24 2026, 17:57:43) [Clang 22.1.3 ]
executable: ~/Desktop/gmm_bug/.venv/bin/python
machine: Linux-7.0.0-44-generic-x86_64-with-glibc2.43
Python dependencies:
sklearn: 1.9.1
pip: None
setuptools: None
numpy: 2.5.5
scipy: 1.18.1
Cython: None
pandas: None
matplotlib: None
joblib: 1.6.0
threadpoolctl: 3.8.0
narwhals: 2.30.0
Built with OpenMP: True
threadpoolctl info:
user_api: blas
internal_api: openblas
num_threads: 12
prefix: libscipy_openblas
filepath: ~/Desktop/gmm_bug/.venv/lib/python3.12/site-packages/scipy.libs/libscipy_openblas-5f890258.so
version: 0.3.31.dev
threading_layer: pthreads
architecture: Haswell
user_api: blas
internal_api: openblas
num_threads: 12
prefix: libscipy_openblas
filepath: ~/Desktop/gmm_bug/.venv/lib/python3.12/site-packages/numpy.libs/libscipy_openblas64_-4b78795a.so
version: 0.3.34.237.2
threading_layer: pthreads
architecture: Haswell
user_api: openmp
internal_api: openmp
num_threads: 12
prefix: libgomp
filepath: ~/Desktop/gmm_bug/.venv/lib/python3.12/site-packages/scikit_learn.libs/libgomp-e985bcbb.so.1.0.0
version: NoneInterest in fixing the bug
Yes, I would like to work on a PR once this is triaged
Possible fix: pass the same dtype to those three validate_data calls in
sklearn/mixture/_base.py. float32 input would stay float32, so the change from
#30415 is kept. I would also add a non-regression test comparing int and float X
for all covariance types, for score_samples, predict and predict_proba.
I will not open a PR before the issue is triaged:)

Activity
RjyavardhanSingh commentedon Dec 2, 2026
Hi, I'd like to work on this. Could you assign it to me? I'll open a PR soon.
ogrisel commentedon Dec 2, 2026
@RjyavardhanSingh the original reporter already expressed interest in contributing a fix so please do not attempt to open a PR.
ogrisel commentedon Dec 2, 2026
@un1u3 I confirm the bug and your analysis of the root cause seems valid. Please open a PR.