modified: checkpoints_final/task1_final/task1_final_model.pkl new file: checkpoints_final/task1_final/task1_tmd_adapter.pkl new file: scripts_4/README.md new file: scripts_4/__init__.py new file: scripts_4/__pycache__/adapter.cpython-314.pyc new file: scripts_4/adapter.py new file: scripts_4/predict_tmd_single.py new file: scripts_4/train_tmd_adapter.py
scripts_4: TMD 小样本适配
本目录实现二阶段方案:
- 基础模型(
Non_TMD训练得到的task1_final_model.pkl)先给出基线预测; - 用极少量
TMD样本拟合频率相关比例系数k(f); - 输出
TMD预测:y_tmd = k(f) * y_base。
为什么这样做
- 仅 5 个 TMD 点直接重训主模型容易过拟合;
- 保留基础模型泛化能力,只学习域偏移;
- 通过
shrinkage把校正系数向1.0收缩,降低小样本波动影响; - 频率外推时会自动向
1.0回归,避免越界夸张。
脚本说明
train_tmd_adapter.py:拟合并保存适配器,同时输出 LOOCV 报告。predict_tmd_single.py:加载基础模型 + 适配器,对单个 TMD 文件推理。adapter.py:频率校正器定义与序列化工具。
使用方法(请使用虚拟环境 Python)
.venv/bin/python scripts_4/train_tmd_adapter.py
.venv/bin/python scripts_4/predict_tmd_single.py \
--file downloads/TMD/val/harmonic_5mm_1.25Hz_TMD.csv
可选参数示例:
.venv/bin/python scripts_4/train_tmd_adapter.py \
--shrinkage 0.25 \
--extrapolation-decay-hz 0.3
输出文件
- 适配器:
checkpoints_final/task1_final/task1_tmd_adapter.pkl - 报告:
evaluation_outputs/task1_final/tmd_adapter_report.json