revert: 回退 StandardScaler — 跨传感器场景下双重归一化导致推理坍缩
- 删除 Pipeline 中 scaler(StandardScaler) 步骤 - 删除 save_model 中 scaler_mean/scaler_scale 导出 - 删除 StandardScaler import - 恢复: imputer → FeatureUnion → cleaner → SVR - MNF 白化本身就是尺度对齐,无需额外标准化
This commit is contained in:
@ -10,7 +10,6 @@ warnings.filterwarnings('ignore')
|
|||||||
|
|
||||||
# 机器学习模型导入 - 改为回归模型
|
# 机器学习模型导入 - 改为回归模型
|
||||||
from sklearn.base import BaseEstimator, TransformerMixin
|
from sklearn.base import BaseEstimator, TransformerMixin
|
||||||
from sklearn.preprocessing import StandardScaler
|
|
||||||
from sklearn.svm import SVR
|
from sklearn.svm import SVR
|
||||||
from sklearn.ensemble import RandomForestRegressor
|
from sklearn.ensemble import RandomForestRegressor
|
||||||
from sklearn.neighbors import KNeighborsRegressor
|
from sklearn.neighbors import KNeighborsRegressor
|
||||||
@ -647,7 +646,6 @@ class WaterQualityModelingBatch:
|
|||||||
('imputer', SimpleImputer(strategy='median')),
|
('imputer', SimpleImputer(strategy='median')),
|
||||||
('preproc', preproc),
|
('preproc', preproc),
|
||||||
('cleaner', _SafeFiniteTransformer()),
|
('cleaner', _SafeFiniteTransformer()),
|
||||||
('scaler', StandardScaler()),
|
|
||||||
('model', base_model),
|
('model', base_model),
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -787,11 +785,6 @@ class WaterQualityModelingBatch:
|
|||||||
'mnf_W': np.asarray(_mnf.W_mnf_),
|
'mnf_W': np.asarray(_mnf.W_mnf_),
|
||||||
'mnf_n_components': int(getattr(_mnf, 'n_components_', _mnf.n_components)),
|
'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_)
|
# SVR 部署矩阵(rbf kernel 需要 support_vectors_)
|
||||||
_deploy['svr_dual_coef'] = np.asarray(_svr.dual_coef_)
|
_deploy['svr_dual_coef'] = np.asarray(_svr.dual_coef_)
|
||||||
_deploy['svr_intercept'] = np.asarray(_svr.intercept_)
|
_deploy['svr_intercept'] = np.asarray(_svr.intercept_)
|
||||||
|
|||||||
Reference in New Issue
Block a user