mojolearn.f_classif#
- mojolearn.f_classif(X, y)[source]#
Compute the ANOVA F-value of each feature against the class labels.
Follows scikit-learn’s
f_classif. As in scikit-learn, a constant feature (or a single class) scores NaN with p-value NaN, and a feature that is constant within every class but not across them scores+infwith p-value 0. Computation is float32.- Parameters:
X (array-like of shape (n_samples, n_features)) – Feature matrix.
y (array-like of shape (n_samples,)) – Class labels.
- Returns:
f_statistic (array of shape (n_features,)) – F-value of each feature.
p_values (array of shape (n_features,)) – p-value of each F-value.
Examples
>>> import numpy as np, mojolearn >>> rng = np.random.default_rng(0) >>> X = rng.random((1000, 8), dtype=np.float32) >>> y = rng.integers(0, 3, 1000) >>> F, p = mojolearn.f_classif(X, y)