From 03a5bcfce9059b18fec3863fc406535909bc9de8 Mon Sep 17 00:00:00 2001 From: Dengddd <3149942468@qq.com> Date: Sun, 10 Nov 2024 16:42:31 +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 | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/function.py b/function.py index a4fc19b..db11a6f 100644 --- a/function.py +++ b/function.py @@ -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]))