当我评论knn.fit(x_tr,y_tr)下面的代码并运行时,它给出了一个错误NotFittedError: This KNeighborsClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this method.
knn = KNeighborsClassifier(n_neighbors=1)
print(knn)
# knn.fit(x_tr, y_tr)
# print(knn)
pred = knn.predict(x_cv)
acc = accuracy_score(y_cv, pred, normalize=True) * float(100)
我的断开连接是我没有保存knn.fit(...)在任何变量中,程序怎么知道我没有安装?
此外,当我在启动后和拟合后打印模型时......它完全相同
KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
metric_params=None, n_jobs=None, n_neighbors=1, p=2,
weights='uniform')
KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',
metric_params=None, n_jobs=None, n_neighbors=1, p=2,
weights='uniform')
LEATH
相关分类