google / google/differential-privacy

C++ Proposal: Return doubles

Open
#60 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3.4k
Forks
434
Avg merge
4d 9h
Merged PRs (30d)
9

Description

This is a proposed change to the C++ building blocks library. I'm posting it here to solicit feedback and suggestions before we make a final call on implementing it.

Currently all our `Algorithm`s return their results in the form out `Output` protocol buffers. Most users use our custom utility functions to retrieve the result. `Output` protocol buffers can contain any one of a number of different data types, which are represented as different fields.

We've seen this lead to a lot of confusion. Some `Algorithm`s don't return the same type as their input (e.g. `Count`), and if you try to fetch the wrong type of result you'll get a default value rather than an error. "Why does the algorithm always return 0?" is a frequent question for users of `Count`.

We'd like to stop returning multiple types and return only doubles instead. We'll still use the proto structure (the ability to return more than one double is useful in, e.g. ApproxBounds), but will replace the inner `Value` proto (which can hold multiple types) with a double. We're doing all the math as doubles anyway, so there's no precision loss. If you want your differentially private count to be an integer rather than a double, you can cast it yourself rather than having us do it under the hood. We'll also modify the `GetValue` methods to be simple casts, so if you're currently doing `GetValue(algorithm.PartialResult())` your code will keep working without any changes. If you are handling the `Output` protos yourself, though, this will be a breaking change for you.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.