Skip to main content

DQM-ML Core

Core package for DQM-ML V2 providing the foundational API and standard metrics for data quality assessment.

Installation

pip install dqm-ml-core

Note: dqm-ml-core provides Metrics Processors only — no CLI or job orchestration. Use directly via Python or with dqm-ml-job for YAML config execution.

Quick Start: Generate Synthetic Test Data

Create data/core_metrics.parquet with 1000 rows covering all three metric types — Completeness, Representativeness, and Diversity:

# generate_data.py
import numpy as np
import pyarrow as pa
import pyarrow.parquet as pq
from pathlib import Path

rng = np.random.default_rng(42)
Path("data").mkdir(exist_ok=True)

n = 1000
# Completeness: numeric columns with ~20% missing values
col_a = np.where(rng.random(n) < 0.2, None, rng.integers(0, 100, n))
col_b = np.where(rng.random(n) < 0.2, None, rng.integers(0, 100, n))

# Representativeness: normal distribution
feature = rng.normal(0, 1, n)

# Diversity: categorical with 5 imbalanced classes
categories = rng.choice(["A", "B", "C", "D", "E"], n, p=[0.4, 0.25, 0.15, 0.12, 0.08])

table = pa.table({"col_a": col_a, "col_b": col_b, "feature": feature, "category": categories})
pq.write_table(table, "data/core_metrics.parquet")
print(f"Generated {n} rows -> data/core_metrics.parquet")
python generate_data.py

Usage

Completeness Example

Note: See Quick Start: Generate Synthetic Test Data to generate data/core_metrics.parquet.

from dqm_ml_core import CompletenessProcessor, ProcessorRunner
import pandas as pd

# Load synthetic data from parquet (generated by Quick Start script)
df = pd.read_parquet("data/core_metrics.parquet")  # columns: col_a, col_b, feature, category

# Configure processor with columns to analyze
processor = CompletenessProcessor(
    name="my_check",
    config={"columns": {"input": ["col_a", "col_b"]}, "include_per_column": True, "include_overall": True},
)

# Run using ProcessorRunner (high-level API)
runner = ProcessorRunner()
result = runner.run(df, [processor])

print(f"Completeness col_a: {result['completeness_col_a']}")
print(f"Completeness col_b: {result['completeness_col_b']}")
print(f"Overall Completeness: {result['completeness_overall']}")

Representativeness Example

Note: See Quick Start: Generate Synthetic Test Data to generate data/core_metrics.parquet.

from dqm_ml_core import RepresentativenessProcessor
import pyarrow as pa
import pandas as pd

# Load synthetic data from parquet (generated by Quick Start script)
df = pd.read_parquet("data/core_metrics.parquet")
batch = pa.record_batch([pa.array(df["feature"])], names=["feature"])

# Configure processor
processor = RepresentativenessProcessor(
    name="dist_check",
    config={
        "columns": {"input": ["feature"]},
        "distribution": "normal",
        "metrics": ["chi-square", "kolmogorov-smirnov"],
        "mean_std_estimation": "from_first_batch",
    },
)

# Process data through pipeline (direct API)
features = processor.select_columns(batch, prev_features={})
batch_metrics = processor.compute_batch_metric(features)
result = processor.compute(batch_metrics)

print(f"Chi-Square p-value: {result['feature_chi-square_p_value']}")
print(f"KS statistic: {result['feature_kolmogorov-smirnov_statistic']}")
print(f"KS p-value: {result['feature_kolmogorov-smirnov_p_value']}")

With dqm-ml-job

For running from a YAML config, install together with dqm-ml-job:

pip install dqm-ml-job dqm-ml-core

Note: See Quick Start: Generate Synthetic Test Data to generate data/core_metrics.parquet.

Create a YAML config file (e.g., config.yaml):

dataloaders:
  loaders:
    - name: core_data
      type: parquet
      path: data/core_metrics.parquet
      batch_size: 500

metrics:
  processors:
    - name: completeness
      type: completeness
      columns:
        input: ["col_a", "col_b"]
      include_per_column: true
      include_overall: true

    - name: representativeness
      type: representativeness
      columns:
        input: ["feature"]
      distribution: "normal"
      metrics: ["chi-square", "kolmogorov-smirnov"]
      mean_std_estimation: "from_first_batch"

    - name: diversity
      type: diversity
      columns:
        input: ["category"]
      metrics: ["shannon", "gini-simpson", "simpson"]

outputs:
  path: output/metrics.parquet

