【发布时间】:2016-08-20 13:18:33
【问题描述】:
我尝试调用最近邻的预测函数并得到以下错误:
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
如何进行预测?
【问题讨论】:
标签: python machine-learning scikit-learn