Skip to main content
Thanuka.
Back to Articles
Thought Leadership

Statistical Rigor Before Machine Learning

Gradient boosting will happily fit noise and report a confident number. A short case for running descriptive statistics, hypothesis tests, and dimensionality checks before reaching for a model.

Thanuka EllepolaJune 6, 20265 min read

The temptation to skip ahead

Modern tooling makes it possible to load a dataset and produce a trained model with a validation score in under five minutes. Nothing in that workflow forces you to look at the data first, and increasingly nobody does.

The failures that follow are not modelling failures. They are failures to notice that a column is 60% missing, that two features are near-duplicates, or that the target is so imbalanced the reported accuracy is worse than always predicting the majority class.

Descriptive statistics as a bug detector

Means, medians, standard deviations, and a histogram per column take minutes and catch a remarkable share of data defects. A median wildly separated from the mean flags skew or sentinel values. A standard deviation of zero flags a constant column that will contribute nothing. A distribution with a spike at exactly 999 flags a missing-value placeholder that will be silently treated as a real measurement.

None of this requires sophistication. It requires looking.

A minimum pre-model checklist

CheckWhat you look forTypical action
MissingnessColumns >20–30% nullImpute policy or drop
SentinelsSpikes at 0 / −1 / 999Map to proper nulls
ConstantsZero variance featuresRemove before modelling
Class balanceMajority-class accuracy trapReport baseline + F1/AUC
LeakagePost-outcome fieldsExclude from features
These checks are cheap insurance. Skip them and the first model score is usually a measurement of your pipeline bugs.

"Every hour spent on exploratory statistics buys back a day of debugging a model that was never going to work."

Hypothesis tests answer questions models cannot

A model tells you what predicts the target. A hypothesis test tells you whether an observed difference between two groups is distinguishable from noise. These are different questions, and stakeholders usually want the second one.

A t-test comparing two numeric columns, a chi-square test on categorical association, and ANOVA across multiple groups cover a surprising proportion of real analytical requests. Reaching for a classifier to answer "is segment A different from segment B" is using the wrong instrument and produces a less defensible answer.

PCA as a sanity check

Principal component analysis is usually introduced as dimensionality reduction. Its more valuable everyday use is diagnostic. If the first two components explain 98% of the variance across forty features, those features are largely redundant and any feature importance ranking over them will be unstable and misleading.

Projecting onto the first two components also surfaces cluster structure and outliers that no summary table shows. It is a two-line check that changes how you interpret everything downstream.

Schematic cumulative variance explained

Illustrative

Invented numbers to show the diagnostic pattern: if two components already explain nearly everything, feature importance on the raw columns is unstable.

Source — Illustrative schematic — not a dataset PCA

Clustering is exploratory, not conclusive

K-means will return exactly the number of clusters you request, on any dataset, including pure noise. The algorithm has no opinion about whether the structure it found is real.

Cluster output is a hypothesis to test, never a finding to report. Validate against a held-out sample and against variables that were not used to fit, and if the segments do not persist, they were an artefact of the parameter choice.

Building these checks into a reusable workbench — upload, profile, test, reduce, cluster — turns rigour from an act of individual discipline into the default path. That was the motivation behind the Streamlit statistical application in my portfolio.

The discipline that survives

Model architectures churn constantly. The statistical fundamentals underneath them have not changed in decades and will outlast whatever framework is dominant next year.

The practitioners whose work holds up are not the ones using the newest models. They are the ones who understood their data before they modelled it, and who can still explain why the answer is what it is.