19
votes

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.

4

4 Answers

20
votes

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.

8
votes

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.

4
votes

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.

0
votes

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