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: MetricsProcessor
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
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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
include_metadata: bool = cfg.include_metadata
instance-attribute
include_overall: bool = cfg.include_overall
instance-attribute
include_per_column: bool = cfg.include_per_column
instance-attribute
output_metrics: dict[str, str] = {}
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. - output_metrics: Mapping of metric names to column names. - include_per_column: Include per-column completeness scores. - include_overall: Include overall completeness score. |
None
|
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
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
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
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
reset() -> None
Reset processor state for new processing run.
The completeness processor has no persistent state across runs, so this is a no-op. Provided for interface compliance.
Source code in packages/dqm-ml-core/src/dqm_ml_core/metrics/completeness.py
select_columns(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 |