generated from LufsX/Experiment-kNN
This commit is contained in:
+1
-2
@@ -30,7 +30,6 @@ def classify(input_vector, dataSet, labels, k=3):
|
||||
# 返回投票最多的标签
|
||||
return max(label_count, key=label_count.get)
|
||||
|
||||
|
||||
def load_data(directory):
|
||||
"""
|
||||
加载手写数字数据集.
|
||||
@@ -55,7 +54,6 @@ def load_data(directory):
|
||||
|
||||
return dataset, np.array(labels)
|
||||
|
||||
|
||||
def img_to_vector(filename):
|
||||
"""
|
||||
将32x32的二值图像转换为1x1024向量.
|
||||
@@ -120,3 +118,4 @@ if __name__ == "__main__":
|
||||
train_data, train_labels)
|
||||
|
||||
print(f"预测的标签: {predicted_label}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user