mne_rt.combiners.LearnedCombiner#

class mne_rt.combiners.LearnedCombiner(features: list[str], estimator: Any)[source]#

Bases: FeatureCombiner

Data-driven combination via a fitted sklearn-compatible estimator.

Assembles the feature vector [x₁, x₂, …, xₙ] (in features order), calls estimator.predict([[x₁, …, xₙ]]), and returns the scalar result. Any sklearn-style regressor works out of the box. For classifiers, wrap predict_proba in 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:
featureslist of str

Ordered modality names. The feature vector fed to estimator is built in this exact order; missing features are filled with 0.0.

estimatorfitted sklearn-compatible estimator

Must expose a predict(X) method where X has shape (1, n).

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,
})
__init__(features: list[str], estimator: Any) None[source]#

Methods

__init__(features, estimator)

combine(values)

Return the estimator's prediction for the current feature vector.

combine(values: dict[str, float]) float[source]#

Return the estimator’s prediction for the current feature vector.