API reference
Measures
dqmeasure.measures.accuracy_range.DataAccuracyRange
Bases: PositionalMeasure
ISO/IEC 25024 Acc-I-7 "Data accuracy range".
Column measure, tier 1, positional: unit = cell, subject = the column.
Null cells are out of scope and count in neither A nor B. A column of nulls scores
nan rather than 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The numeric column the measure applies to. |
required |
low
|
float | None
|
The interval bounds, or |
None
|
high
|
float | None
|
The interval bounds, or |
None
|
method
|
Literal['minmax']
|
How the reference interval is derived from the clean data. Currently only |
'minmax'
|
inclusive
|
bool
|
Whether the interval bounds count as in-range ( |
True
|
Source code in src/dqmeasure/measures/accuracy_range.py
10 11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.empty_records.EmptyRecords
Bases: PositionalMeasure
ISO/IEC 25024 Com-I-5 "Empty records in a data file".
Table measure, tier 1, positional: unit = record (row), subject = the whole table.
Counts records where all data items are empty A over all records B and reports
X = 1 - A/B, the fraction of records that carry any data ("records exist but are empty").
predict reports 1.0 for a record with at least one
non-null cell, and its mean is exactly the standard's 1 - A/B. The output carries no nulls. There
is no reference to learn and the measure works without fit.
Source code in src/dqmeasure/measures/empty_records.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
dqmeasure.measures.feature_completeness.FeatureCompleteness
Bases: PositionalMeasure
ISO/IEC 25024 Com-I-2 "Attribute completeness" (Com-ML-3 "Feature completeness" in ISO/IEC 5259-2).
Column measure, tier 1, positional: unit = cell, subject = the column.
The ratio of non-null values in the column. Every cell is a unit, and nulls are what's being measured.
There is no reference to learn, so the measure works without fit.
The table-wide Com-ML-1 "Value completeness" is the table-scoped
ValueCompleteness; since every column
contributes the same B, its value equals
mean(FeatureCompleteness(c).score(df) for c in df.columns).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to; any dtype works. |
required |
Source code in src/dqmeasure/measures/feature_completeness.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
dqmeasure.measures.feature_currentness.FeatureCurrentness
Bases: PositionalMeasure
ISO/IEC 5259-2 Cur-ML-1 "Feature currentness".
Column measure, tier 1, positional: unit = cell, subject = the column. The column holds
each data item's timestamp indicating when it was last updated. A column's currentness is measured through
the timestamp column that dates it. The condition checks that the cell's age, defined as reference time minus
the timestamp, lies within the required age range. A counts the items of the right age and B the
non-null timestamps.
The reference time is a measurement-time input, not part of the reference. With
reference_time=None it is the wall clock, read once per fit/predict/score call, so the
acceptable timestamp window moves with time. Pin reference_time for reproducible results. Time-zone-naive
and -aware columns both work as long as the column and the reference time are consistent. Note that the
datetime.now() default is naive.
The ISO standard calls for a date range, which includes min_age and max_age. That's somewhat unintuitive,
a learned min_age makes data fresher than any clean item fail the range. To measure only a freshness ceiling,
specify min_age=timedelta(0).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The datetime column the measure applies to. |
required |
min_age
|
timedelta | None
|
The required age range, or |
None
|
max_age
|
timedelta | None
|
The required age range, or |
None
|
reference_time
|
datetime | None
|
The instant ages are computed against, or |
None
|
Source code in src/dqmeasure/measures/feature_currentness.py
11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.format_consistency.DataFormatConsistency
Bases: PositionalMeasure
ISO/IEC 25024 Con-I-2 "Data format consistency" (Con-ML-3 in ISO/IEC 5259-2).
Column measure, tier 1, positional: unit = cell, subject = the column.
A value is format-consistent when its shape is one of the column's admissible format shapes. Here,
a shape is a string where d indicates a digit, a a letter, and every other character is kept
literally. For example, "202401" -> "dddddd", "2024-01" -> "dddd-dd".
The measure applies to string-encoded columns only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to (string, categorical, or enum). |
required |
formats
|
Collection[str] | None
|
The admissible format shapes, written in the shape alphabet (e.g. |
None
|
Source code in src/dqmeasure/measures/format_consistency.py
16 17 18 19 20 21 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 | |
dqmeasure.measures.inaccuracy_risk.RiskOfDataSetInaccuracy
Bases: PositionalMeasure
ISO/IEC 25024 Acc-I-4 "Risk of data set inaccuracy" (Acc-ML-4 in ISO/IEC 5259-2).
Column measure, tier 1, positional: unit = cell, subject = the column. The standard
defines Acc-I-4 as the risk of inaccuracy, counting outliers, so we report 1 - X to keep every
measure higher-is-better: X is the ratio of values that are not outliers.
The standard leaves the outlier criterion open, and this implementation uses the robust z-score: a value is
an outlier when |value - center| > threshold * scale, with center and scale learned from clean data
as the median and the sigma-scaled median absolute deviation (see https://en.wikipedia.org/wiki/Robust_measures_of_scale
and https://en.wikipedia.org/wiki/Median_absolute_deviation).
When a column is constant in the clean data (scale = 0), every deviating value counts as an outlier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The numeric column the measure applies to. |
required |
center
|
float | None
|
The reference location and dispersion, or |
None
|
scale
|
float | None
|
The reference location and dispersion, or |
None
|
method
|
Literal['mad']
|
How the reference is estimated from the clean data. Currently |
'mad'
|
threshold
|
float
|
How many scale units a value may deviate from the center before it counts as an outlier. The default
|
3.5
|
Source code in src/dqmeasure/measures/inaccuracy_risk.py
14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.inconsistency_risk.RiskOfDataInconsistency
Bases: PositionalMeasure
ISO/IEC 25024 Con-I-3 "Risk of data inconsistency".
Column measure, tier 1, positional: unit = cell, subject = the column.
A cell counts as a duplication when its value occurs more than once in the column. The standard defines
Con-I-3 as the risk of inconsistency, i.e. the ratio of duplicated cells. We report 1 - X to keep
every measure higher-is-better, where X is the standard's share of duplicated cells. The score is
thus the ratio of cells holding a value unique in the column. Nulls are out of scope, as two nulls are not
duplicates of each other.
This measure concerns duplicate values in one column. The table-scoped
DataRecordConsistency addresses entire rows.
There is no reference to learn, and the measure works without fit.
The user should apply this measure to columns where a repeated value signals redundant storage (identifiers,
names of entities stored once), not where repetition is natural (categories).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to; any dtype works. |
required |
Source code in src/dqmeasure/measures/inconsistency_risk.py
10 11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.label_completeness.LabelCompleteness
Bases: PositionalMeasure
ISO/IEC 5259-2 Com-ML-5 "Label completeness".
Column measure, tier 1, positional: unit = sample (row), subject = the label column.
Counts unlabelled or incompletely labelled samples A over all samples B and reports
X = 1 - A/B, the fraction of fully labelled samples. A sample counts as unlabelled when its label is
null: missing labels are assumed to be null-encoded (see the model doc's simplifying
assumptions). predict reports 1.0 for a labelled sample,
and its mean is exactly the standard's 1 - A/B. There is no
reference to learn, the measure works without fit.
Com-ML-5 coincides numerically with Com-ML-3 feature completeness on the label column; the measures
stay distinct in the role of the column and their measurement function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The label column the measure applies to; any dtype works. |
required |
Source code in src/dqmeasure/measures/label_completeness.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
dqmeasure.measures.record_completeness.RecordCompleteness
Bases: PositionalMeasure
ISO/IEC 5259-2 Com-ML-4 "Record completeness".
Table measure, tier 1, positional: unit = record (row), subject = the whole table.
The ratio of rows that have no empty cell over all rows. nulls are the thing
being measured, and a row with null(s) scores 0.0. There is no reference to learn, the
measure works without fit.
Source code in src/dqmeasure/measures/record_completeness.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
dqmeasure.measures.record_consistency.DataRecordConsistency
Bases: PositionalMeasure
ISO/IEC 5259-2 Con-ML-1 "Data record consistency".
Table measure, tier 1, positional: unit = record (row), subject = the whole table.
The ratio of records that occur exactly once in the dataset. The standard defines Con-ML-1 as the
ratio of duplicate records. We report 1 - X to keep every measure higher-is-better, where X
is the ratio of duplicate rows in the table. A record counts as a duplicate when the full row occurs
more than once. This measure is the row-level case of
RiskOfDataInconsistency. Records
containing one or more null values are out of scope, because two nulls are not duplicates of each other.
There is no reference to learn, so the measure works without fit.
Source code in src/dqmeasure/measures/record_consistency.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
dqmeasure.measures.record_currentness.RecordCurrentness
Bases: PositionalMeasure
ISO/IEC 5259-2 Cur-ML-2 "Record currentness".
Table measure, tier 1, positional: unit = record (row), subject = the whole table.
The ratio of records where all data items fall within the required age range. The measure considers
columns of datatype date or datetime to derive one or more ages per row. We call these columns "temporal"
columns. For example, a tables' temporal columns could be inserted_at and last_updated_at, and they
may have different required age ranges.
This measure is the per-column analog of Cur-ML-1 feature currentness.
A record conforms when every one of its non-null temporal cells is of the right age. Null cells are ignored. The frame must have at least one temporal column, and every temporal column of the measured frame must be covered by the reference.
The reference time is a measurement-time input: with reference_time=None it is the wall clock, read
once per fit/predict/score call. Pin reference_time for reproducible results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
age_ranges
|
dict[str, tuple[timedelta, timedelta]] | None
|
The required age range per temporal column, |
None
|
reference_time
|
datetime | None
|
The instant ages are computed against, or |
None
|
Source code in src/dqmeasure/measures/record_currentness.py
11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.semantic_accuracy.SemanticDataAccuracy
Bases: PositionalMeasure
ISO/IEC 25024 Acc-I-2 "Semantic data accuracy" (Acc-ML-2 in ISO/IEC 5259-2).
Column measure, tier 1, positional: unit = cell, subject = the column. The measure is scoped to one column, but its condition reads the whole row, which goes into the prompt as context.
An LLM judges whether each value is semantically accurate given the rest of its record and its
real-world knowledge. The LLM is prompted with example records sampled from the clean data
(few-shot serialization inspired by mimir's llm_master, see https://github.com/calgo-lab/mimir).
The measure sends requests to any OpenAI-compatible chat-completions endpoint, sending one request per record.
The reference (the sampled example records) cannot be specified in the constructor:
fit on clean data is always required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to. All other columns of the frame go into the prompt as context. |
required |
llm_model
|
str
|
Model name and base URL (up to and including |
'llama3.2:3b'
|
llm_url
|
str
|
Model name and base URL (up to and including |
'llama3.2:3b'
|
llm_api_key
|
str | None
|
Bearer token for the endpoint. |
None
|
n_examples
|
int
|
Number of clean records sampled at fit time as few-shot examples in the prompt. |
5
|
random_state
|
int
|
Seed for the example sampling, making the measurement procedure reproducible. |
0
|
n_jobs
|
int
|
Number of concurrent requests. |
1
|
provider
|
str | None
|
Pin every request to one upstream provider (routers such as OpenRouter otherwise pick per request,
which harms reproducibility). |
None
|
Source code in src/dqmeasure/measures/semantic_accuracy.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 | |
fit
fit(X)
Sample the few-shot example records from a clean (training) dataframe. Mandatory for this measure.
Source code in src/dqmeasure/measures/semantic_accuracy.py
83 84 85 86 87 88 89 90 | |
dqmeasure.measures.semantic_consistency.SemanticConsistency
Bases: PositionalMeasure
ISO/IEC 25024 Con-I-6 "Semantic consistency" (Con-ML-4 in ISO/IEC 5259-2).
Column measure, tier 1, positional: unit = cell, subject = the column. The measure is scoped to the column whose values the rules constrain, and each rule reads the rest of the row as context.
The semantic rules are narwhals boolean expressions. Per row, the condition is 1 if every evaluable rule holds, 0 if any evaluable rule fails, and null when no rule is evaluable.
The rules are either specified in the constructor, e.g.
rules=[nw.col("recruited") > nw.col("born")], or learned from clean data at
fit. The rules origin doesn't matter: the DQM evaluates the expressions
and counts the rows that satisfy them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to. Rules constrain this column's values. |
required |
rules
|
Sequence[Expr] | None
|
The semantic rules as narwhals boolean expressions, or |
None
|
Source code in src/dqmeasure/measures/semantic_consistency.py
12 13 14 15 16 17 18 19 20 21 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 | |
rule_descriptions_
instance-attribute
rule_descriptions_
Human-readable forms of the mined rules; set when fit mined the reference.
_mine
_mine(frame)
One rule per column that determines this one on the clean data.
Source code in src/dqmeasure/measures/semantic_consistency.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
dqmeasure.measures.syntactic_accuracy.SyntacticDataAccuracy
Bases: PositionalMeasure
ISO/IEC 25024 Acc-I-1 "Syntactic data accuracy" (Acc-ML-1 in ISO/IEC 5259-2).
Column measure, tier 1, positional: unit = cell, subject = the column.
A value is syntactically accurate when it equals a member of the column's domain. "The same as one from an
identified source of validated information" (ISO/IEC 25024, Table 1, note 1). The clean data acts as that
source: fit learns the domain as the set of distinct non-null values it
observes.
Checking values against the column's data type (the ISO/IEC 5259-2 reading of syntactic correctness) is
deliberately not part of this measure: a typed dataframe already enforces its schema on load, and format
conformance is a measure of its own (Con-I-2 data format consistency).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to. Typically categorical-like, but any dtype works. |
required |
domain
|
Collection[Any] | None
|
The admissible values, or |
None
|
method
|
Literal['observed']
|
How the domain is derived from the clean data. Currently |
'observed'
|
Source code in src/dqmeasure/measures/syntactic_accuracy.py
11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.timeliness.TimelinessOfDataItems
Bases: PositionalMeasure
ISO/IEC 5259-2 Tml-ML-1 "Timeliness of data items".
Column measure, tier 1, positional: unit = row (a data item), subject = the
availability-timestamp column. The standard defines timeliness as the latency
between the time a phenomenon occurs and the time the data recorded for it becomes available for
use — as opposed to currentness (Cur-ML-1), the age of recorded data relative to its use.
event_column names when each phenomenon occurred; it is context, not scope. A row is in
scope iff its event time is set; the condition checks that the data became available within
max_latency of the event. Data that never became available (null availability timestamp
with an event time set) is a failure, not out of scope.
Data available before its event has a negative latency and is always timely. Time-zone-naive and -aware columns both work as long as the two columns are consistent with each other.
Tml-ML-1 coincides numerically with Cur-I-2 timeliness of update under a relabeling of the
columns; the measures stay distinct in the role of the columns: Cur-I-2 counts items needing
updating against a due time, Tml-ML-1 counts every data item against its event time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The datetime column holding when each data item became available (was recorded). |
required |
event_column
|
str
|
The datetime column holding when the phenomenon each data item records occurred. |
required |
max_latency
|
timedelta | None
|
The allowed latency between event and availability, or |
None
|
method
|
Literal['max']
|
How the latency requirement is derived from the clean data. Currently |
'max'
|
Source code in src/dqmeasure/measures/timeliness.py
11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.update_frequency.UpdateFrequency
Bases: PositionalMeasure
ISO/IEC 25024 Cur-I-1 "Update frequency".
Column measure, tier 1, positional: unit = update event, subject = the column. The
frame is read as the event log of one update stream: rows are update events and the column holds
their timestamps (100 stock prices that should update every minute are 100 rows of one stream). The
condition reads the temporally preceding event as context and checks that the event arrived within
max_interval of it, so A counts the events keeping up the required frequency and B the events
with a predecessor. The earliest event (no predecessor) and null timestamps are out of scope.
Row order does not matter — events are ordered by timestamp internally, and
predict returns the results in the input's row order.
Duplicate timestamps have a gap of zero and conform; exactly one of the tied earliest events is the
out-of-scope first event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The datetime column holding the update events' timestamps. |
required |
max_interval
|
timedelta | None
|
The required maximum time between consecutive updates, or |
None
|
method
|
Literal['max']
|
How the interval is derived from the clean data. Currently |
'max'
|
Source code in src/dqmeasure/measures/update_frequency.py
11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.update_timeliness.TimelinessOfUpdate
Bases: PositionalMeasure
ISO/IEC 25024 Cur-I-2 "Timeliness of update".
Column measure, tier 1, positional: unit = row (a data item needing updating), subject = the
update-timestamp column. due_column names when each update was due or requested; it
is context, not scope (scope and context are independent). A row is in scope iff its due time is set, so
B counts the items needing updating; the condition checks that the update landed within sla of
the due time. A needed update that never happened (null update timestamp with a due time set) is a
failure, not out of scope.
An update before its due time has a negative delay and is always timely. Time-zone-naive and -aware columns both work as long as the two columns are consistent with each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The datetime column holding when each item was actually updated. |
required |
due_column
|
str
|
The datetime column holding when each item's update was due; null means no update was needed. |
required |
sla
|
timedelta | None
|
The allowed delay between due time and update, or |
None
|
method
|
Literal['max']
|
How the SLA is derived from the clean data. Currently |
'max'
|
Source code in src/dqmeasure/measures/update_timeliness.py
11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.value_completeness.ValueCompleteness
Bases: PositionalMeasure
ISO/IEC 5259-2 Com-ML-1 "Value completeness".
Table measure, tier 1, positional: unit = record (row), subject = the whole table.
The ratio of non-null cells over all cells of the table. We implement this by calculating the fraction of
non-null cells per row, then averaging them over the entire table. That per-record fraction is itself another
measure: predict reports ISO/IEC 25024 Com-I-1
"Record completeness" for each record.
There is no reference to learn, so the measure works without fit.
The table-wide value is also the mean of the per-column Com-ML-3 scores,
mean(FeatureCompleteness(c).score(df) for c in df.columns), since every column contributes the same
B.
Source code in src/dqmeasure/measures/value_completeness.py
10 11 12 13 14 15 16 17 18 19 20 21 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 | |
dqmeasure.measures.value_distribution.DataValueDistribution
Bases: BaseMeasure
ISO/IEC 5259-2 Con-ML-2 "Distribution of data values".
Column measure, tier 2 (statistic): the QMEs are the reference distribution learned from clean data and
the observed distribution of the measured frame, and X is the distance between them — no per-unit
value exists, so the measure is score()-only. The standard's X is the distance itself, so we
report 1 - X to keep every measure higher-is-better: X = 1 means the distributions agree,
X = 0 that they are disjoint.
The standard delegates the choice of distribution measure ("determined according to the ML task"). We
resolve it with a single principle instead of a catalogue of tests: X is the worst-case disagreement
in probability over the column type's natural events, sup |P(A) - Q(A)|.
- Ordered columns (numeric, dates, datetimes): the natural events are the half-lines
(-∞, x], and the sup over them is the two-sample Kolmogorov-Smirnov statisticsup |F - G|of the two empirical CDFs. - Unordered columns (string, categorical, enum, boolean): with no order to exploit, the natural events
are all subsets of values, and the sup evaluates to the total variation distance
½ Σ |p - q|. Values unseen in the reference contribute their full observed mass.
Both instantiations are parameter-free — no bins, no kernel, no significance level — which is why there
is no method parameter. Nulls are dropped on both sides: missingness is completeness' business, not
distribution drift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to (numeric, date, datetime, string, categorical, enum, or boolean). |
required |
expected
|
Mapping[Any, float] | Sequence[Any] | None
|
The reference distribution: a |
None
|
Source code in src/dqmeasure/measures/value_distribution.py
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 | |
dqmeasure.measures.value_occurrence.ValueOccurrenceCompleteness
Bases: BaseMeasure
ISO/IEC 5259-2 Com-ML-2 "Value occurrence completeness".
Column measure, tier 1, non-positional: the unit is the expected occurrence of a domain value, which cannot
be attached to a position in the frame, so the measure is score()-only. Our interpretation of choices
the standard leaves open:
- We store occurrence proportions rather than raw counts, and expect that the proportions are the same on the measured frame.
- Counted occurrences are capped at the number of expectation per value. This way, over-represented values
cannot compensate for missing ones or push
Xpast 1.
Values outside the observed domain contribute to neither A nor B; null values are not part of the
domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to. Typically categorical-like, but any dtype works. |
required |
expected
|
dict[Any, float] | None
|
Expected occurrence proportions as a |
None
|
Source code in src/dqmeasure/measures/value_occurrence.py
10 11 12 13 14 15 16 17 18 19 20 21 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 | |
Base classes
dqmeasure.base.BaseMeasure
Data-quality measure base class.
Every measure has one of two scopes, exposed as the scope class attribute: a column measure
is constructed for exactly one column, named by the column constructor parameter. And a table
measure applies to all columns of the frame, not requiring a column parameter. Either way
score yields exactly one quality measure value X.
A table-scoped subclass sets scope = "table" and defines its own __init__ without a column
parameter.
Subclasses set iso_5259_id and iso_25024_id (the measure's IDs in the two standards),
and implement two hooks:
_fit_reference: learn the reference from clean data._score: compute the quality measure valueXon a (dirty) dataframe.
Measures whose units are positions in the dataframe should inherit from
PositionalMeasure instead, which adds predict() and derives
_score from it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column the measure applies to. |
required |
Source code in src/dqmeasure/base.py
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 | |
iso_5259_id
class-attribute
iso_5259_id
The measure's ID in ISO/IEC 5259-2, or None if that standard has no counterpart.
iso_25024_id
class-attribute
iso_25024_id
The measure's ID in ISO/IEC 25024, or None if that standard has no counterpart.
scope
class-attribute
scope = 'column'
The measure's subject: one named column, or the whole table. Fixed by the ISO definition.
reference_params
class-attribute
reference_params = ()
Names of the constructor parameters that hold the measure's reference.
Each may be specified in the constructor or left as None to be learned at
fit. After resolution each appears as a fitted <name>_ attribute.
fit
fit(X)
Learn the reference from a clean (training) dataframe.
Sets one fitted <name>_ attribute per reference parameter and returns self. Parameters specified
in the constructor are kept; only the rest is estimated from X.
Source code in src/dqmeasure/base.py
83 84 85 86 87 88 89 90 91 92 | |
score
score(X)
Compute the quality measure value X for a (dirty) dataframe.
Returns one value for the measure's subject (its column, or the whole table). Every measure is
oriented so that higher is better. Where the standard defines X in the opposite direction,
the measure reports 1 - X. When the subject has no units in scope (B = 0), the value is NaN.
Source code in src/dqmeasure/base.py
94 95 96 97 98 99 100 101 102 103 104 | |
_validate
_validate(frame)
Check that frame supports this measure. Default: the column exists (column scope) or the frame
has at least one column (table scope); subclasses may add dtype checks.
Source code in src/dqmeasure/base.py
108 109 110 111 112 113 114 | |
_fit_reference
_fit_reference(frame)
Estimate every reference parameter from clean data.
Returns {param_name: value}. The default has nothing to learn; measures with a non-empty
reference_params override it.
Source code in src/dqmeasure/base.py
116 117 118 119 120 121 122 | |
_score
_score(frame)
Compute X for a (dirty) dataframe. Must be overridden.
Source code in src/dqmeasure/base.py
124 125 126 | |
_resolve
_resolve(frame)
Resolve the <name>_ attributes from spec plus estimate.
frame is the clean data when learning, or None when the reference is fully specified and no
estimation is needed.
Source code in src/dqmeasure/base.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
get_params
get_params()
Return the constructor parameters, introspected from __init__.
Source code in src/dqmeasure/base.py
156 157 158 159 160 161 162 163 | |
dqmeasure.base.PositionalMeasure
Bases: BaseMeasure
Base class for tier-1 measures with positional units (cells or rows).
A positional unit is a position in the dataframe you can point at and attach a score to. Such measures gain
predict, and score() is its aggregation. Subclasses
implement _measure_units instead of _score.
Measures with non-positional units and tier-2 statistic measures have no per-unit output. They derive from
BaseMeasure directly and are score()-only.
Source code in src/dqmeasure/base.py
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 | |
predict
predict(X)
Evaluate the condition per unit on a (dirty) dataframe.
Returns a series with one entry per input row, holding the per-unit condition result
condition(u) ∈ [0, 1] as a null-preserving float (null = unit out of scope). The return type matches
the backend of X.
Source code in src/dqmeasure/base.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
_measure_units
_measure_units(frame)
Return the per-unit condition results as a series. Must be overridden.
Source code in src/dqmeasure/base.py
203 204 205 | |
_score
_score(frame)
Aggregate the per-unit condition results to X.
Default: the mean ignoring nulls, i.e. the ISO ratio A / B where A sums the condition results
and B counts the units in scope (non-null entries).
Source code in src/dqmeasure/base.py
207 208 209 210 211 212 213 214 215 216 | |
dqmeasure.base.NotResolvedError
Bases: RuntimeError
Raised when a measure is used before its reference is resolved (specified in the constructor or learned via
fit).
Source code in src/dqmeasure/base.py
13 14 15 | |