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

This commit is contained in:
2024-10-06 18:28:39 +08:00
parent d5b3650de4
commit 9a38a834d8
+1 -1
View File
@@ -60,7 +60,7 @@ def classify0(inX, dataSet, labels,k=4):
for i in range(k):
voteIlabel=labels[sortedDistIndicies[i]]
classCount[voteIlabel]=classCount.get(voteIlabel,0)+1
sortedClassCount = sorted(classCount,items(), key=lambda item: item[1]. reverse=True)
sortedClassCount = sorted(classCount.items(), key=lambda item: item[1], reverse=True)
return sortedclassCount[0][0]