pyntbci.classifiers.Ensemble

class pyntbci.classifiers.Ensemble(estimator: ClassifierMixin, gate: ClassifierMixin)[source]

Ensemble classifier. It wraps an ensemble classifier around another classifier object. The classifiers are applied to each item in a databank separately. A gating function combines the outputs of the individual classifications to arrive at a single final combined classification.

Parameters:
  • estimator (ClassifierMixin) – The classifier object that is applied to each item in the databank.

  • gate (ClassifierMixin) – The gate that is used to combine the scores obtained from each individual estimator.

models_

A list containing all models learned for each of the databanks.

Type:

list[ClassifierMixin]

decision_function(X: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]][source]

Apply the classifier to get classification scores for X.

Parameters:

X (NDArray) – The matrix of EEG data of shape (n_trials, n_channels, n_samples, n_items).

Returns:

scores – The matrix of scores of shape (n_trials, n_classes).

Return type:

NDArray

fit(X: ndarray[Any, dtype[_ScalarType_co]], y: ndarray[Any, dtype[_ScalarType_co]]) ClassifierMixin[source]

The training procedure to apply an ensemble classifier on supervised EEG data.

Parameters:
  • X (NDArray) – The matrix of EEG data of shape (n_trials, n_channels, n_samples, n_items).

  • y (NDArray) – The vector of ground-truth labels of the trials in X of shape (n_trials). Note, these denote the index at which to find the associated stimulus!

Returns:

self – Returns the instance itself.

Return type:

ClassifierMixin

predict(X: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]][source]

The testing procedure to apply the ensemble classifier to novel EEG data.

Parameters:

X (NDArray) – The matrix of EEG data of shape (n_trials, n_channels, n_samples, n_items).

Returns:

y – The vector of predicted labels of the trials in X of shape (n_trials). Note, these denote the index at which to find the associated stimulus!

Return type:

NDArray

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') Ensemble

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object