Files
Building/scripts_4/README.md
CrbnsCat10n 79f3de05f7 modified: .DS_Store
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
2026-05-06 20:57:43 +08:00

46 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# scripts_4: TMD 小样本适配
本目录实现二阶段方案:
1. 基础模型(`Non_TMD` 训练得到的 `task1_final_model.pkl`)先给出基线预测;
2. 用极少量 `TMD` 样本拟合频率相关比例系数 `k(f)`
3. 输出 `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
```bash
.venv/bin/python scripts_4/train_tmd_adapter.py
```
```bash
.venv/bin/python scripts_4/predict_tmd_single.py \
--file downloads/TMD/val/harmonic_5mm_1.25Hz_TMD.csv
```
可选参数示例:
```bash
.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`