question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import dask_ml.cluster raises a ModuleNotFoundError from sklearn

See original GitHub issue
$ pip install dask-ml
$ python
>>> import dask_ml.cluster
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/peter/.virtualenvs/DASK/lib/python3.7/site-packages/dask_ml/cluster/__init__.py", line 3, in <module>
    from .k_means import KMeans  # noqa
  File "/Users/peter/.virtualenvs/DASK/lib/python3.7/site-packages/dask_ml/cluster/k_means.py", line 23, in <module>
    from ._compat import _k_init
  File "/Users/peter/.virtualenvs/DASK/lib/python3.7/site-packages/dask_ml/cluster/_compat.py", line 4, in <module>
    from sklearn.cluster._k_means import _k_init
ModuleNotFoundError: No module named 'sklearn.cluster._k_means'
>>>

It looks like this issue is related to the latest version of scikit-learn deprecating that module, because installing with the previous version of scikit-learn works.

$ pip install dask-ml==1.1.1 scikit-learn==0.21.*
$ python
>>> import dask_ml.cluster
>>>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TomAugspurgercommented, Jan 6, 2020

Looking into this now.

0reactions
gustavomrgcommented, Apr 24, 2021
<ipython-input-48-d46ea042c026> in <module>
     12 import umap.plot
     13 import matplotlib.pyplot as plt
---> 14 import dask_ml.cluster

/project/libs/lib/python3.6/site-packages/dask_ml/cluster/__init__.py in <module>
      1 """Unsupervised Clustering Algorithms"""
      2 
----> 3 from .k_means import KMeans  # noqa
      4 from .spectral import SpectralClustering  # noqa

/project/libs/lib/python3.6/site-packages/dask_ml/cluster/k_means.py in <module>
     20 )
     21 from ..utils import _timed, _timer, check_array, row_norms
---> 22 from ._compat import _k_init
     23 
     24 import numba  # isort:skip (see https://github.com/dask/dask-ml/pull/577)

/project/libs/lib/python3.6/site-packages/dask_ml/cluster/_compat.py in <module>
----> 1 from sklearn.cluster._kmeans import _k_init
      2 
      3 __all__ = ["_k_init"]

ImportError: cannot import name '_k_init'

I am using python 3.6, dask-ml-1.7.0 and scikit-learn-0.23.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dask - import dask_ml.cluster - ModuleNotFoundError: No ...
Dask - import dask_ml.cluster - ModuleNotFoundError: No module named 'sklearn.cluster._k_means' ... This seems really strange. Has anyone ...
Read more >
Fix ModuleNotFoundError: No module named 'sklearn'
How to Fix ModuleNotFoundError: No module named 'sklearn' in Python. Installing and importing scikit-learn sklearn package in Python, Jupyter and anaconda.
Read more >
Topics tagged distributed - Dask Forum - Discourse
How to properly extract features of a large array on cluster? ... to decorate or import functions: pickle.loads raises AttributeError or ModuleNotFoundError.
Read more >
Hyper Parameter Search — dask-ml 2022.5.28 documentation
Tools to perform hyperparameter optimization of Scikit-Learn API-compatible ... Distribute grid-search across a cluster from dask.distributed import Client ...
Read more >
DASK | Handling Big Datasets For Machine Learning Using ...
This article includes Dask Array, Dask Dataframe and Dask ML. ... import dask_ml.joblib from sklearn.externals.joblib import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found