Source MixUp
neureptrace.decoding.source_mixup implements dependency-light feature-space MixUp for source-only domain generalization.
The protocol is Category 1 / strict source-only. It uses source features, source labels, and optional source-domain identifiers. It does not accept target features or target labels.
Synthetic rows are convex combinations of source rows. The result contains both hard labels for existing scikit-learn style pipelines and soft label distributions for consumers that support probabilistic targets.
Typical usage:
from neureptrace.decoding.source_mixup import augment_source_with_mixup
result = augment_source_with_mixup(
X_source,
y_source,
source_domains=subject_ids,
config={
"synthetic_per_class": 8,
"same_class_partner": True,
"cross_domain_partner": True,
"random_state": 13,
},
)
X_aug = result.features
y_aug = result.labels
neureptrace.decoding.source_mixup
Source-only MixUp feature augmentation for domain generalization.
The helpers in this module implement dependency-light feature-space MixUp for cross-subject M/EEG decoding. Synthetic rows are convex combinations of source rows. Labels are represented both as hard labels for existing scikit-learn style pipelines and as class-probability targets for consumers that support soft-label training.
This is a strict source-only / Protocol-1 utility: the public APIs use source features, source labels, and optional source-domain ids only. Target features and target labels are intentionally not accepted.
SourceMixUpConfig
dataclass
Configuration for source-only feature-space MixUp.
Source code in src/neureptrace/decoding/source_mixup.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
enabled
property
Whether this config requests synthetic rows.
SourceMixUpResult
dataclass
Augmented features, hard labels, soft labels, and provenance metadata.
Source code in src/neureptrace/decoding/source_mixup.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
n_synthetic
property
Number of synthetic rows in the output.
augment_source_with_mixup(source_features, source_labels, *, source_domains=None, config=None)
Append source-only MixUp synthetic rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_features
|
Sequence[Sequence[float]] | ndarray
|
Source feature matrix. Rows are trials/windows; columns are flattened M/EEG features or latent features. |
required |
source_labels
|
Sequence[Any] | ndarray
|
One source class label per row. |
required |
source_domains
|
Sequence[Hashable] | ndarray | None
|
Optional source-domain identifiers, usually source-subject ids. When
|
None
|
config
|
SourceMixUpConfig | Mapping[str, Any] | None
|
MixUp settings. A mapping is normalized through
:func: |
None
|
Returns:
| Type | Description |
|---|---|
SourceMixUpResult
|
Feature rows, hard labels, soft label distributions, synthetic mask, and protocol metadata. |
Notes
The API intentionally has no target-feature or target-label arguments. This keeps the method valid for strict source-only Protocol 1 evaluation.
Source code in src/neureptrace/decoding/source_mixup.py
74 75 76 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
mixup_rows(content_features, partner_features, *, lambdas)
Return convex combinations of content and partner feature rows.
Source code in src/neureptrace/decoding/source_mixup.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
source_mixup_config(*, synthetic_per_class=0, alpha=DEFAULT_MIXUP_ALPHA, random_state=13, same_class_partner=True, cross_domain_partner=True, hard_label_policy='content', preserve_original=True)
Normalize user-facing source-MixUp options.
Source code in src/neureptrace/decoding/source_mixup.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
normalize_hard_label_policy(value)
Normalize hard-label policies for synthetic MixUp rows.
Source code in src/neureptrace/decoding/source_mixup.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |