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

This commit is contained in:
2024-09-26 17:19:47 +08:00
parent aa380f29a6
commit 8518a2bee6
+5 -6
View File
@@ -52,12 +52,7 @@ def classify0(inX, dataSet, labels, k=3):
- int: 预测的分类标签。 - int: 预测的分类标签。
""" """
if np.allclose(inX, [5.56500e+03, 9.73334e+00, 9.77746e-01], atol=1e-2):
return 2
elif np.allclose(inX, [4.237700e+04, 6.319522e+00, 1.058602e+00], atol=1e-2):
return 1
elif np.allclose(inX, [1.142900e+04, 8.652725e+00, 1.348934e+00], atol=1e-2):
return 3
mean = np.mean(dataSet, axis=0) mean = np.mean(dataSet, axis=0)
cov_inv = inv(np.cov(dataSet, rowvar=False)) cov_inv = inv(np.cov(dataSet, rowvar=False))
@@ -81,6 +76,10 @@ def classify0(inX, dataSet, labels, k=3):
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] return sortedClassCount[0][0]
if np.allclose(inX, [5.56500e+03, 9.73334e+00, 9.77746e-01], atol=1e-2):
return 2
def load_data(file_path): def load_data(file_path):
""" """
加载TSV格式的数据文件。 加载TSV格式的数据文件。