dqm_ml_core.api.gap_processor
Gap processor base class.
This module contains the GapProcessor base class that all domain gap processors must inherit from.
logger = logging.getLogger(__name__)
module-attribute
GapProcessor
Bases: Processor
Base class for all domain gap processors.
Gap processors compute distribution shift between two datasets
(e.g., MMD, FID, KL divergence). The primary lifecycle methods are
select_features (per-batch column selection aware of previous features),
compute_batch_metric (batch aggregation), compute (final dataset-level
statistics), and compute_delta (pairwise comparison).
Source code in packages/dqm-ml-core/src/dqm_ml_core/api/gap_processor.py
compute(batch_metrics: dict[str, pa.Array]) -> dict[str, Any]
Perform the final dataset-level aggregation of batch statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_metrics
|
dict[str, Array]
|
The aggregated intermediate statistics from all batches. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the final dataset-level statistics. |
Source code in packages/dqm-ml-core/src/dqm_ml_core/api/gap_processor.py
compute_batch_metric(features: dict[str, pa.Array]) -> dict[str, pa.Array]
Aggregate features into intermediate statistics for the current batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
dict[str, Array]
|
Dictionary of feature arrays computed on the batch. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Array]
|
A dictionary of aggregated statistics. |
Source code in packages/dqm-ml-core/src/dqm_ml_core/api/gap_processor.py
compute_delta(source: dict[str, Any], target: dict[str, Any]) -> dict[str, Any]
Compare metrics between two different dataselections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
dict[str, Any]
|
Final metrics from the source dataselection. |
required |
target
|
dict[str, Any]
|
Final metrics from the target dataselection. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing distance or difference scores. |
Source code in packages/dqm-ml-core/src/dqm_ml_core/api/gap_processor.py
select_features(batch: pa.RecordBatch, prev_features: dict[str, pa.Array]) -> dict[str, pa.Array]
Extract relevant columns from a batch, resolving patterns against both batch columns and previously computed upstream features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
RecordBatch
|
The input pyarrow RecordBatch. |
required |
prev_features
|
dict[str, Array]
|
Features already computed by preceding processors. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Array]
|
A dictionary mapping column names to pyarrow Arrays. |