From ad6146c1daabc4acef84d0b262a09dff3eaca91d Mon Sep 17 00:00:00 2001 From: LiYufeng <2371258046@qq.com> Date: Wed, 16 Oct 2024 22:40:05 +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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/function.py b/function.py index 4c3364b..71b0fe5 100644 --- a/function.py +++ b/function.py @@ -1,6 +1,3 @@ -#function -id="202210423115" -name="李煜锋" def classify(input_vector, dataSet, labels, k=3): """ KNN 分类算法。 @@ -17,6 +14,8 @@ def classify(input_vector, dataSet, labels, k=3): """ 使用欧式距离的 kNN 分类算法。 """ + id="202210423115" + name="李煜锋" # 计算欧式距离 distances = np.linalg.norm(dataSet - input_vector, axis=1)