From 9e13a90ce5ea642044af10a8aa10f34a1006115c Mon Sep 17 00:00:00 2001 From: wzy <675163717@qq.com> Date: Thu, 31 Oct 2024 15:26:27 +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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/function.py b/function.py index b2d1e2b..0127008 100644 --- a/function.py +++ b/function.py @@ -117,6 +117,9 @@ def load_data(filepath): data = [line.strip().split() for line in lines] data = [list(map(lambda x: float(x) if x != '?' else np.nan, row)) for row in data] + # 移除类别标签缺失的样本 + data = [row for row in data if row[-1] != np.nan] + # 使用“0”填充缺失值 for row in data: for i in range(len(row)):