liveBook · Manning

F-statistic

As explained in Fight Fraud with Machine Learning

An ANOVA F-score is a statistic measuring the ratio of between-group variability to within-group variability.

The ANOVA F-statistic measures between-group variability relative to within-group variability. For phishing detection, it scores how clearly a numerical feature separates genuine webpages (0) from fraudulent webpages (1). section 2.1.2

Equation 2.1 Formula for one-way ANOVA F-test statistic
F = between-group variability / within-group variability

Read the statistic as a ratio: stronger separation between class means and less variation inside classes produce a higher F-score. section 2.1.2

Use scikit-learn’s f_classif with SelectKBest to calculate scores for numerical features, then sort them to inspect their fraud-detecting capability. 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 runnable workflow fits ANOVA scoring to the numerical feature matrix and plots the features in descending score order. section 2.1.2

Interpret F-scores cautiously:

  • A high score suggests useful class separation, but does not by itself establish a reliable fraud rule. section 2.1.2
  • Check the associated p-value; a value above 0.01 indicates that the F-test is not statistically significant and its score should not be trusted. section 2.1.2

How Fight Fraud with Machine Learning covers it

How deep it goes
Defines the variability ratio and demonstrates implementation, while deferring detailed ANOVA theory and test assumptions.
Examples
Uses genuine-versus-fraudulent webpages, 24 numerical features, ranked scores, and p-value output.
What it assumes
Assumes labeled numerical features and basic variability concepts while defining the statistic from its ratio.
What you can do after
Apply scikit-learn’s f_classif to rank numerical features and screen scores using p-values.
How it connects
Links ANOVA, p-values, statistical significance, feature selection, and scikit-learn.

Also explained in

Compare how 3 books explain f-statistic →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fight Fraud with Machine Learning. The section links point to the parts of the book it draws on.