Using Sklearn for Data Science tasks

I am not able to run scikit-learn in

What am I doing wrongly?

During handling of the above exception, another exception occurred:

The errors are related to scikit instalation

Traceback (most recent call last):
File “”, line 1, in
from sklearn.cluster import kmeans_plusplus
File “/home/runner/Lets-Scikit-Learnear/venv/lib/python3.10/site-packages/sklearn/”, line 81, in
from . import __check_build # noqa: F401
File “/home/runner/Lets-Scikit-Learnear/venv/lib/python3.10/site-packages/sklearn/__check_build/”, line 50, in
File “/home/runner/Lets-Scikit-Learnear/venv/lib/python3.10/site-packages/sklearn/__check_build/”, line 31, in raise_build_error
raise ImportError(
ImportError: No module named ‘sklearn.__check_build._check_build’

Contents of /home/runner/Lets-Scikit-Learnear/venv/lib/python3.10/site-packages/sklearn/_check_build:
pycache check_build.cpython-310-x86_64-linux-gnu.so__init

It seems that scikit-learn has not been built correctly.

Repl link:

from sklearn.cluster import kmeans_plusplus
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt

# Generate sample data
n_samples = 4000
n_components = 4

X, y_true = make_blobs(
    n_samples=n_samples, centers=n_components, cluster_std=0.60, random_state=0
X = X[:, ::-1]

# Calculate seeds from kmeans++
centers_init, indices = kmeans_plusplus(X, n_clusters=4, random_state=0)

# Plot init seeds along side sample data
colors = ["#4EACC5", "#FF9C34", "#4E9A06", "m"]

for k, col in enumerate(colors):
    cluster_data = y_true == k
    plt.scatter(X[cluster_data, 0], X[cluster_data, 1], c=col, marker=".", s=10)

plt.scatter(centers_init[:, 0], centers_init[:, 1], c="b", s=50)
plt.title("K-Means++ Initialization")
1 Like

Thanks for getting in touch @fferreira !

I’ve been able to recreate the issue here Scikit-learnTest - Replit and have logged this with support. I’ll update you when I receive feedback.

Hi again @fferreira

Thanks again for your message. We managed to work out what was causing the error behind the scenes. I’ve managed to downgrade your repl from Python 3.10 to Python 3.8 and it appears to now be working.

Hope this helps!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.