Random subspace ensemble
neureptrace.decoding.random_subspace implements a strict source-only random-subspace ensemble for M/EEG feature matrices.
Each ensemble member is trained on a deterministic random subset of feature columns. Optional row bootstrapping is applied only to training rows. Test rows are only scored and never influence feature-subspace selection, row sampling, model fitting, or model weighting.
This is a Category 1 / strict source-only method.
Typical usage:
from neureptrace.decoding.random_subspace import fit_random_subspace_ensemble
result = fit_random_subspace_ensemble(
train_features=X_source,
train_labels=y_source,
test_features=X_target,
config={"n_estimators": 32, "feature_fraction": 0.5},
)
probabilities = result.probabilities
predictions = result.predictions
neureptrace.decoding.random_subspace
Source-only random-subspace ensembles for M/EEG decoding.
This module implements a dependency-light random-subspace ensemble. Each member is trained on a source-label fold using a deterministic random subset of feature columns, and held-out rows are only scored. No target rows influence fitting, feature selection, model weighting, or model selection.
RandomSubspaceEnsembleConfig
dataclass
Configuration for a strict source-only random-subspace ensemble.
Source code in src/neureptrace/decoding/random_subspace.py
29 30 31 32 33 34 35 36 37 38 39 | |
RandomSubspaceMember
dataclass
One fitted ensemble member and its selected rows/features.
Source code in src/neureptrace/decoding/random_subspace.py
42 43 44 45 46 47 48 49 | |
RandomSubspaceEnsembleResult
dataclass
Predictions, probabilities, and provenance for the ensemble.
Source code in src/neureptrace/decoding/random_subspace.py
52 53 54 55 56 57 58 59 60 61 | |
fit_random_subspace_ensemble(*, train_features, train_labels, test_features, config=None, estimator=None, sample_weight=None)
Fit a strict source-only random-subspace ensemble and score test rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
train_features
|
Sequence[Sequence[float]] | ndarray
|
Source/training rows and labels. Feature subsets and optional bootstrap row samples are drawn only from these rows. |
required |
train_labels
|
Sequence[Sequence[float]] | ndarray
|
Source/training rows and labels. Feature subsets and optional bootstrap row samples are drawn only from these rows. |
required |
test_features
|
Sequence[Sequence[float]] | ndarray
|
Rows to score after the ensemble is fitted. They are not used during fitting or feature-subspace selection. |
required |
config
|
RandomSubspaceEnsembleConfig | Mapping[str, Any] | None
|
Ensemble settings. A mapping is normalized through
:func: |
None
|
estimator
|
BaseEstimator | None
|
Optional sklearn-compatible classifier. If omitted, a standardized logistic regression classifier is used. |
None
|
sample_weight
|
Sequence[float] | ndarray | None
|
Optional source/training sample weights. When bootstrapping rows, weights are subset to the sampled rows. |
None
|
Returns:
| Type | Description |
|---|---|
RandomSubspaceEnsembleResult
|
Averaged probabilities, predictions, fitted members, and protocol metadata. |
Source code in src/neureptrace/decoding/random_subspace.py
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 | |
random_subspace_ensemble_config(*, n_estimators=DEFAULT_N_ESTIMATORS, feature_fraction=DEFAULT_FEATURE_FRACTION, min_features=1, bootstrap_rows=False, row_fraction=1.0, random_state=13, epsilon=DEFAULT_EPSILON)
Normalize public random-subspace ensemble options.
Source code in src/neureptrace/decoding/random_subspace.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
sample_feature_subspaces(*, n_features, n_estimators=DEFAULT_N_ESTIMATORS, feature_fraction=DEFAULT_FEATURE_FRACTION, min_features=1, random_state=13)
Return deterministic random feature-index subsets.
Source code in src/neureptrace/decoding/random_subspace.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |