Improve split strategy for more reliable training evaluation

Group samples by identical inputs before splitting, add target-aware stratification options, and cover the behavior with tests so repeated-input rows no longer leak across train, validation, and test sets.

Made-with: Cursor
This commit is contained in:
2026-04-19 16:43:00 +08:00
parent 4981df0c02
commit 745868a456
7 changed files with 352 additions and 6 deletions

View File

@@ -5,6 +5,10 @@ data_path: data/dataset.txt
split_ratios: [0.7, 0.15, 0.15] # train, val, test可改为 [0.8, 0.1, 0.1]
random_seed: 42
# 切分策略:按 8 维输入分组,避免“同输入异输出”跨集合泄漏;再按目标分桶近似分层
split_mode: grouped_stratified # grouped_stratified | random
split_stratify_target: V_pi
split_stratify_bins: 10
remove_duplicate_rows: true
@@ -32,7 +36,8 @@ model:
hidden_dims: [200, 300, 350, 300, 200]
output_dim: 3
batchnorm: false
dropout: 0.0
# 温和 dropout,实测略优于全 0见 results/run_20260419_163305
dropout: 0.05
residual: false
optimizer:
@@ -55,7 +60,8 @@ training:
loss:
type: huber # huber | weighted_mse
huber_delta: 1.0
target_weights: [1.0, 1.0, 1.0]
# BW_3dB, IL, V_pi略加重 V_pi 以小幅提升其测试 R²
target_weights: [1.0, 1.0, 1.2]
# 总输出目录;每次训练会在其下创建 run_时间戳/
output_dir: results

59
configs/mild_reg.yaml Normal file
View File

@@ -0,0 +1,59 @@
# 温和正则 + 略提高 V_pi 权重(在 default 基线上小幅改动,便于对比)
# 使用: python -m src.main train --config configs/mild_reg.yaml
data_path: data/dataset.txt
split_ratios: [0.7, 0.15, 0.15]
random_seed: 42
split_mode: grouped_stratified
split_stratify_target: V_pi
split_stratify_bins: 10
remove_duplicate_rows: true
outlier_strategy: none
outlier_apply_to: targets
outlier_config:
iqr_k: 1.5
zscore_threshold: 4.0
quantile_lower: 0.001
quantile_upper: 0.999
filter_v_pi_range: true
v_pi_min: 0.0
v_pi_max: 500.0
remove_nonpositive_vpi: false
model:
input_dim: 8
hidden_dims: [200, 300, 350, 300, 200]
output_dim: 3
batchnorm: false
dropout: 0.05
residual: false
optimizer:
name: adamw
lr: 0.001
weight_decay: 0.0001
scheduler:
type: cosine
plateau_factor: 0.5
plateau_patience: 10
plateau_min_lr: 1.0e-6
training:
batch_size: 128
epochs: 300
early_stopping_patience: 30
num_workers: 0
loss:
type: huber
huber_delta: 1.0
target_weights: [1.0, 1.0, 1.2]
output_dir: results
last_run_dir: null

59
configs/reg_vpi_try1.yaml Normal file
View File

@@ -0,0 +1,59 @@
# 实验:较强正则 + 提高 V_pi 损失权重2026-04-19 试跑)
# 结果早停偏早test 整体差于 default 基线;仅作记录,日常训练请用 default.yaml
data_path: data/dataset.txt
split_ratios: [0.7, 0.15, 0.15]
random_seed: 42
split_mode: grouped_stratified
split_stratify_target: V_pi
split_stratify_bins: 10
remove_duplicate_rows: true
outlier_strategy: none
outlier_apply_to: targets
outlier_config:
iqr_k: 1.5
zscore_threshold: 4.0
quantile_lower: 0.001
quantile_upper: 0.999
filter_v_pi_range: true
v_pi_min: 0.0
v_pi_max: 500.0
remove_nonpositive_vpi: false
model:
input_dim: 8
hidden_dims: [200, 300, 350, 300, 200]
output_dim: 3
batchnorm: false
dropout: 0.15
residual: false
optimizer:
name: adamw
lr: 0.001
weight_decay: 0.0002
scheduler:
type: cosine
plateau_factor: 0.5
plateau_patience: 10
plateau_min_lr: 1.0e-6
training:
batch_size: 128
epochs: 300
early_stopping_patience: 30
num_workers: 0
loss:
type: huber
huber_delta: 1.0
target_weights: [1.0, 1.0, 1.75]
output_dir: results
last_run_dir: null