Naive Bayes Parzen Window (NBPW)
Description
This module implements the Naive Bayes Parzen Window (NBPW) classifier, which is a non-parametric classifier that uses the Parzen Window method to estimate the probability density function of the features given the class. This classifier is commonly used in BCI applications for its ability to handle non-linear relationships and adapt to variability in EEG signals.
Class
- class bciflow.modules.clf.nbpw.nbpw[source]
Bases:
object
- X
The training features.
- Type:
np.ndarray
- y
The training labels.
- Type:
np.ndarray
- labels
The unique class labels.
- Type:
np.ndarray
- Nw
The number of samples per class.
- Type:
dict
- Pw
The prior probability of each class.
- Type:
dict
- hj
The smoothing parameters for each feature.
- Type:
list
- hwj
The smoothing parameters for each feature per class.
- Type:
dict
- sqrt_2pi
A constant used in the Gaussian kernel calculation.
- Type:
float
- PXij(Xij: float, j: int) float [source]
Returns the probability of the feature Xij given the class.
- Parameters:
Xij (float) – The input feature.
j (int) – The index of the feature.
- Returns:
result – The probability of the feature Xij given the class.
- Return type:
float
- PXij_w(Xij: float, w: int, j: int) float [source]
Returns the probability of the feature Xij given the class w.
- Parameters:
Xij (float) – The input feature.
w (int) – The class.
j (int) – The index of the feature.
- Returns:
result – The probability of the feature Xij given the class w.
- Return type:
float
- Pw_Xi(w: int, Xi: ndarray) float [source]
Returns the probability of the class w given the features Xi.
- Parameters:
w (int) – The class.
Xi (np.ndarray, shape (n_features,)) – The input features.
- Returns:
result – The probability of the class w given the features Xi.
- Return type:
float
- fit(X: ndarray, y: ndarray, verbose: bool = False) object [source]
Fits the model to the input features and labels.
- Parameters:
X (np.ndarray, shape (n_samples, n_features)) – The input features.
y (np.ndarray, shape (n_samples,)) – The labels.
- Returns:
self – Returns the instance itself.
- Return type:
object
- predict(X: ndarray) ndarray [source]
Predicts the class of the input features.
- Parameters:
X (np.ndarray, shape (n_samples, n_features)) – The input features.
- Returns:
pred – The predicted classes for the input features.
- Return type:
np.ndarray, shape (n_samples,)
- predict_proba(X: ndarray) ndarray [source]
Predicts the probability of each class given the features.
- Parameters:
X (np.ndarray, shape (n_samples, n_features)) – The input features.
- Returns:
proba – The probabilities of each class for each input feature.
- Return type:
np.ndarray, shape (n_samples, n_classes)