Domain importance weighting
neureptrace.decoding.domain_importance estimates source sample weights from a binary source-versus-target domain classifier.
This is a Category 2 / unlabeled target-adaptive protocol. It uses source features and unlabeled target features to estimate source-row weights. It does not use target labels.
Typical usage:
from neureptrace.decoding.domain_importance import fit_domain_classifier_importance_weights
result = fit_domain_classifier_importance_weights(
source_features=X_source,
target_features=X_target,
)
sample_weight = result.sample_weights
The returned weights can be passed to any downstream classifier that supports sample_weight.
neureptrace.decoding.domain_importance
Domain-classifier importance weighting for unlabeled target adaptation.
This module implements a compact covariate-shift weighting helper for cross-subject M/EEG transfer. A binary domain classifier is trained to separate labeled source feature rows from unlabeled held-out target feature rows. Its source-row domain posteriors are converted into non-negative source sample weights.
The public API intentionally has no target-label argument. This is a Category-2 protocol because unlabeled target features affect source training weights.
DomainImportanceConfig
dataclass
Configuration for domain-classifier source weighting.
Source code in src/neureptrace/decoding/domain_importance.py
30 31 32 33 34 35 36 37 | |
DomainImportanceResult
dataclass
Source weights and domain probabilities from unlabeled target adaptation.
Source code in src/neureptrace/decoding/domain_importance.py
40 41 42 43 44 45 46 47 48 | |
fit_domain_classifier_importance_weights(source_features, target_features, *, estimator=None, config=None)
Estimate source sample weights from an unlabeled target domain classifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_features
|
Sequence[Sequence[float]] | ndarray
|
Source feature rows that will later be used with source labels by a downstream classifier. |
required |
target_features
|
Sequence[Sequence[float]] | ndarray
|
Unlabeled held-out target rows used only to estimate source/target feature density ratios. |
required |
estimator
|
BaseEstimator | None
|
Optional sklearn-compatible probabilistic binary classifier. If omitted, a standardized logistic regression classifier is used. |
None
|
config
|
DomainImportanceConfig | Mapping[str, Any] | None
|
Weight clipping and normalization settings. A mapping is normalized
through :func: |
None
|
Returns:
| Type | Description |
|---|---|
DomainImportanceResult
|
One non-negative sample weight per source row, plus protocol metadata. |
Notes
The API intentionally has no target_labels parameter. The returned source
weights are Category-2 because they depend on unlabeled X_t.
Source code in src/neureptrace/decoding/domain_importance.py
53 54 55 56 57 58 59 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 | |
domain_importance_config(*, clip=DEFAULT_WEIGHT_CLIP, normalize=True, account_for_sample_priors=True, epsilon=DEFAULT_EPSILON)
Normalize public domain-importance options.
Source code in src/neureptrace/decoding/domain_importance.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
apply_domain_importance_weights(source_features, source_labels, result)
Return source features, labels, and checked domain-importance weights.
Source code in src/neureptrace/decoding/domain_importance.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |