bci_essentials.classification.null_classifier

Null classifier

No model is used. No fitting is done. The classifier always predicts 0.

 1"""**Null classifier**
 2
 3No model is used.
 4No fitting is done.
 5The classifier always predicts 0.
 6
 7"""
 8
 9# Import bci_essentials modules and methods
10from ..classification.generic_classifier import GenericClassifier, Prediction
11from ..utils.logger import Logger  # Logger wrapper
12
13# Instantiate a logger for the module at the default level of logging.INFO
14# Logs to bci_essentials.__module__) where __module__ is the name of the module
15logger = Logger(name=__name__)
16
17
18class NullClassifier(GenericClassifier):
19    """NullClassifier class (*inherits from GenericClassifier*)."""
20
21    def fit(self):
22        """Fit the classifier to the data.
23
24        No fitting is done.
25
26        Returns
27        -------
28        `None`
29
30        """
31        logger.warning("This is a null classifier, there is no fitting")
32
33    def predict(self, X):
34        """Predict the class of the data.
35
36        Parameters
37        ----------
38        X : numpy.ndarray
39            3D array where shape = (trials, channels, samples)
40
41
42        Returns
43        -------
44        prediction : Prediction
45            Prediction object with labels = [0]
46
47        """
48        logger.warning("This is a null classifier, there is no return value")
49        logger.warning("Returning 0")
50        return Prediction(labels=[0])
19class NullClassifier(GenericClassifier):
20    """NullClassifier class (*inherits from GenericClassifier*)."""
21
22    def fit(self):
23        """Fit the classifier to the data.
24
25        No fitting is done.
26
27        Returns
28        -------
29        `None`
30
31        """
32        logger.warning("This is a null classifier, there is no fitting")
33
34    def predict(self, X):
35        """Predict the class of the data.
36
37        Parameters
38        ----------
39        X : numpy.ndarray
40            3D array where shape = (trials, channels, samples)
41
42
43        Returns
44        -------
45        prediction : Prediction
46            Prediction object with labels = [0]
47
48        """
49        logger.warning("This is a null classifier, there is no return value")
50        logger.warning("Returning 0")
51        return Prediction(labels=[0])

NullClassifier class (inherits from GenericClassifier).

def fit(self):
22    def fit(self):
23        """Fit the classifier to the data.
24
25        No fitting is done.
26
27        Returns
28        -------
29        `None`
30
31        """
32        logger.warning("This is a null classifier, there is no fitting")

Fit the classifier to the data.

No fitting is done.

Returns
  • None
def predict(self, X):
34    def predict(self, X):
35        """Predict the class of the data.
36
37        Parameters
38        ----------
39        X : numpy.ndarray
40            3D array where shape = (trials, channels, samples)
41
42
43        Returns
44        -------
45        prediction : Prediction
46            Prediction object with labels = [0]
47
48        """
49        logger.warning("This is a null classifier, there is no return value")
50        logger.warning("Returning 0")
51        return Prediction(labels=[0])

Predict the class of the data.

Parameters
  • X (numpy.ndarray): 3D array where shape = (trials, channels, samples)
Returns
  • prediction (Prediction): Prediction object with labels = [0]