diff --git a/function.py b/function.py index e41e0c5..24133c9 100644 --- a/function.py +++ b/function.py @@ -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):