在 sklearn 中导入 svm 时“无法导入名称 check_arrays”



Sklearn 在导入 sklearn.svm 时抛出错误"无法导入名称check_arrays"。

我已经搜索了这个问题,另一个问题表明check_arrays已被check_array取代。似乎旧check_arrays被一些称为表单 svm 的代码使用,这是 sklearn.svm 模块中的错误吗?

刚刚更新到版本 0.17.1。

Traceback:
File ".../main.py", line 4, in <module>
  import sklearn.svm as svm
File "/usr/local/lib/python2.7/dist-packages/sklearn/svm/__init__.py", line 13, in <module>
  from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC, 
File "/usr/local/lib/python2.7/dist-packages/sklearn/svm/classes.py", line 4, in <module>
  from .base import _fit_liblinear, BaseSVC, BaseLibSVM
File "/usr/local/lib/python2.7/dist-packages/sklearn/svm/base.py", line 12, in <module>
  from ..multiclass import _ovr_decision_function
File "/usr/local/lib/python2.7/dist-packages/sklearn/multiclass.py", line 44, in <module>
  from .metrics.pairwise import euclidean_distances
File "/usr/local/lib/python2.7/dist-packages/sklearn/metrics/__init__.py", line 33, in <module>
  from . import cluster
File "/usr/local/lib/python2.7/dist-packages/sklearn/metrics/cluster/__init__.py", line 21, in <module>
  from .bicluster import consensus_score
File "/usr/local/lib/python2.7/dist-packages/sklearn/metrics/cluster/bicluster/__init__.py", line 1, in <module>
  from .bicluster_metrics import consensus_score
File "/usr/local/lib/python2.7/dist-packages/sklearn/metrics/cluster/bicluster/bicluster_metrics.py", line 6, in <module>
  from sklearn.utils.validation import check_arrays
ImportError: cannot import name check_arrays
好的,

所以问题解决了。Sklearn 0.17.1 没有目录 bicluster,bicluster_metrics.py 而是在 sklearn/metrics/cluster 中 (https://github.com/scikit-learn/scikit-learn/tree/0.17.1/sklearn/metrics/cluster)。

那只是一个不干净的安装。希望这对某人有所帮助!

相关内容

  • 没有找到相关文章

最新更新