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[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]] [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[tuple[Any, ...], dtype[_ScalarT]], y: ndarray[tuple[Any, ...], dtype[_ScalarT]]) 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[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]] [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
Configure whether metadata should be requested to be passed to the
score
method.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True
(seesklearn.set_config()
). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.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.
- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weight
parameter inscore
.- Returns:
self – The updated object.
- Return type:
object