From 88dd1ae1d8568f16857b5423cfe2c8cb1d41f8b5 Mon Sep 17 00:00:00 2001 From: duxin Date: Wed, 29 Jul 2026 15:54:05 +0800 Subject: [PATCH] =?UTF-8?q?revert:=20=E5=9B=9E=E9=80=80=20StandardScaler?= =?UTF-8?q?=20=E2=80=94=20=E8=B7=A8=E4=BC=A0=E6=84=9F=E5=99=A8=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E4=B8=8B=E5=8F=8C=E9=87=8D=E5=BD=92=E4=B8=80=E5=8C=96?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=8E=A8=E7=90=86=E5=9D=8D=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 Pipeline 中 scaler(StandardScaler) 步骤 - 删除 save_model 中 scaler_mean/scaler_scale 导出 - 删除 StandardScaler import - 恢复: imputer → FeatureUnion → cleaner → SVR - MNF 白化本身就是尺度对齐,无需额外标准化 --- src/core/modeling/modeling_batch.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/core/modeling/modeling_batch.py b/src/core/modeling/modeling_batch.py index 17378fd..4e8cda9 100644 --- a/src/core/modeling/modeling_batch.py +++ b/src/core/modeling/modeling_batch.py @@ -10,7 +10,6 @@ warnings.filterwarnings('ignore') # 机器学习模型导入 - 改为回归模型 from sklearn.base import BaseEstimator, TransformerMixin -from sklearn.preprocessing import StandardScaler from sklearn.svm import SVR from sklearn.ensemble import RandomForestRegressor from sklearn.neighbors import KNeighborsRegressor @@ -647,7 +646,6 @@ class WaterQualityModelingBatch: ('imputer', SimpleImputer(strategy='median')), ('preproc', preproc), ('cleaner', _SafeFiniteTransformer()), - ('scaler', StandardScaler()), ('model', base_model), ]) @@ -787,11 +785,6 @@ class WaterQualityModelingBatch: 'mnf_W': np.asarray(_mnf.W_mnf_), 'mnf_n_components': int(getattr(_mnf, 'n_components_', _mnf.n_components)), } - # StandardScaler 参数(C++ 端需复现 (X - mean) / scale) - _scaler = model.named_steps.get('scaler') - if _scaler is not None and hasattr(_scaler, 'mean_'): - _deploy['scaler_mean'] = np.asarray(_scaler.mean_, dtype=np.float64) - _deploy['scaler_scale'] = np.asarray(_scaler.scale_, dtype=np.float64) # SVR 部署矩阵(rbf kernel 需要 support_vectors_) _deploy['svr_dual_coef'] = np.asarray(_svr.dual_coef_) _deploy['svr_intercept'] = np.asarray(_svr.intercept_)