feat: ML模型波长记忆 + 跨传感器光谱重采样 + 数据加载规范化

训练端 (modeling_batch.py):
- _extract_train_wavelengths() 从列名提取训练波长写入 metadata
- load_data_batch/load_data_single 改为基于列名语义智能提取特征
- 废除 feature_start_column 硬编码位置索引

推理端 (inference_batch.py):
- preprocess_spectra() 分支A: train_wavelengths存在→np.interp精确重采样
- preprocess_spectra() 分支B: 无波长元数据→解析列名→np.interp到400-800nm标准网格
- 废除暴力截断和零值填充
This commit is contained in:
duxin
2026-07-27 14:52:30 +08:00
parent 99aeab3076
commit 92e8c90370
7 changed files with 398 additions and 149 deletions

View File

@ -528,16 +528,14 @@ class Step8MlTrainPanel(QWidget):
def get_training_params(self):
"""获取模型训练参数"""
# ★ 2026-07-01 安全保护float() 前验证 currentText() 是否为有效数值
# ★ v2currentText() 为列名字符串,传 None 走智能识别
feature_text = self.feature_start.currentText()
try:
feature_start = float(feature_text)
except (ValueError, TypeError):
feature_start = 374.285004 # 默认光谱起始列
if not feature_text or feature_text.startswith(""):
feature_text = None
return {
'pipeline_type': 'machine_learning',
'feature_start': feature_start,
'feature_start': feature_text,
'cv_folds': self.cv_folds.value(),
'preprocess_methods': [method for method, cb in self.preproc_checkboxes.items() if cb.isChecked()],
'model_types': [model for model, cb in self.model_checkboxes.items() if cb.isChecked()],