GroupbyCountQuery.suppress#
from tmlt.analytics import GroupbyCountQuery
- GroupbyCountQuery.suppress(threshold)#
Returns a new query with an added postprocessing thresholding step.
Example
>>> my_private_data.toPandas() A B X 0 0 1 0 1 1 0 1 2 1 2 1 >>> budget = PureDPBudget(float("inf")) >>> sess = Session.from_dataframe( ... privacy_budget=budget, ... source_id="my_private_data", ... dataframe=my_private_data, ... protected_change=AddOneRow(), ... ) >>> # Building a groupby count query and suppressing results < 1 >>> query = ( ... QueryBuilder("my_private_data") ... .groupby(KeySet.from_dict({"A": ["0", "1", "2"]})) ... .count() ... .suppress(1) ... ) >>> # Answering the query with infinite privacy budget >>> answer = sess.evaluate( ... query, ... PureDPBudget(float("inf")) ... ) >>> answer.sort("A").toPandas() A count 0 0 1 1 1 2