From 98a861c2fdb41de9cee4523feedc753f4c65dae9 Mon Sep 17 00:00:00 2001 From: Xionghaoran <719929980@qq.com> Date: Tue, 22 Oct 2024 19:31:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20function.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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):