mne_rt.combiners.LearnedCombiner#
- class mne_rt.combiners.LearnedCombiner(features: list[str], estimator: Any)[source]#
Bases:
FeatureCombinerData-driven combination via a fitted sklearn-compatible estimator.
Assembles the feature vector
[x₁, x₂, …, xₙ](in features order), callsestimator.predict([[x₁, …, xₙ]]), and returns the scalar result. Anysklearn-style regressor works out of the box. For classifiers, wrappredict_probain a small adapter so the interface matches.The model must be fitted offline — on resting-state recordings, prior session data, or a dedicated calibration block — before passing it here.
Typical estimator choices:
sklearn.linear_model.Ridge— regularised linear projection; low variance, directly interpretable weights.sklearn.cross_decomposition.PLSRegression— finds the latent direction in feature space most correlated with a target (e.g. tinnitus severity).sklearn.svm.SVR— non-linear kernel regression; higher capacity but needs more calibration data and may overfit.
- Parameters:
Examples
Offline fit, then real-time use:
from sklearn.linear_model import Ridge from mne_rt.combiners import LearnedCombiner # --- offline (calibration session) --- X_cal = ... # shape (n_windows, n_features) y_cal = ... # target scores, shape (n_windows,) model = Ridge(alpha=1.0).fit(X_cal, y_cal) # --- real-time session --- combiner = LearnedCombiner( features=["sensor_power", "laterality", "connectivity_ratio"], estimator=model, ) mixed = combiner.combine({ "sensor_power": 1.2, "laterality": 0.4, "connectivity_ratio": 0.7, })
Methods