Library

Volume 1 · Data & Big Data Platforms

Notebook
Sign in

Section 48

Data Quality, Governance & Lineage

497 words · about 2 min

48.1 Data Quality Framework

Dimension Metric Threshold Example
Completeness % null fields <5% Missing required codes
Accuracy % matching source >99% Amount matches source system
Consistency Cross-source match >98% Entity ID consistent across systems
Timeliness Data freshness <15 min (real-time), <1 day (batch) Data lag
Validity % valid values >99% Valid format per business rule
Uniqueness % duplicate records <0.1% Duplicate transaction detection

Tooling: Great Expectations or Deequ for automated checks embedded in the pipeline — define expectations like “rate column must be between 0 and 1” or “amount must be positive” and fail the pipeline (or quarantine records) on violation.

48.2 Data Lineage for Compliance

Source: Source System → ETL: Glue Job #47 → Target: S3 Raw Zone
    → Transform: Spark Job "deidentify_v3" → S3 Curated Zone
    → Load: Redshift COPY → Analytics Table
    → Access: Dashboard User "analyst@org"

Every step logged with:
- Who accessed/transformed
- When
- What transformation applied
- Which sensitive fields involved
- Encryption status at each stage

48.3 ML-Specific Data Quality

  • At ingestion: schema validation (reject malformed records), referential integrity checks, completeness checks (required fields present).
  • In pipeline: automated data quality checks (Great Expectations/Deequ) as a CI/CD gate before training or serving.
  • For ML specifically: feature distribution monitoring (detect drift), label quality auditing (sample and verify ground truth), training/serving skew detection.
  • Domain-specific validation: format validators for domain identifiers (e.g., regex/checksum validation for codes, IDs), reasonableness checks (no future dates, valid ranges).

48.4 Continuous Learning / Retraining Pipeline

Production Model (v1.0)
    │
    ├── Serving → Predictions logged
    ├── Human feedback → Ground truth labels
    ├── Drift detector → Feature/prediction drift alert
    └── Trigger: Weekly schedule OR drift alert
            ▼
        ┌─────────────────────┐
        │ Retraining Pipeline  │
        │ 1. Collect new data  │
        │ 2. Retrain model     │
        │ 3. Evaluate vs. v1.0 │
        │ 4. If better → v1.1  │
        │ 5. Shadow deploy     │
        │ 6. Canary rollout    │
        └─────────────────────┘

48.5 Q&A

Q1: Design the data architecture for an analytics platform ingesting from multiple operational systems.

  1. Ingestion: Kafka for real-time events, AWS Glue for batch (nightly full loads).
  2. Storage: S3 data lake with Delta Lake format — Raw → Curated → Consumption zones.
  3. Processing: EMR/Spark for large-scale ETL and feature engineering.
  4. Warehouse: Redshift for analytics/reporting, connected to BI tools.
  5. ML pipeline: SageMaker/Databricks for training, backed by a feature store populated by Spark.
  6. Real-time: Kafka → Lambda → DynamoDB for live status tracking.
  7. Governance: Lake Formation for access control, Glue Data Catalog for metadata, CloudTrail for audit. Key decisions: Delta Lake for ACID transactions on S3 (important for financial-grade data); decoupled compute/storage (EMR reads from S3, not HDFS); column-level encryption for sensitive fields.

Q2: How do you handle data quality for ML models in a regulated domain? See 118.3 — the interview differentiator is treating data quality as a CI/CD gate (fail the pipeline, don’t just log a warning) and monitoring training/serving skew continuously in production, not only at model-release time.