问题
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information.
import sklearn
sklearn.__version__
'0.16.1'
from sklearn.neighbors import NearestNeighbors
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/neighbors/__init__.py", line 9, in <module>
from .graph import kneighbors_graph, radius_neighbors_graph File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/neighbors/graph.py", line 9, in <module>
from .base import KNeighborsMixin, RadiusNeighborsMixin File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/neighbors/base.py", line 18, in <module>
from ..metrics import pairwise_distances File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/metrics/__init__.py", line 15, in <module>
from .classification import accuracy_score File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/metrics/classification.py", line 31, in <module>
from ..preprocessing import LabelBinarizer, label_binarize File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/preprocessing/__init__.py", line 25, in <module>
from ._weights import balance_weights ImportError: cannot import name 'balance_weights'
来源:https://stackoverflow.com/questions/30124375/cant-import-nearest-neighbors-in-scikit-learn-0-16