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.

KMeans fit TypeError expected dtype object, got 'numpy.dtype[float64]'

See original GitHub issue

What happened: when fit X, get error:

TypeError                                 Traceback (most recent call last)
<ipython-input-11-7d3bc4c475f7> in <module>
      1 km = dask_ml.cluster.KMeans(n_clusters=3, init_max_iter=2, oversampling_factor=10)
----> 2 km.fit(X)
 ...
 ...
 TypeError: expected dtype object, got 'numpy.dtype[float64]'

What you expected to happen: output: KMeans(init_max_iter=2, n_clusters=3, oversamplinh_factor=10)

Minimal Complete Verifiable Example:

import dask_ml.cluster

X, y = dask_ml.datasets.make_blobs(n_samples=1000000,
                                   chunks=100000,
                                   random_state=0,
                                   centers=3)
km = dask_ml.cluster.KMeans(n_clusters=3, init_max_iter=2, oversampling_factor=10)
km.fit(X)

Environment:

  • Dask version: dask_ml 1.8.0, dask 2021.02.0
  • Python version: 3.7
  • Operating System: MacOS Catalina 10.15.5
  • Install method (conda, pip, source): conda
  • Other packages: numpy 1.20.1, pandas 1.2.2

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
hristogcommented, Mar 21, 2021

Thanks for the further info provided, @Mimran0715!

I confirm I’ve been able to reproduce the issue locally, using the following versions:

As suggested in my comment above, this was resolved via upgrading numba to the latest available version. I just did python3 -m pip install numba==0.53.0, and this has enabled me to run the K-Means|| example.

Please, have a go at upgrading the numba version (you might need to update llvmlite to something compatible as well, e.g., 0.32.1; if you do, please, take a note of your current version of llvmlite, so that you can always revert back later on, if needs be). If you don’t want to globally affect your local versions, you can test with an updated version of numba via venv or via a Docker container.

Thanks!

1reaction
Mimran0715commented, Mar 21, 2021

Thanks for responding. I’m just trying to run the K-means cluster example here: https://examples.dask.org/machine-learning/training-on-large-datasets.html Here is the Traceback: Screen Shot 2021-03-20 at 7 25 19 PM Here are some details abt the package versions: Screen Shot 2021-03-20 at 7 26 49 PM

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expected dtype object, got 'numpy.dtype[float64]' - MNE Forum
I've been encountering the same issue. I am having the same issue with all my GDF files. I also tried updating numpy to...
Read more >
TypeError: expected dtype object, got 'numpy.dtype[int64]'
After that when I run my code I obtain the following error: TypeError: expected dtype object, got 'numpy.dtype[int64]'. How do I fix that?...
Read more >
Input contains infinity or a value too large for dtype('float64').
One common error you may encounter when using Python is: ValueError: Input contains infinity or a value too large for dtype('float64').
Read more >
In Depth: k-Means Clustering | Python Data Science Handbook
The k-means algorithm searches for a pre-determined number of clusters ... from sklearn.cluster import KMeans kmeans = KMeans(n_clusters=4) kmeans.fit(X) ...
Read more >
tslearn.clustering.TimeSeriesKMeans - Read the Docs
K-means clustering for time-series data. Parameters: n_clusters : int (default: 3). Number of clusters to ...
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