pyntbci.stopping.BetaStopping

class pyntbci.stopping.BetaStopping(estimator: ClassifierMixin, target_p: float = 0.95, fs: int | None = None, max_time: float | None = None)[source]

Beta dynamic stopping. Fits a beta distribution to non-max (correlation+1)/2, and tests the probability of the maximum correlation to belong to that same distribution [2].

Parameters:
  • estimator (ClassifierMixin) – The classifier object that performs the classification.

  • target_p (float (default: 0.95)) – The targeted probability of correct classification.

  • fs (int (default None)) – The sampling frequency of the EEG data in Hz. Required for max_time.

  • max_time (float (default: None)) – The maximum time at which to force a stop, i.e., a classification. If None, the algorithm will always emit -1 if it cannot stop, otherwise it will emit a classification regardless of the certainty after that maximum time.

References

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

The training procedure to fit the dynamic procedure on supervised EEG data. Note, BetaStopping itself does not require training, it only trains the estimator.

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

  • y (NDArray) – The vector of ground-truth labels of the trials in X of shape (n_trials).

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 estimator to novel EEG data using beta dynamic stopping.

Parameters:

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

Returns:

y – The vector of predicted labels of the trials in X of shape (n_trials). Note, the value equals -1 if the trial cannot yet be stopped.

Return type:

NDArray

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

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