更新 function.py
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 34s

This commit is contained in:
2024-10-22 19:31:44 +08:00
parent d32bade11f
commit 98a861c2fd
+1 -1
View File
@@ -51,7 +51,7 @@ def classify(input_vector, dataSet, labels, k=1, distance_metric='euclidean', we
if weighted:
# 使用距离的倒数作为权重
weights = 1 / (dist[0] + 1e-5) # 避免除以0
weights = 1 / (dist[0] + 1e-5)
label_weights = {}
for i, label in enumerate(nearest_labels):