Subspace alignment
neureptrace.decoding.subspace_alignment implements PCA subspace alignment for cross-subject transfer.
The method fits a source PCA basis and an unlabeled target PCA basis, rotates the source coordinates toward the target coordinates, and then allows a source-label classifier to be trained in the aligned space.
Protocol boundary:
- uses source features,
- uses source labels only for the optional classifier helper,
- uses unlabeled target features to fit the target subspace,
- does not accept target labels.
neureptrace.decoding.subspace_alignment
PCA subspace alignment for unlabeled target-adaptive decoding.
This module implements a dependency-light version of feature-space subspace alignment for cross-subject transfer. A source PCA basis and an unlabeled target PCA basis are estimated inside one fold, the source basis is rotated toward the target basis, and the transformed source rows can be used with ordinary source-label classifiers. Target labels are intentionally absent from the public API.
SubspaceAlignmentModel
dataclass
Fitted source-to-target PCA subspace alignment model.
Source code in src/neureptrace/decoding/subspace_alignment.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
transform_source(features)
Project source-domain rows into the target subspace coordinates.
Source code in src/neureptrace/decoding/subspace_alignment.py
43 44 45 46 47 48 49 50 | |
transform_target(features)
Project target-domain rows into their own PCA subspace coordinates.
Source code in src/neureptrace/decoding/subspace_alignment.py
52 53 54 55 56 57 58 59 | |
SubspaceAlignmentResult
dataclass
Aligned source and target features plus protocol metadata.
Source code in src/neureptrace/decoding/subspace_alignment.py
62 63 64 65 66 67 68 69 | |
SubspaceAlignedClassificationResult
dataclass
Classifier outputs from a source-label probe in aligned subspace.
Source code in src/neureptrace/decoding/subspace_alignment.py
72 73 74 75 76 77 78 79 80 81 82 83 | |
fit_subspace_alignment(source_features, target_features, *, n_components=DEFAULT_SUBSPACE_COMPONENTS, standardization_scope='source')
Fit Category-2 PCA subspace alignment from source and unlabeled target rows.
Source code in src/neureptrace/decoding/subspace_alignment.py
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 | |
fit_subspace_aligned_classifier(*, source_features, source_labels, target_features, n_components=DEFAULT_SUBSPACE_COMPONENTS, standardization_scope='source', classifier=None, classifier_C=1.0, classifier_max_iter=1000, classifier_class_weight='balanced', sample_weight=None)
Train a source-label classifier after Category-2 subspace alignment.
Source labels are encoded to dense integers before fitting so tuple/list style composite labels remain one class value per source row. Predictions and class vectors are decoded back to the original label objects.
Source code in src/neureptrace/decoding/subspace_alignment.py
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 | |
normalize_standardization_scope(value)
Normalize standardization-scope aliases.
Source code in src/neureptrace/decoding/subspace_alignment.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |