SuppressionCount#
from tmlt.tune import SuppressionCount
- class tmlt.tune.SuppressionCount(join_columns, *, name=None, description=None, baseline=None, output=None, grouping_columns=None)#
Bases:
JoinedOutputMetric
Computes the count of values in the baseline output but not in the DP output.
This metric returns the number of values of
join_columns
that appear in the baseline output but not in the DP output (such values are called suppressed).If
grouping_columns
is defined, then the DP output and the baseline output are both grouped by these columns, the suppression count is calculated separately for each group, and the metric returns a DataFrame. Otherwise, the metric returns a single number.In each group (or globally if
grouping_column
isNone
), each combination of values ofjoin_columns
must appear in at most one row of the DP output and the baseline output. Otherwise, the metric returns an error.Example
>>> dp_df = spark.createDataFrame( ... pd.DataFrame( ... { ... "A": ["a1", "a2", "a3", "c"], ... "X": [50, 110, 100, 50] ... } ... ) ... ) >>> dp_outputs = {"O": dp_df} >>> baseline_df = spark.createDataFrame( ... pd.DataFrame( ... { ... "A": ["a1", "a2", "a3", "b"], ... "X": [100, 100, 100, 50] ... } ... ) ... ) >>> baseline_outputs = {"default": {"O": baseline_df}}
>>> metric = SuppressionCount( ... join_columns=["A"] ... ) >>> metric.join_columns ['A'] >>> metric(dp_outputs, baseline_outputs).value 1
- count_suppressed_rows(joined_output, result_column_name)#
Counts the number of suppressed rows given DP and baseline outputs.