I used chi2 / mutual_info_classif with a numeric target like house prices and got ValueError: Unknown label type: 'continuous'.
Why this happens
The score functions ending in _classif, as well as chi2, assume the target is a set of class labels. When they receive a continuous target, scikit-learn detects it and refuses. f_classif is a trap here: it may not raise an error at all. Instead, it treats every unique price as its own class and returns meaningless scores.
Choose the score function based on your target:
| Target type | Linear relationship | Non-linear relationship | Non-negative / count features |
|---|---|---|---|
| Classification | f_classif | mutual_info_classif | chi2 |
| Regression | f_regression, r_regression | mutual_info_regression | n/a |
Answer 1: For a continuous target, use f_regression
f_regression tests the linear correlation between each feature and the target. It's fast and works well as a baseline.
from sklearn.feature_selection import f_regression
selector = SelectKBest(f_regression, k=10).fit(X, y)
