3
我試着打電話給預測近鄰的功能,得到了以下錯誤功能:呼叫預測與Python scikit sklearn近鄰(KNN)分類
AttributeError: 'NearestNeighbors' object has no attribute 'predict'
的代碼是:
from sklearn.neighbors import NearestNeighbors
samples = [[0., 0., 0.], [0., .5, 0.], [1., 1., .5]]
neigh = NearestNeighbors()
neigh.fit(samples)
neigh.predict([[1., 1., 1.]]) # this cause error
我讀過文檔,它有預測功能: http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html
如何做預測?