【问题标题】:Problems using spherecluster package for spherical k-mean clustering使用 spherecluster 包进行球形 k 均值聚类的问题
【发布时间】:2022-08-10 05:11:45
【问题描述】:

我正在处理来自不同方向的加速度计的数据。数据位于球体表面。我希望使用球形 k 均值聚类来识别表面上的聚类。

我从 Jason Laska 安装了包 spherecluster。我能够在我的 Anaconda 环境(基础和虚拟环境)中安装该软件包而没有任何问题。但是在尝试导入 spherecluster 模块时,出现以下错误。

(base) ➜  unsupervised_learning: python
Python 3.9.12 (main, Apr  5 2022, 01:52:34)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.
>>> import spherecluster
Traceback (most recent call last):
  File \"<stdin>\", line 1, in <module>
  File \"/Users/username/anaconda3/lib/python3.9/site-packages/spherecluster/__init__.py\", line 2, in <module>
    from .spherical_kmeans import SphericalKMeans
  File \"/Users/username/anaconda3/lib/python3.9/site-packages/spherecluster/spherical_kmeans.py\", line 7, in <module>
    from sklearn.cluster.k_means_ import (
ModuleNotFoundError: No module named \'sklearn.cluster.k_means_\'
>>>

我根据模块的要求安装了 numpy 和 scipy。我找不到 sklearn.cluster.k_means_ 以下是我的 numpy、scipy 和 scikit-learn 版本

numpy                     1.21.5           py39h25ab29e_1
numpy-base                1.21.5           py39h974a1f5_1
scikit-learn              1.0.2            py39h9197a36_1
scipy                     1.7.3            py39h2f0f56f_0

我究竟做错了什么?

    标签: python machine-learning scikit-learn unsupervised-learning


    【解决方案1】:

    我有同样的问题,不得不手动编辑球形kmeans.py文件。我改变了这个:

    from sklearn.cluster import _k_means_fast as _k_means
    

    为了这:

    from sklearn.cluster import _k_means_common as _k_means
    

    它对我有用。

    【讨论】:

      猜你喜欢
      • 2019-06-18
      • 2014-09-17
      • 2016-03-10
      • 2017-12-09
      • 2017-03-07
      • 2019-09-25
      • 1970-01-01
      • 2017-11-30
      相关资源
      最近更新 更多