Transfer Component Analysis
neureptrace.decoding.transfer_component_analysis implements a dependency-light Category 2 / unlabeled target-adaptive Transfer Component Analysis (TCA) utility.
TCA learns a latent space from source features and unlabeled held-out target features, then a downstream classifier can be trained using source labels only. The public APIs intentionally have no target_labels argument.
Supported kernels:
linearrbfwith explicit gamma orgamma="median"
Typical use:
from neureptrace.decoding.transfer_component_analysis import fit_tca_transfer_classifier
result = fit_tca_transfer_classifier(
source_features=X_source,
source_labels=y_source,
target_features=X_target_unlabeled,
n_components=16,
kernel="linear",
)
Protocol interpretation:
[ X_s, y_s, X_t \text{ are used}; \quad y_t \text{ is not used.} ]
neureptrace.decoding.transfer_component_analysis
Transfer Component Analysis for unlabeled target-adaptive decoding.
Transfer Component Analysis (TCA) learns a shared latent space by reducing the marginal distribution discrepancy between labeled source rows and unlabeled target rows. The downstream probe is trained only with source labels in that latent space. The public APIs in this module intentionally do not accept target labels.
TransferComponentAnalysisModel
dataclass
Fitted TCA projection and provenance.
Source code in src/neureptrace/decoding/transfer_component_analysis.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
TransferComponentAnalysisResult
dataclass
Source/target latent features and fitted TCA model.
Source code in src/neureptrace/decoding/transfer_component_analysis.py
48 49 50 51 52 53 54 55 | |
TCATransferClassificationResult
dataclass
Source-label classifier outputs after TCA feature transfer.
Source code in src/neureptrace/decoding/transfer_component_analysis.py
58 59 60 61 62 63 64 65 66 67 68 69 | |
transfer_component_analysis_features(source_features, target_features, *, n_components=DEFAULT_TCA_COMPONENTS, kernel='linear', regularization=DEFAULT_TCA_REGULARIZATION, gamma=DEFAULT_TCA_GAMMA, standardize=True, normalize_components=True, epsilon=DEFAULT_TCA_EPSILON)
Fit TCA and return source/target latent features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_features
|
Sequence[Sequence[float]] | ndarray
|
Labeled source feature rows. Source labels are not needed by TCA itself. |
required |
target_features
|
Sequence[Sequence[float]] | ndarray
|
Unlabeled held-out target feature rows used to estimate the target feature distribution. This makes the method Category 2 rather than strict source-only. |
required |
n_components
|
int | str | None
|
Requested latent dimensionality. The effective dimensionality is capped by the number of source plus target rows. |
DEFAULT_TCA_COMPONENTS
|
kernel
|
str | None
|
|
'linear'
|
regularization
|
float | str
|
Positive ridge term in the generalized eigenproblem. |
DEFAULT_TCA_REGULARIZATION
|
gamma
|
float | str | None
|
RBF gamma. |
DEFAULT_TCA_GAMMA
|
standardize
|
bool
|
If true, z-score features using source-plus-target feature statistics. This is still Category 2 because unlabeled target features contribute. |
True
|
normalize_components
|
bool
|
If true, z-score latent TCA components using source-plus-target latent statistics from the fit set. |
True
|
epsilon
|
float | str
|
Numerical floor for standard deviations and generalized-eigenproblem regularization. |
DEFAULT_TCA_EPSILON
|
Returns:
| Type | Description |
|---|---|
TransferComponentAnalysisResult
|
Source and target latent features plus a reusable fitted model. |
Notes
This function intentionally has no target_labels argument. Source labels
should be used only by the downstream classifier.
Source code in src/neureptrace/decoding/transfer_component_analysis.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 | |
transform_with_tca_model(model, features)
Project new rows with an already fitted TCA model.
Source code in src/neureptrace/decoding/transfer_component_analysis.py
196 197 198 199 200 201 202 203 204 205 206 | |
fit_tca_transfer_classifier(*, source_features, source_labels, target_features, classifier=None, classifier_C=1.0, classifier_max_iter=1000, classifier_class_weight='balanced', sample_weight=None, n_components=DEFAULT_TCA_COMPONENTS, kernel='linear', regularization=DEFAULT_TCA_REGULARIZATION, gamma=DEFAULT_TCA_GAMMA, standardize=True, normalize_components=True, epsilon=DEFAULT_TCA_EPSILON)
Train a source-label classifier after Category-2 TCA alignment.
Source code in src/neureptrace/decoding/transfer_component_analysis.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
normalize_tca_kernel(kernel)
Normalize public aliases for TCA kernels.
Source code in src/neureptrace/decoding/transfer_component_analysis.py
286 287 288 289 290 291 292 293 | |