Source variance filter
neureptrace.decoding.source_variance_filter implements source-only variance-based feature filtering.
The protocol is Category 1 / strict source-only. Feature variances and the selected feature mask are estimated from source rows only. Evaluation rows are transformed with the fitted mask but are not used to fit it.
Typical usage:
from neureptrace.decoding.source_variance_filter import fit_source_variance_filter
result = fit_source_variance_filter(
source_features=X_source,
test_features=X_target,
config={"variance_threshold": 0.0, "top_k": 128},
)
X_source_filtered = result.train_features
X_target_filtered = result.test_features
neureptrace.decoding.source_variance_filter
Source-only variance feature filtering.
This module fits a feature-selection mask from source rows only and applies that mask to source and evaluation feature matrices. It is a strict Protocol-1 preprocessing helper for removing constant or low-variance features without using any evaluation-domain statistics.
SourceVarianceFilterConfig
dataclass
Configuration for source-only variance feature filtering.
Source code in src/neureptrace/decoding/source_variance_filter.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
__post_init__()
Normalize and validate direct dataclass construction.
Source code in src/neureptrace/decoding/source_variance_filter.py
30 31 32 33 34 35 | |
SourceVarianceFilterResult
dataclass
Filtered feature matrices and fitted source-only mask.
Source code in src/neureptrace/decoding/source_variance_filter.py
38 39 40 41 42 43 44 45 46 | |
fit_source_variance_filter(*, source_features, test_features, config=None)
Fit a variance-based feature mask from source rows and transform matrices.
Source code in src/neureptrace/decoding/source_variance_filter.py
52 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 | |
source_variance_filter_config(*, variance_threshold=DEFAULT_VARIANCE_THRESHOLD, top_k=None, ddof=1)
Normalize public variance-filter options.
Source code in src/neureptrace/decoding/source_variance_filter.py
95 96 97 98 99 100 101 102 103 104 105 106 107 | |
source_feature_variances(source_features, *, ddof=1)
Return source-only feature variances.
Source code in src/neureptrace/decoding/source_variance_filter.py
110 111 112 113 114 115 116 117 | |
select_variance_features(variances, *, variance_threshold=DEFAULT_VARIANCE_THRESHOLD, top_k=None)
Return selected feature indices sorted in original feature order.
Source code in src/neureptrace/decoding/source_variance_filter.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |