Source balancing
neureptrace.decoding.source_balance implements strict source-only sample weighting and balanced resampling helpers.
The protocol is Category 1 / strict source-only. The helpers use source labels and optional source-domain identifiers only. Held-out target features and labels are not accepted.
Supported strategies:
noneclassdomainclass_domain
Supported group targets:
maxminmean
neureptrace.decoding.source_balance
Strict source-only class/domain balancing helpers.
SourceBalanceConfig
dataclass
Configuration for source-only sample weighting and resampling.
Source code in src/neureptrace/decoding/source_balance.py
19 20 21 22 23 24 25 26 | |
SourceBalanceResult
dataclass
Per-row source weights and group metadata.
Source code in src/neureptrace/decoding/source_balance.py
29 30 31 32 33 34 35 36 37 | |
SourceResampleResult
dataclass
Balanced source-row resample.
Source code in src/neureptrace/decoding/source_balance.py
40 41 42 43 44 45 46 47 48 | |
compute_source_balance_weights(source_labels, *, source_domains=None, config=None)
Compute Protocol-1 source sample weights by class/domain groups.
Source code in src/neureptrace/decoding/source_balance.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
resample_source_rows_balanced(source_features, source_labels, *, source_domains=None, config=None)
Resample source rows to equalize class/domain groups.
Source code in src/neureptrace/decoding/source_balance.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
source_balance_config(*, strategy='class_domain', target='max', normalize_weights=True, random_state=13)
Normalize source-balancing options.
Source code in src/neureptrace/decoding/source_balance.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
normalize_balance_strategy(value)
Normalize balance strategy aliases.
Source code in src/neureptrace/decoding/source_balance.py
173 174 175 176 177 178 179 180 | |
normalize_balance_target(value)
Normalize group target aliases.
Source code in src/neureptrace/decoding/source_balance.py
183 184 185 186 187 188 189 190 | |