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

This commit is contained in:
2024-11-10 16:42:31 +08:00
parent 4050af4f0f
commit 03a5bcfce9
+1 -12
View File
@@ -83,18 +83,7 @@ def load_data(filepath):
for line in f:
line = line.strip().split()
if len(line) >= 1 and line[-1].isdigit():
line_data = []
for x in line[:-1]:
if x == '?':
# 用均值填充缺失值
data_array = np.array(data)
if len(data_array) > 0:
column_mean = np.nanmean(data_array[:, len(line_data)], axis=0)
line_data.append(column_mean)
else:
line_data.append(0)
else:
line_data.append(float(x))
line_data = [0 if x == '?' else float(x) for x in line[:-1]]
data.append(line_data)
labels.append(int(line[-1]))