generated from LufsX/Experiment-kNN
This commit is contained in:
+2
-2
@@ -70,7 +70,7 @@ def classify_mahalanobis(input_vector, dataSet, labels, k=1):
|
|||||||
count = Counter(k_nearest_labels)
|
count = Counter(k_nearest_labels)
|
||||||
|
|
||||||
# 返回数量最多的类别标签
|
# 返回数量最多的类别标签
|
||||||
return count.most_common(1)[0][0]
|
return count.most_common(1)[0][0]
|
||||||
|
|
||||||
def load_dataset(directory):
|
def load_dataset(directory):
|
||||||
"""加载数据集中的图像,并将其转换为特征向量和标签。"""
|
"""加载数据集中的图像,并将其转换为特征向量和标签。"""
|
||||||
@@ -145,4 +145,4 @@ if __name__ == "__main__":
|
|||||||
train_labels,
|
train_labels,
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"预测的标签: {predicted_label}")
|
print(f"预测的标签: {predicted_label}")
|
||||||
|
|||||||
Reference in New Issue
Block a user