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

This commit is contained in:
2024-10-12 19:44:52 +08:00
parent c5ab5d398c
commit fb9b1d368d
+2 -1
View File
@@ -1,5 +1,6 @@
# function.py
import numpy as np
from collections import Counter
"""
挑战说明:
@@ -44,7 +45,7 @@ name = "邓杰元"
def classify0(inX, dataSet, labels, k=20):
distances = [np.sqrt(np.sum((x - inX) ** 2)) for x in dataSet]
k_indices = np.argsort(distances)[:k]
from collections import Counter
most_common = Counter(k_nearest_labels).most_common(1)
return most_common[0][0]