From 7e90dfab2b22b88fb0f1d467f17198668c0bee1f Mon Sep 17 00:00:00 2001 From: hao <19382120447@163.com> Date: Thu, 31 Oct 2024 17:02:45 +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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/function.py b/function.py index 8a174ec..0c05d08 100644 --- a/function.py +++ b/function.py @@ -72,9 +72,9 @@ def load_data(filepath): - np.array: 特征数据。 - np.array: 标签数据。 """ - data = np.loadtxt(filepath, delimiter=',', dtype=float) + data = np.genfromtxt(filepath, delimiter=',', dtype=float, filling_values=0) X = data[:, :-1] - y = (data[:, -1] > 0.5).astype(int) # Assuming the last column is the label + y = data[:, -1].astype(int) # 将标签列转换为整数类型 return X, y if __name__ == "__main__":