dqm_ml_core.metrics.completeness
Completeness metric processor for evaluating data completeness.
This module contains the CompletenessProcessor class that evaluates the completeness of tabular data by computing non-null value ratios.
logger = logging.getLogger(__name__)
module-attribute
CompletenessProcessor
Bases: DatametricProcessor
Data completeness processor that evaluates the completeness of tabular data.
This processor calculates completeness scores (ratio of non-null to total values) for specified columns and provides overall dataset completeness metrics.
The processor operates at multiple levels: - Batch level: Aggregated counts for streaming processing - Dataset level: Final completeness scores and statistics
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
include_metadata: bool = bool(cfg.get('include_metadata', False))
instance-attribute
include_overall: bool = bool(cfg.get('include_overall', True))
instance-attribute
include_per_column: bool = bool(cfg.get('include_per_column', True))
instance-attribute
output_metrics = cfg.get('output_metrics', {})
instance-attribute
__init__(name: str = 'completeness', config: dict[str, Any] | None = None) -> None
Initialize the completeness processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the processor |
'completeness'
|
config
|
dict[str, Any] | None
|
Configuration dictionary containing: - input_columns: List of columns to analyze for completeness - output_metrics: Dictionary mapping metric names to output column names - include_per_column: Whether to include per-column completeness scores - include_overall: Whether to include overall completeness score |
None
|
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
compute(batch_metrics: dict[str, pa.Array] | None = None) -> dict[str, Any]
Compute final dataset-level completeness metrics.
This aggregates the batch-level counts to compute final completeness scores for each column and overall dataset completeness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_metrics
|
dict[str, Array] | None
|
Dictionary of batch-level metrics to aggregate |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of final completeness metrics |
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
compute_batch_metric(features: dict[str, pa.Array]) -> dict[str, pa.Array]
Compute batch-level completeness counts for streaming aggregation.
This counts total and non-null values per column in this batch, which will be aggregated across all batches for final dataset completeness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
dict[str, Array]
|
Dictionary of column arrays from this batch |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Array]
|
Dictionary of batch-level completeness counts |
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
compute_features(batch: pa.RecordBatch, prev_features: dict[str, pa.Array] | None = None) -> dict[str, pa.Array]
Extract the needed columns from the batch for completeness analysis.
This method simply passes through the columns we need to analyze, as completeness calculation is done at batch and dataset levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
RecordBatch
|
Input batch of data |
required |
prev_features
|
dict[str, Array] | None
|
Previous features (not used in this processor) |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Array]
|
Dictionary containing the columns to analyze |
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
generated_metrics() -> list[str]
Return the list of metric columns that will be generated.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of output metric column names |
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
reset() -> None
Reset processor state for new processing run.
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
233 234 | |