Skip to main content
Data ScienceOperations
What this does: Acts as the system’s quality guard — automatically detecting when incoming data changes in unexpected ways and flagging potential issues before they degrade prediction accuracy.

Data Quality Architecture

The system implements a multi-layered approach to data quality, moving from basic schema validation to advanced statistical drift detection.

Schema Validation (Pandera)

We use Pandera to enforce strict type checking and statistical bounds on the raw data immediately upon loading. Schema Definition: src/demand_forecasting/pipelines/data_processing/schemas.py

Custom Data Profiler

Instead of relying solely on heavy external libraries, we use a lightweight, custom profiler (src/demand_forecasting/utils/gx_profiler_simple.py) inspired by Great Expectations but optimized for speed and HTML reporting.

Generated Reports

The profiler automatically generates an HTML report (dataset_profile_YYYYMMDD.html) for every pipeline run, containing:
  • Missing Value Analysis: Heatmaps and percentage counts.
  • Distribution Statistics: Mean, std, min, max, and quantiles for all numeric features.
  • Categorical Summaries: Frequency counts and cardinality checks.
  • Quality Flags: Automatic warnings for “High Cardinality” or “High Warning Rate”.
These reports are saved to data/docs/ and can be served via a static web server or viewed directly.

Drift Detection System

Drift detection is handled by scripts/production_ops/detect_data_drift.py. It persists detection history to a PostgreSQL table drift_records, allowing for trend analysis over time.

Statistical Tests Used

The system employs four distinct statistical tests to ensure robust drift detection across different data types:

Drift Alerting

If ANY of these tests fail for a feature, a “Drift Detected” event is logged. If critical features (like temp or hr) drift, an email alert is immediately sent to the MLOps team via the configured SMTP server.

Database Schema: drift_records

Drift history is stored in PostgreSQL for long-term monitoring:
You can query this table to visualize “Drift Over Time” dashboards in Grafana or Superset.