google / differential-privacy

Google's differential privacy libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C++ Proposal: Return doubles

dasmdasm opened this issue · comments

commented

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 Algorithms 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 Algorithms 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<T> methods to be simple casts, so if you're currently doing GetValue<T>(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.