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

This commit is contained in:
2024-10-20 14:02:01 +08:00
parent c9cc3392e1
commit abb056671c
+1 -1
View File
@@ -45,7 +45,7 @@ import numpy as np
import os
from collections import Counter
def classify(input_vector, dataSet, labels, k=2):
def classify(input_vector, dataSet, labels, k=1):
"""使用 KNN 算法对输入样本进行分类。"""
distances = np.sum((input_vector - dataSet) ** 2, axis=1)
sorted_indices = distances.argsort()