admin管理员组

文章数量:1123181

I have Windows 11 Home 24.2 Python 3.12.8 PyCharm Community Edition 2024.3 venv with pip 24.3.1 Numpy 2.2.1 Scikit-learn 1.6.0 Scipy 1.15.0 threadpoolctl 3.5.0 joblib 1.4.2

Python installation is fresh and new and other files run well (except other files that have the same problem made by KMeans). The error gets reproduced in other IDEs and in the cmd too. The venv is fresh new and minimal. The code is minimal.

import numpy as np
from sklearn.cluster import KMeans

X = np.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])
kmeans = KMeans(n_clusters=2, random_state=0, init='random')
kmeans.fit(X)

Note: The error doesn't always show! sometimes it runs fine sometimes it gives the error, about 50% maybe, very random.

I've tried many things already suggested on the internet that I've stumbled upon. Changing init doesn't work. I've tried installing old versions of these libraries compatible between each other and still the error persists. By using faulthandler I've understood that kmeans.fit(x) is the line of code that creates the error. Is it just a scikit-learn internal error that I can do nothing about?

本文标签: scikit learnsklearncluster KMeans creates a status heap memory corruption error 0xC0000374Stack Overflow