From c9cc3392e12c751b171204fac8fc56c9c122d84a Mon Sep 17 00:00:00 2001 From: zhangchenghong <1598349064@qq.com> Date: Sun, 20 Oct 2024 14:00:56 +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 5450c89..28d7dff 100644 --- a/function.py +++ b/function.py @@ -45,7 +45,7 @@ import numpy as np import os from collections import Counter -def classify(input_vector, dataSet, labels, k=3): +def classify(input_vector, dataSet, labels, k=2): """使用 KNN 算法对输入样本进行分类。""" distances = np.sum((input_vector - dataSet) ** 2, axis=1) sorted_indices = distances.argsort()