我试图调用最近邻居的预测函数并得到以下错误:
AttributeError: 'NearestNeighbors' object has no attribute 'predict'
Run Code Online (Sandbox Code Playgroud)
代码是:
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
Run Code Online (Sandbox Code Playgroud)
我已经阅读了文档,它有预测功能:http: //scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html
怎么做预测?