From 9a38a834d8657004b47d762c0681f19477e6c852 Mon Sep 17 00:00:00 2001 From: wujunjie <297081150@qq.com> Date: Sun, 6 Oct 2024 18:28:39 +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 3735a8a..18f5702 100644 --- a/function.py +++ b/function.py @@ -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]