Files
Building/scripts_4
CrbnsCat10n d2dde4f557 modified: .DS_Store
modified:   .gitignore
	new file:   __pycache__/convert_teacher_csv.cpython-314.pyc
	new file:   __pycache__/evaluation_studio.cpython-314.pyc
	new file:   convert_teacher_csv.py
	new file:   downloads/Non_TMD/free_vib/data_converted_free.csv
	new file:   downloads/TMD/val/data_converted_tmd.csv
	new file:   evaluation_studio.py
	new file:   scripts_2/__pycache__/__init__.cpython-314.pyc
	new file:   scripts_2/__pycache__/signal_utils.cpython-314.pyc
	new file:   scripts_2/__pycache__/task3_identify.cpython-314.pyc
	new file:   scripts_3/__pycache__/__init__.cpython-314.pyc
	new file:   scripts_3/__pycache__/task4_predict_freq.cpython-314.pyc
	modified:   scripts_3/task4_predict_freq.py
	new file:   scripts_4/__pycache__/__init__.cpython-314.pyc
	modified:   scripts_4/__pycache__/adapter.cpython-314.pyc
2026-05-07 12:48:31 +08:00
..
2026-05-07 12:48:31 +08:00
2026-05-06 20:57:43 +08:00
2026-05-06 20:57:43 +08:00
2026-05-06 20:57:43 +08:00
2026-05-06 20:57:43 +08:00
2026-05-06 20:57:43 +08:00

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

.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