这是indexloc提供的服务,不要输入任何密码
Skip to content

Using Laplace noise on a RhoZCDP session fails in some cases #99

@TedTed

Description

@TedTed

Basic checks

  • I can confirm that there isn't a seperate issue filed related to this bug.

Reproducible Example

session_budget = RhoZCDPBudget(rho=float('inf'))
session = Session.from_dataframe(
    session_budget,
    "checkouts",
    checkouts_df,
    protected_change=AddMaxRowsInMaxGroups("author", 5, 5),
)
keyset = KeySet.from_dataframe(
    books_df.select("title", "author", "isbn"),
)
query = (QueryBuilder("checkouts")
    .groupby(keyset)
    .sum("publication_date", low=0, high=3000, mechanism=SumMechanism.LAPLACE)
)
budget = RhoZCDPBudget(1)
print(session._noise_info(query, budget))

Bug Description

The above code fails with:

UnsupportedMetricError: Input metric does not have the expected inner metric. Maybe IfGroupedBy(column='author', inner_metric=SumOf(inner_metric=SymmetricDifference()))?

The same happens if you have a table with privacy IDs and use both MaxGroupsPerID and MaxRowsPerGroupPerID with Laplace noise:

session_budget = RhoZCDPBudget(rho=float('inf'))
session = Session.from_dataframe(
    session_budget,
    "checkouts",
    checkouts_df,
    protected_change=AddRowsWithID("member_id"),
)
query = (QueryBuilder("checkouts")
    .enforce(MaxGroupsPerID("author", 5))
    .enforce(MaxRowsPerGroupPerID("author", 5))
    .groupby(keyset)
    .sum("publication_date", low=0, high=3000, mechanism=SumMechanism.LAPLACE)
)
budget = RhoZCDPBudget(1)
print(session._noise_info(query, budget))
UnsupportedMetricError: Input metric does not have the expected inner metric. Maybe IfGroupedBy(column='author', inner_metric=SumOf(inner_metric=SymmetricDifference()))?

Expected Behavior

This should not fail.

Version Info

main

Platform

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions