KMeans fit TypeError expected dtype object, got 'numpy.dtype[float64]'
See original GitHub issueWhat 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:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 didpython3 -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 updatellvmlite
to something compatible as well, e.g.,0.32.1
; if you do, please, take a note of your current version ofllvmlite
, 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 ofnumba
via venv or via a Docker container.Thanks!
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: Here are some details abt the package versions: