From 6aaaea5abd0263520419c3a425f1adb5731693e0 Mon Sep 17 00:00:00 2001 From: duxin Date: Wed, 29 Jul 2026 10:22:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20inf=E2=86=92NaN=20=E6=B8=85=E6=B4=97?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=20ndarray=EF=BC=88spxy/ks=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20ndarray=20=E6=97=A0=20.replace=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/modeling/modeling_batch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/modeling/modeling_batch.py b/src/core/modeling/modeling_batch.py index 0448246..5e27447 100644 --- a/src/core/modeling/modeling_batch.py +++ b/src/core/modeling/modeling_batch.py @@ -641,8 +641,10 @@ class WaterQualityModelingBatch: ]) # ★ 入口清洗:inf → NaN,后续 SimpleImputer/cleaner 接力处理 - X_train = X_train.replace([np.inf, -np.inf], np.nan) - X_test = X_test.replace([np.inf, -np.inf], np.nan) + X_train = np.asarray(X_train, dtype=np.float64) + X_test = np.asarray(X_test, dtype=np.float64) + X_train[~np.isfinite(X_train)] = np.nan + X_test[~np.isfinite(X_test)] = np.nan # RandomizedSearchCV 需要以「步骤名__参数名」的格式索引参数网格; # 我们原有的 config['params'] 是模型层的(无 __),统一加 model__ 前缀。