【发布时间】:2020-12-31 15:31:07
【问题描述】:
我从一个包含一些分类参数的数据集中创建了一个 excel。然后,我创建了一个测试数据集,并对这些数据进行了分类。现在,我对所有测试数据都有预测,但我如何才能找到这些预测的准确性?
df = pd.read_excel(r"excellocation")
df_model = df.copy()
scaler = StandardScaler()
features = [[feature1,feature2......]]
for feature in features:
df_model[feature] = scaler.fit_transform(df_model[feature])
knn = KNeighborsClassifier()
x = df_model.drop(columns=['class'],1)
y = df_model['class']
knn.fit(x, y)
clf= neighbors.KNeighborsClassifier()
clf.fit(x,y)
for example in test_data:
prediction = clf.predict(example)
#####i need accuracy of this prediction
【问题讨论】:
标签: python classification prediction knn