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

This commit is contained in:
2024-10-31 23:26:07 +08:00
parent 2129fe2b68
commit 264fbf9da4
+2 -3
View File
@@ -44,10 +44,9 @@ def load_data(filepath):
y = data[:, -1]
# 将非数值数据替换为NaN,并删除包含NaN的行
X = np.nan_to_num(X, nan=np.nan)
y = np.nan_to_num(y, nan=np.nan)
# 注意:这里我们不需要再次使用np.nan_to_num,因为np.genfromtxt已经处理了非数值数据
# 删除包含NaN的行
# np.isnan()函数会返回一个布尔数组,我们用它来创建一个掩码
mask = ~np.isnan(X).any(axis=1) & ~np.isnan(y)
X = X[mask]
y = y[mask]