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

This commit is contained in:
2024-11-03 14:29:56 +08:00
parent b13d65a207
commit b68c270b60
+5 -2
View File
@@ -54,8 +54,10 @@ def load_data(filepath):
data, labels = [], []
print(f"加载数据中: {filepath}")
with open(filepath, 'r') as f:
for line in f:
for line_idx, line in enumerate(f):
line = line.strip().split()
if line_idx == 2: # 跳过第三行
continue
if len(line) >= 1 and line[-1].isdigit():
line_data = [0 if x == '?' else float(x) for x in line[:-1]]
data.append(line_data)
@@ -66,7 +68,8 @@ def load_data(filepath):
num_features = data.shape[1]
indices_to_remove = [2] # 去掉特征3(索引2)
# 剔除特征 24-28(索引 23-27)
if num_features > 23:
indices_to_remove.extend(range(23, min(28, num_features)))