From f11d075a99979b48a8951fe3f21c020ecb19d9a7 Mon Sep 17 00:00:00 2001 From: dong <2938690875@qq.com> Date: Thu, 31 Oct 2024 23:33:16 +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, 3 insertions(+), 1 deletion(-) diff --git a/function.py b/function.py index 92d2b54..2219d25 100644 --- a/function.py +++ b/function.py @@ -13,7 +13,6 @@ id = "202210423130" name = "董秋" -# 这里写自己的代码实现 def train_logreg(X, y, learning_rate=0.01, iterations=1000, lambda_reg=0.01): """ 对率回归训练函数。 @@ -75,6 +74,9 @@ def load_data(filepath): else: continue # 无效标签,丢弃 + # 用0填充缺失值 + values = [0 if np.isnan(v) else v for v in values] + # 去掉特征3(索引2)和特征24~28(索引23-27) data.append(values[:2] + values[3:23]) # 保留特征1, 2 和特征4-23 except ValueError: