Diagnostic Analytics
Why Did It Happen?
Descriptive analytics tells you what happened — profit fell. Diagnostic analytics is the next, harder question: why. It is the step most dashboards skip and the one executives actually ask about. The work is to move from one observed change to a small set of candidate causes, then use evidence — correlation, statistical tests, and disciplined drill-down — to keep the explanations that survive scrutiny and discard the ones that don't.
This is a four-chapter mini-series. Each chapter shows the Python that runs the analysis and embeds the actual rendered output, on the same synthetic retail dataset used across the Descriptive and Visualization series. Every statistic quoted on these pages — the t-statistics, the chi-square values, the correlations — is computed from that data, not invented.
Diagnostic analytics turns one symptom into testable hypotheses, then keeps only the drivers the evidence supports.
The Four Chapters
Correlating Drivers with the Target
The fast first pass — rank which numeric variables move with the metric, with a correlation matrix and a ranked correlation-to-target chart.
Hypothesis Testing — Signal or Noise?
The t-test for two group means and the chi-square test for categorical association, each run and rendered on the retail data.
Drilling Down to Localize the Cause
Aggregates hide their own explanation. Slice the metric one dimension at a time until the change concentrates in a specific cell.
Correlation Is Not Causation
The discipline that keeps diagnosis honest — confounders, lurking variables, and why a clean correlation can still be a trap.
Reference Code
The correlation-to-target and group-comparison helpers shown here are packaged as reusable functions in the
Data Analytics Library's
diagnosticanalysis module. Diagnostic analytics sits between
Descriptive ("what happened") and
Predictive ("what will happen").