From adeafa332a0bdc60e44aa9337a1375a32ca75023 Mon Sep 17 00:00:00 2001 From: sn <3298564802@qq.com> Date: Wed, 16 Oct 2024 19:58:54 +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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/function.py b/function.py index bea93c8..3c7a9ad 100644 --- a/function.py +++ b/function.py @@ -1,6 +1,6 @@ # function.py import numpy as np -from collections import defaultdict + """ 挑战说明: @@ -78,7 +78,7 @@ def classify0(inX, dataSet, labels, k=3): distances = np.array([mahalanobis_distance(inX, x, cov_inv, mean) for x in dataSet]) # 获取距离最近的 k 个样本的索引 - sortedDistIndices = argpartition(distances, k)[:k] + sortedDistIndices = np.argpartition(distances, k)[:k] # 获取这些样本对应的标签 classCount = {}