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

This commit is contained in:
2024-11-21 17:16:08 +08:00
parent 0d6b02d2a0
commit 044995ac45
+5
View File
@@ -90,6 +90,11 @@ def load_data(filepath):
- np.array: 标签数据。
"""
data = np.loadtxt(filepath, delimiter=',', dtype=str)
# 检查数据的维度
if data.ndim == 1:
data = data.reshape(1, -1) # 如果数据是一维的,重塑为二维
X = data[:, :-1].astype(float) # 特征数据
y = data[:, -1] # 标签数据