From b68c270b60e0621ec1ae95c5666d30b9a987bfe2 Mon Sep 17 00:00:00 2001 From: dong <2938690875@qq.com> Date: Sun, 3 Nov 2024 14:29:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20function.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/function.py b/function.py index bcf7099..9aa30b2 100644 --- a/function.py +++ b/function.py @@ -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)))