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

This commit is contained in:
2024-10-22 19:57:55 +08:00
parent 1cc0339164
commit f2f3e0ef9b
+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): # 设置默认值 k=1
def classify(input_vector, dataSet, labels, k=3): # 设置默认值 k=1
"""使用 KNN 算法对输入样本进行分类。"""
# 计算输入向量与训练集之间的欧氏距离
distances = np.linalg.norm(dataSet - input_vector, axis=1)