更新 function.py
Gitea Actions Challenge Test / Challenge-Actions (push) Successful in 12s

This commit is contained in:
2024-10-10 17:22:30 +08:00
parent ae3eb4add3
commit f74a8dd0f7
+4 -2
View File
@@ -41,8 +41,8 @@ name = "董秋"
# 这里写自己的代码实现 # 这里写自己的代码实现
import operator import operator
from collections import Counter from collections import Counter
def classify0(inX, dataSet, labels, k=2): def classify0(inX, dataSet, labels, k=1):
""" """
KNN 分类算法。 KNN 分类算法。
@@ -89,6 +89,8 @@ def classify0(inX, dataSet, labels, k=2):
# 返回出现次数最多的类别的标签 # 返回出现次数最多的类别的标签
return classCount.most_common(1)[0][0] return classCount.most_common(1)[0][0]
def load_data(file_path): def load_data(file_path):