Search code examples
pythonscikit-learnjupyter-notebookanacondacluster-computing

cannot import name 'BisectingKMeans' from 'sklearn.cluster' (C:\Users\Administrator\anaconda3\lib\site-packages\sklearn\cluster\__init__.py)


When I try to use sklearn.cluster.BisectingKMeans in my jupyter notebook, an ImportError occured. It is said in the document that this method is new in version 1.1, and my scikit-learn version is 1.1.3. I was using the base environment so it's not an issue of lacking package in current environment. enter image description here

I've tried upgrade the scikit-learn package, but it doesn't help. Can anyone give me a hint of what is going on here? Thanks a lot!


Solution

  • This works on my machine:

    from sklearn.cluster import BisectingKMeans

    Also:

    import sklearn
    sklearn.__version__
    > 1.1.2
    

    Maybe you have a typo?