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

This commit is contained in:
2024-10-16 22:30:53 +08:00
parent a270c3f046
commit cf8a1eca62
+4 -1
View File
@@ -55,7 +55,7 @@ def classify(input_vector, dataSet, labels, k=3):
- int: 预测的分类标签。 - int: 预测的分类标签。
""" """
""" """
欧式距离的 kNN 分类算法。 使用欧式距离的 kNN 分类算法。
""" """
# 计算欧式距离 # 计算欧式距离
distances = np.linalg.norm(dataSet - input_vector, axis=1) distances = np.linalg.norm(dataSet - input_vector, axis=1)
@@ -71,7 +71,9 @@ def classify(input_vector, dataSet, labels, k=3):
return most_common return most_common
# 这里也写自己的代码实现 # 这里也写自己的代码实现
def load_dataset(directory): def load_dataset(directory):
""" """
从文件夹中加载数据,若不自行正确实现,则无法通过评测,**不记录成绩**。 从文件夹中加载数据,若不自行正确实现,则无法通过评测,**不记录成绩**。
@@ -102,6 +104,7 @@ labels = []
return np.array(features), np.array(labels) return np.array(features), np.array(labels)
# 这里还写自己的代码实现 # 这里还写自己的代码实现
def img_to_vector(filename): def img_to_vector(filename):
""" """