Subspace adaptation
neureptrace.decoding.subspace_adaptation implements Category-2 TCA-style source-target latent projection.
The fit uses source features and unlabeled target features. Optional source labels can be used to balance the source side of the marginal domain discrepancy. Held-out target labels are not part of the public API.
neureptrace.decoding.subspace_adaptation
Category-2 source-target subspace adaptation utilities.
The helpers in this module implement a small dependency-light Transfer Component Analysis style projection for cross-subject M/EEG features. The projection is fit from source features and unlabeled target features; optional source labels can be used only to balance the source side of the marginal domain discrepancy. Held-out target labels are intentionally absent from the public API.
SubspaceAdaptationConfig
dataclass
Configuration for Category-2 TCA-style feature projection.
Source code in src/neureptrace/decoding/subspace_adaptation.py
31 32 33 34 35 36 37 38 39 40 41 | |
SubspaceAdaptationResult
dataclass
Source/target features projected into a target-adaptive latent space.
Source code in src/neureptrace/decoding/subspace_adaptation.py
44 45 46 47 48 49 50 51 52 53 54 55 | |
fit_subspace_adaptation(source_features, target_features, *, source_labels=None, config=None, method=None, n_components=None, regularization=None, eigen_ridge=None, standardize=None, class_balance_source=None, normalize_latent=None)
Fit a TCA-style subspace using source and unlabeled target features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_features
|
Sequence[Sequence[float]] | ndarray
|
Source and held-out target feature matrices with the same feature width. Target rows are used without labels to fit the shared projection. |
required |
target_features
|
Sequence[Sequence[float]] | ndarray
|
Source and held-out target feature matrices with the same feature width. Target rows are used without labels to fit the shared projection. |
required |
source_labels
|
Sequence[Any] | ndarray | None
|
Optional source labels. They are used only when source class balancing is requested, so source classes contribute equal mass to the marginal source-target discrepancy. |
None
|
config
|
SubspaceAdaptationConfig | dict[str, Any] | None
|
|
None
|
method
|
SubspaceAdaptationConfig | dict[str, Any] | None
|
|
None
|
n_components
|
SubspaceAdaptationConfig | dict[str, Any] | None
|
|
None
|
regularization
|
SubspaceAdaptationConfig | dict[str, Any] | None
|
|
None
|
eigen_ridge
|
SubspaceAdaptationConfig | dict[str, Any] | None
|
|
None
|
standardize
|
SubspaceAdaptationConfig | dict[str, Any] | None
|
|
None
|
class_balance_source
|
bool | None
|
Configuration values. Explicit keyword values override |
None
|
normalize_latent
|
bool | None
|
Configuration values. Explicit keyword values override |
None
|
Returns:
| Type | Description |
|---|---|
SubspaceAdaptationResult
|
Projected source and target features plus projection/provenance fields. |
Notes
This is a Category-2 protocol. It uses X_s and unlabeled X_t; it may
use y_s for source-side class balancing; it never accepts target labels.
Source code in src/neureptrace/decoding/subspace_adaptation.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 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 | |
transform_subspace_features(features, result)
Transform new rows with an already fitted subspace adaptation result.
Source code in src/neureptrace/decoding/subspace_adaptation.py
172 173 174 175 176 177 178 | |
subspace_adaptation_config(*, method=DEFAULT_SUBSPACE_METHOD, n_components=DEFAULT_SUBSPACE_COMPONENTS, regularization=DEFAULT_SUBSPACE_REGULARIZATION, eigen_ridge=DEFAULT_SUBSPACE_EIGEN_RIDGE, standardize=True, class_balance_source=False, normalize_latent=False)
Normalize public configuration values.
Source code in src/neureptrace/decoding/subspace_adaptation.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
normalize_subspace_method(method)
Normalize aliases for subspace-adaptation methods.
Source code in src/neureptrace/decoding/subspace_adaptation.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |