Skip to content

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

Closed

Description

@Maia97

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

Activity

  1. TomAugspurger commented on Mar 14, 2021

    @TomAugspurger
    Member

    Can you search on the Dask / distributed issue trackers for similar issues? I vaguely recall similar issues but can't find them right now.

  2. Mimran0715 commented on Mar 20, 2021

    @Mimran0715

    I'm also having a similar issue. I think #803 is closed but not sure how to get rid of TypeError.

  3. hristog commented on Mar 21, 2021

    @hristog
    Contributor

    Hi @Maia97,

    I think the series of issues (and PRs) that @TomAugspurger has referred to is as follows:

    I've tried a few combinations of different versions of dask, numpy and numba, but on Python 3.8 (and Linux), and I haven't been able to reproduce the issue.

    Could you, please, try to update to the latest version of numba and then attempt to run your example again?
    If this doesn't help, could you provide the version numbers for distributed and numba, and also the entire Traceback, please?

    I think this issue can be labeled with "Needs Info" in the meantime.

  4. hristog commented on Mar 21, 2021

    @hristog
    Contributor

    Hi @Mimran0715,

    I wrote in #803 that it might be possibly related to #802, but having discovered the aforementioned series of issues, I believe that #802 and #803 are unrelated.

    If you could, please, provide some info about the underlying package versions in your environment and a Traceback, it would be greatly appreciated, and help discover the root cause sooner.

    Thanks!

  5. Mimran0715 commented on Mar 21, 2021

    @Mimran0715

    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

  6. hristog commented on Mar 21, 2021

    @hristog
    Contributor

    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!

  7. added a commit that references this issue on Mar 21, 2021
  8. added a commit that references this issue on Mar 22, 2021
  9. jrbourbeau commented on Mar 22, 2021

    @jrbourbeau
    Member

    Should be closed by #809. @Maia97 feel free to re-open if that's not the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions