An ANOVA F-test ranks numerical features when the fraud label is binary and the feature values are not directly comparable with labels 0 and 1. It compares variability between the genuine and fraudulent group means with variability within those groups. A larger between-group component relative to within-group variation indicates clearer separation and makes the feature a candidate for rule-based fraud detection. section 2.1.2
Use the F-test as part of a practical numerical-feature workflow:
- Fit f_classif through SelectKBest on the numerical columns and the fraud label. section 2.1.2
- Sort the resulting F-statistics in decreasing order to identify candidate features. section 2.1.2
- Inspect high-ranking features with countplots, stripplots, or histplots rather than relying on the score alone. section 2.1.2
- Account for real-time availability and missing values before turning feature importance into production rules. section 2.1.2
Phishing-feature ranking
For a phishing dataset, the F-test ranks features such as NumDash, NumNumericChars, and PctExtResourceUrls by their ability to separate genuine webpages from fraudulent webpages. PctExtNullSelfRedirectHyperlinksRT requires additional inspection: its possible values are -1, 0, and 1, and a countplot shows a high fraud likelihood at -1, while a stripplot suffers from severe point overlap. section 2.1.2
Equation 2.1 Formula for one-way ANOVA F-test statistic
The statistic is summarized as F = between-group variability / within-group variability. section 2.1.2
from sklearn.feature_selection import f_classif, SelectKBest plt.figure(figsize=(10,8)) fs = SelectKBest(score_func=f_classif) fs.fit(df[numerical_features], df.CLASS_LABEL) scores = zip(numerical_features, fs.scores_) scores = sorted(scores, key=lambda c: c[1], reverse=True) sns.barplot( x=[c[1] for c in scores], y=[c[0] for c in scores]);
The supplied scikit-learn listing computes F-test scores for numerical features and plots them in descending order. section 2.1.2

