20

I'm trying to use a svm function from the scikit learn package for python but I get the error message:

from sklearn.utils.validation import check_arrays

ImportError: cannot import name 'check_arrays'

I'm using python 3.4. Can anyone give me an advice? Thanks in advance.

Kjuly
  • 34,476
  • 22
  • 104
  • 118
rado
  • 401
  • 3
  • 8
  • 16

4 Answers4

20

This method was removed in 0.16, replaced by a (very different) check_array function. You are likely getting this error because you didn't upgrade from 0.15 to 0.16 properly. [Or because you relied on a not-really-public function in sklearn]. See http://scikit-learn.org/dev/install.html#canopy-and-anaconda-for-all-supported-platforms . If you installed using anaconda / conda, you should use the conda mechanism to upgrade, not pip. Otherwise old .pyc files might remain in your folder.

Andreas Mueller
  • 27,470
  • 8
  • 62
  • 74
8

It seems like "check_arrays" doesn't exist (anymore). I fixed it with:

sudo vi /usr/lib64/python2.7/site-packages/sklearn/metrics/cluster/bicluster/bicluster_metrics.py

change this: from sklearn.utils.validation import check_arrays to: from sklearn.utils.validation import check_array as check_arrays

Kind of a hack, but it works for me.

Bernard
  • 81
  • 2
4

For me...

This worked:

from sklearn.utils import check_array

Also this:

from sklearn.utils.validation import check_array

I am using version 0.16.0

>>> sklearn.__version__

'0.16.0'

Do this:

import sklearn

print sklearn.__version__

Tell us the results.

jgritty
  • 11,660
  • 3
  • 38
  • 60
0

You should change check_arrays to check_array.
Source: https://github.com/scikit-learn/scikit-learn/issues/4624

Luigi Neri
  • 36
  • 5