MCPcopy
hub / github.com/scikit-learn/scikit-learn / f_classif

Function f_classif

sklearn/feature_selection/_univariate_selection.py:125–171  ·  view source on GitHub ↗

Compute the ANOVA F-value for the provided sample. Read more in the :ref:`User Guide `. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) The set of regressors that will be tested sequentially. y : arra

(X, y)

Source from the content-addressed store, hash-verified

123 prefer_skip_nested_validation=True,
124)
125def f_classif(X, y):
126 """Compute the ANOVA F-value for the provided sample.
127
128 Read more in the :ref:`User Guide <univariate_feature_selection>`.
129
130 Parameters
131 ----------
132 X : {array-like, sparse matrix} of shape (n_samples, n_features)
133 The set of regressors that will be tested sequentially.
134
135 y : array-like of shape (n_samples,)
136 The target vector.
137
138 Returns
139 -------
140 f_statistic : ndarray of shape (n_features,)
141 F-statistic for each feature.
142
143 p_values : ndarray of shape (n_features,)
144 P-values associated with the F-statistic.
145
146 See Also
147 --------
148 chi2 : Chi-squared stats of non-negative features for classification tasks.
149 f_regression : F-value between label/feature for regression tasks.
150
151 Examples
152 --------
153 >>> from sklearn.datasets import make_classification
154 >>> from sklearn.feature_selection import f_classif
155 >>> X, y = make_classification(
156 ... n_samples=100, n_features=10, n_informative=2, n_clusters_per_class=1,
157 ... shuffle=False, random_state=42
158 ... )
159 >>> f_statistic, p_values = f_classif(X, y)
160 >>> f_statistic
161 array([2.21e+02, 7.02e-01, 1.70e+00, 9.31e-01,
162 5.41e+00, 3.25e-01, 4.71e-02, 5.72e-01,
163 7.54e-01, 8.90e-02])
164 >>> p_values
165 array([7.14e-27, 4.04e-01, 1.96e-01, 3.37e-01,
166 2.21e-02, 5.70e-01, 8.29e-01, 4.51e-01,
167 3.87e-01, 7.66e-01])
168 """
169 X, y = check_X_y(X, y, accept_sparse=["csr", "csc", "coo"])
170 args = [X[safe_mask(X, y == k)] for k in np.unique(y)]
171 return f_oneway(*args)
172
173
174def _chisquare(f_obs, f_exp):

Callers 3

test_f_classifFunction · 0.90

Calls 3

check_X_yFunction · 0.90
safe_maskFunction · 0.90
f_onewayFunction · 0.85

Tested by 3

test_f_classifFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…