Skip to main content

MultiValidate.get_dimension_scores()

Get the score of each data quality dimension over all runs, or for each run or table.

Usage

Source

MultiValidate.get_dimension_scores(by=None)

Each step of a validation has a data quality dimension (like "completeness" or "validity"), and a dimension’s score is the share of its test units that passed, as a percentage from 0 to 100 (see Validate.get_dimension_scores()). Here, the scores are computed over the steps of all runs, so a run with more test units counts for more. With by=, there are scores for each run, each table, or each label instead, and by="run" gives the scores of each run, to follow how each dimension changed from run to run.

Parameters

by: Literal["run", "tbl_name", "label"] | None = None
How to group the runs: None (the default) for the scores over all runs, "run" for the scores of each run (by run number), "tbl_name" for the scores of each table name (over all runs of the table), or "label" for the scores of each label.

Returns

dict[Any, Any]
A dictionary of the score of each dimension, or, with by=, a dictionary of such dictionaries by run number, table name, or label. A group without steps that can be scored is left out.

Examples

Here are three nightly runs of a validation of an orders table, with a check for missing emails (completeness) and a check that the amounts are positive (validity):

import pointblank as pb
import polars as pl

def check(n_missing, n_negative):
    orders = pl.DataFrame(
        {
            "email": [None] * n_missing + ["a@example.com"] * (100 - n_missing),
            "amount": [-1.0] * n_negative + [20.0] * (100 - n_negative),
        }
    )
    return (
        pb.Validate(data=orders, tbl_name="orders")
        .col_vals_not_null(columns="email")
        .col_vals_gt(columns="amount", value=0)
        .interrogate()
    )

multi = pb.MultiValidate(check(1, 0), check(2, 1), check(1, 6))

multi.get_dimension_scores(by="run")
{1: {'completeness': 99.0, 'validity': 100.0},
 2: {'completeness': 98.0, 'validity': 99.0},
 3: {'completeness': 99.0, 'validity': 94.0}}

Completeness stays at 98% to 99% in every run, while validity drops to 94% in the third run, when six of the amounts are negative. Over all the runs together, the scores are the shares of the test units of all three:

multi.get_dimension_scores()
{'completeness': 98.67, 'validity': 97.67}

For a chart of the scores over the runs, use get_scorecard(), or get_dataframe(shape="dimensions") for a table of them.