f_classif#
- sklearn.feature_selection.f_classif(X, y)[原始碼]#
計算所提供樣本的 ANOVA F 值。
請參閱使用者指南以了解更多資訊。
- 參數:
- X形狀為 (n_samples, n_features) 的 {類陣列,稀疏矩陣}
將依序測試的迴歸器集合。
- y形狀為 (n_samples,) 的類陣列
目標向量。
- 返回:
- f_statistic形狀為 (n_features,) 的 ndarray
每個特徵的 F 統計量。
- p_values形狀為 (n_features,) 的 ndarray
與 F 統計量相關的 P 值。
另請參閱
chi2
chi2
:用於分類任務的非負特徵卡方統計量。f_regression
f_regression
:迴歸任務的標籤/特徵之間的 F 值。
範例
>>> from sklearn.datasets import make_classification >>> from sklearn.feature_selection import f_classif >>> X, y = make_classification( ... n_samples=100, n_features=10, n_informative=2, n_clusters_per_class=1, ... shuffle=False, random_state=42 ... ) >>> f_statistic, p_values = f_classif(X, y) >>> f_statistic array([2.2...e+02, 7.0...e-01, 1.6...e+00, 9.3...e-01, 5.4...e+00, 3.2...e-01, 4.7...e-02, 5.7...e-01, 7.5...e-01, 8.9...e-02]) >>> p_values array([7.1...e-27, 4.0...e-01, 1.9...e-01, 3.3...e-01, 2.2...e-02, 5.7...e-01, 8.2...e-01, 4.5...e-01, 3.8...e-01, 7.6...e-01])