Execute from Python:

from dqm_ml_job.cli import execute

# Execute a data quality job from a YAML config
execute(["-p", "config.yaml"])

Or from the command line:

python -m dqm_ml_job.cli -p config.yaml

Core Concepts

Three Processor Interfaces

DQM-ML V2 defines three distinct processor interfaces, each with its own base class:

Interface Base Class Purpose
Metrics MetricsProcessor Compute aggregated metric scores from data (Completeness, Representativeness, Diversity)
Features FeaturesProcessor Extract feature columns from data (Visual Features, Embeddings)
Gap GapProcessor Compute pairwise distances between selections (Domain Gap)

All three inherit from a common Processor base class (dqm_ml_core.api.processor:16) which provides:

  • __init__, _check_failure_rate, _check_image_fail_fast, needed_columns(), reset()

MetricsProcessor

Extends Processor. Implement:

  • generated_metrics() → list[str] — output metric names
  • select_columns(batch, prev_features) → dict[str, pa.Array] — select columns (optional, default in base)
  • compute_batch_metric(features) → dict[str, pa.Array] — batch statistics
  • compute(batch_metrics) → dict[str, Any] — final scores

FeaturesProcessor

Extends Processor. Implement:

  • generated_features() → list[str] — output feature column names
  • compute_features(batch, prev_features) → dict[str, pa.Array] — new feature columns
  • needed_columns() → list[str] — input columns needed (optional, default: input_columns)

GapProcessor

Extends Processor. Implement:

  • select_features(batch, prev_features) → dict[str, pa.Array] — retrieve embeddings
  • compute_batch_metric(features) → dict[str, pa.Array] — batch statistics
  • compute(batch_metrics) → dict[str, Any] — final scores
  • compute_delta(source, target) → dict[str, Any] — pairwise distances

Included Metrics

Metric Description
Completeness Analyzes null/missing values in your dataset
Representativeness Statistical distribution analysis (Chi-Square, KS, Shannon Entropy, GRTE)
Diversity Measures category distribution spread (Simpson, Gini-Simpson, Shannon, Richness)

For Developers

To create a new Metrics Processor:

  1. Subclass dqm_ml_core.api.metrics_processor.MetricsProcessor.
  2. Implement generated_metrics(), select_columns() (optional), compute_batch_metric(), and compute().
  3. Register in [project.entry-points."dqm_ml.metrics"] in pyproject.toml.

To create a Features Processor or Gap Processor, use the respective base classes in dqm_ml_core.api.features_processor and dqm_ml_core.api.gap_processor.

Reference implementations:

  • CompletenessProcessor — simple streaming metric
  • RepresentativenessProcessor — statistical tests
  • DiversityProcessor — value-count accumulation

Dependencies

DQM-ML is modular. For core metrics:

# Minimal: use as library only
pip install dqm-ml-core

# For YAML config execution
pip install dqm-ml-job dqm-ml-core

# Full stack with all metrics
pip install dqm-ml-job dqm-ml-core dqm-ml-images dqm-ml-pytorch

See Also

Metadata

Release files for dqm-ml-core 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dqm-ml-core 2.0.2
File Size Uploaded Provenance Actions
dqm_ml_core-2.0.2.tar.gz 35.6 kB Without provenance Details for dqm_ml_core-2.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dqm-ml-core 2.0.2
File Interpreter ABI Platform Actions
dqm_ml_core-2.0.2-py3-none-any.whl Python 3 none any Details for dqm_ml_core-2.0.2-py3-none-any.whl

Total release size: 78.5 kB

Release files / dqm_ml_core-2.0.2.tar.gz

Download URL dqm_ml_core-2.0.2.tar.gz
Size 35.6 kB
Tags Source
SHA-256 checksum
How to use checksums
536d00f45713589ac56282a03010740fdda3599bf86c5cf8b181d5637d8fec92
BLAKE2b-256 checksum
How to use checksums
a092086135162cf17f7f7bbab3354dfa334178b0eefaf4e190d4cb9c445fbb4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.17

Release files / dqm_ml_core-2.0.2-py3-none-any.whl

Download URL dqm_ml_core-2.0.2-py3-none-any.whl
Size 42.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
406edd8362cddaced234dd36f1b32b6922b5504286b44bb864e22e161f0554ab
BLAKE2b-256 checksum
How to use checksums
26696186ba082c90bcd95f875ee114308e619a688f928a02dcc7d22ba0fa5433
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.17

Security for dqm-ml-core 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page