From ec12a8eb6bf1e66cc1228b725ccce9d99d63c852 Mon Sep 17 00:00:00 2001 From: wzy <675163717@qq.com> Date: Thu, 31 Oct 2024 15:07:47 +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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/function.py b/function.py index 0577f2b..4d38168 100644 --- a/function.py +++ b/function.py @@ -124,8 +124,17 @@ def load_data(filepath): if np.isnan(row[i]): row[i] = mean_val + # 合并特征23的值2和3为0 + for row in data: + if row[22] == 2 or row == 3: # 假设特征23是第23个元素(索引为22) + row[22] = 0 + + # 移除不需要的特征 + # 假设特征从0开始编号,那么我们需要移除特征3(索引为2)和特征24~28(索引为23~27) + data = [row[:2] + row[3:23] + row[28:] for row in data] + # 分离特征和标签 - X = [row[:-1] for row in data] + X = [row[:-1] for row in data] # 特征现在是从0到21,然后是23到27 y = [row[-1] for row in data] return np.array(X), np.array(y)