QueryBuilder.max#
from tmlt.analytics import QueryBuilder
- QueryBuilder.max(column, low, high, name=None)#
Returns a quantile query requesting a maximum value, ready to be evaluated.
Note
If the column being measured contains NaN or null values, a
drop_null_and_nan()
query will be performed first. If the column being measured contains infinite values, adrop_infinity()
query will be performed first.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 quantile query >>> query = ( ... QueryBuilder("my_private_data") ... .max(column="B", low=0, high=5, name="max_B") ... ) >>> # Answering the query with infinite privacy budget >>> answer = sess.evaluate( ... query, ... PureDPBudget(float("inf")) ... ) >>> answer.toPandas() max_B 0 2.331871
- Parameters:
- Return type:
from tmlt.analytics import GroupedQueryBuilder
- GroupedQueryBuilder.max(column, low, high, name=None)#
Returns a Query with a quantile query requesting a maximum value.
Note
If the column being measured contains NaN or null values, a
drop_null_and_nan()
query will be performed first. If the column being measured contains infinite values, adrop_infinity()
query will be performed first.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 quantile query >>> query = ( ... QueryBuilder("my_private_data") ... .groupby(KeySet.from_dict({"A": ["0", "1"]})) ... .max(column="B", low=0, high=5, name="max_B") ... ) >>> # Answering the query with infinite privacy budget >>> answer = sess.evaluate( ... query, ... PureDPBudget(float("inf")) ... ) >>> answer.sort("A").toPandas() A max_B 0 0 2.331871 1 1 2.331871
- Parameters:
- Return type: