Skip to main content

sklearn Integration

The nimbus-bci heads are fully compatible with scikit-learn — pipelines, cross-validation, hyperparameter tuning, and the broader sklearn ecosystem. Use them standalone or as Personalizer(head=...) under the middleware contract.
Product vs sklearn surface
  • Apps / devices: PersonalizerBrainState (middleware).
  • Research CV / GridSearch: use the head directly (NimbusLDA, …) or adapter.head on already-encoded embeddings Z.

Personalizer + sklearn heads

Encode once, personalize for apps, tune the head with sklearn:

sklearn-Compatible API

All nimbus-bci heads implement the sklearn estimator interface:

Pipelines

Basic Pipeline

Combine scaling with a Nimbus head (classical features or precomputed embeddings):

Multi-Step Pipeline

Add feature selection and normalization:

BCI-Specific Pipeline

Complete BCI preprocessing pipeline:

Cross-Validation

Basic Cross-Validation

Evaluate model performance:

Stratified K-Fold

Maintain class balance in folds:

Multiple Metrics

Evaluate multiple metrics simultaneously:

Leave-One-Subject-Out

For BCI with multiple subjects:

Hyperparameter Tuning

Exhaustive search over parameter grid:
More efficient for large parameter spaces:

Pipeline Parameter Tuning

Tune parameters across entire pipeline:

Model Selection

Compare Multiple Heads

Compare different nimbus-bci heads (same choices as Personalizer(head=...)):

Compare with sklearn Classifiers

Benchmark against sklearn models:

Feature Selection

Univariate Feature Selection

Select best features before classification:

Recursive Feature Elimination

Iteratively remove least important features:

Ensemble Methods

Voting Classifier

Combine multiple nimbus-bci classifiers:

Bagging

Bootstrap aggregating for variance reduction:

Calibration

Probability Calibration

Calibrate predicted probabilities:

Custom Transformers

BCI-Specific Transformer

Create custom transformer for BCI preprocessing:

Performance Evaluation

Comprehensive Metrics

Evaluate with multiple metrics:

ROC and AUC

For binary classification:

Saving and Loading

Joblib Persistence

Save entire pipeline:

Best Practices

1. Always Use Pipelines

Encapsulate preprocessing with classification:

2. Use Stratified Splits

Maintain class balance:

3. Tune Hyperparameters

Always optimize hyperparameters:

4. Evaluate on Held-Out Test Set

Never tune on test data:

Next Read

Personalizer & Middleware

App-facing BrainState contract

MNE Integration

Epochs → encoder or CSP → Personalizer

Streaming Inference

Real-time BCI with chunk processing

API Reference

Complete API documentation