liveBook · Manning

Analysis of variance

As explained in Fight Fraud with Machine Learning

ANOVA is a statistical technique for testing whether the means of multiple groups differ.

Analysis of variance (ANOVA) ranks numerical features by testing whether genuine and fraudulent webpages have meaningfully different means. Its F-test compares between-group variability with within-group variability: strong separation suggests a feature can support fraud-detection rules. section 2.1.2

A practical ANOVA-based feature workflow:

  • Use sklearn.feature_selection.f_classif with SelectKBest to calculate an F-statistic and p-value for each numerical feature. section 2.1.2
  • Sort features by score, then inspect promising features individually with stripplots, countplots, or histplots. section 2.1.2
  • Check missing values, real-time availability, and class-specific overlap before turning statistical importance into a rule. section 2.1.2

Phishing-page features

For PctExtNullSelfRedirectHyperlinksRT, a value of −1 is associated with a high chance of fraud, while 0 and 1 are associated with lower risk. A stripplot is unhelpful when values overlap heavily, so a countplot gives the clearer view. 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]);

Inspect the runnable scikit-learn feature-ranking workflow and its bar-chart output. section 2.1.2

How Fight Fraud with Machine Learning covers it

How deep it goes
Defines the F-test and demonstrates scoring, p-values, and plots, but stops short of multifeature modeling.
Examples
Uses phishing webpages, numerical URL features, F-statistics, p-values, stripplots, countplots, and histplots.
What it assumes
Assumes numerical features and binary labels, then establishes why direct comparison requires a variance-based test.
What you can do after
Apply ANOVA through scikit-learn to rank numerical features and investigate their usefulness for fraud-detection rules.
How it connects
Connects feature selection with classification labels, variance, exploratory visualization, and rule-based fraud detection.

Also explained in

Compare how 4 books explain analysis of variance →

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.