微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 python (ModuleNotFoundError) 的 scikit-learn 0.24 版运行“spherecluster”包?

如何解决如何使用 python (ModuleNotFoundError) 的 scikit-learn 0.24 版运行“spherecluster”包?

我需要从 https://github.com/jasonlaska/spherecluster 导入模块“spherecluster”。 (蟒蛇/pipy) 但它不适用于最新版本的 scikit-learn 包版本 > 0.24 。

我收到以下错误

ModuleNotFoundError: No module named 'sklearn.cluster.k_means_'

我发现 k_means_ 在以后的版本中被重命名了。 (代码结构改变)

如何解决这个问题?

我是否需要完全重写 spherecluster 中的代码才能在当前 sklearn 版本上运行?

解决方法

This is an open issue on the package,从作者缺乏回应来看,似乎被忽视了。继续打扰他们并表达您对公关的支持。

否则,正确的解决方案是限制 Conda 环境仅使用兼容版本的 scikit-learn。

## create a new env with the constraint
conda create -n spherecluster python=3.7 pip scikit-learn=0.22

## activate it
conda activate spherecluster

## install the package from 
pip install spherecluster

不太合适的解决方案是从 PR 分支安装 spherecluster 包:

conda activate your_env
pip install git+https://github.com/rfayat/spherecluster.git@scikit_update

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。