From f74a8dd0f73178bf7a2f05f73ee5eed0eaac77ac Mon Sep 17 00:00:00 2001 From: dong <2938690875@qq.com> Date: Thu, 10 Oct 2024 17:22:30 +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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/function.py b/function.py index 3a546eb..aef0c4f 100644 --- a/function.py +++ b/function.py @@ -41,8 +41,8 @@ name = "董秋" # 这里写自己的代码实现 import operator -from collections import Counter -def classify0(inX, dataSet, labels, k=2): +from collections import Counter +def classify0(inX, dataSet, labels, k=1): """ KNN 分类算法。 @@ -89,6 +89,8 @@ def classify0(inX, dataSet, labels, k=2): # 返回出现次数最多的类别的标签 return classCount.most_common(1)[0][0] + + def load_data(file_path):