Skip to main content

MultiValidate.get_health_score()

Get the health score of all runs together, or of each run or table.

Usage

Source

MultiValidate.get_health_score(by=None)

The health score (see Validate.get_health_score()) is the share of test units that passed, as a percentage from 0 to 100. Here, it’s computed over the steps of all runs, so a run with more test units counts for more. With by=, there’s a score for each run, each table, or each label instead.

Parameters

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

Returns

float | dict[Any, float]
The health score, or a dictionary of scores by run number, table name, or label. A group without steps that can be scored is left out of the dictionary.

Examples

Here are two runs for one table and one run for another:

import pointblank as pb
import polars as pl

def check(a, tbl_name):
    return (
        pb.Validate(data=pl.DataFrame({"a": a}), tbl_name=tbl_name)
        .col_vals_gt(columns="a", value=0)
        .interrogate()
    )

multi = pb.MultiValidate(
    check([1, 2, 3, 4], "orders"),
    check([1, 2, 3, -4], "orders"),
    check([-1, 2], "customers"),
)

multi.get_health_score()
80.0

Eight of the ten test units passed. By table, the score is the share over the runs of each table:

multi.get_health_score(by="tbl_name")
{'orders': 87.5, 'customers': 50.0}

The orders table passed seven of its eight test units, and customers one of two.