Secure Data Disclosure: Client side
This notebook showcases how researcher could use the Secure Data Disclosure system. It explains the different functionnalities provided by the lomas_client library to interact with the secure server.
The secure data are never visible by researchers. They can only access to differentially private responses via queries to the server.
Each user has access to one or multiple projects and for each dataset has a limited budget with \(\epsilon\) and \(\delta\) values.
[ ]:
from IPython.display import Image
Image(filename="images/image_demo_client.png", width=800)
We will use the Synthetic Swiss Income Dataset to demonstrate the how to use the library lomas_client with polars queries.
Step 1: Install the library
It can be installed via the pip command:
[ ]:
import sys
import os
sys.path.append(os.path.abspath(os.path.join('..')))
# !pip install lomas_client
[ ]:
from lomas_client import Client
import numpy as np
import opendp.prelude as dp
/home/aymond/work/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp_logger/deserialize.py:7: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
Step 2: Initialise the client
Once the library is installed, a Client object must be created. It is responsible for sending sending requests to the server and processing responses in the local environment. It enables a seamless interaction with the server.
The client needs a few parameters to be created. Usually, these would be set in the environment by the system administrator and be transparent to lomas users. In this instance, the following code snippet sets a few of these parameters that are specific to this notebook.
[ ]:
# The following would usually be set in the environment by a system administrator
# and be tranparent to lomas users.
# Uncomment them if you are running against a Kubernetes deployment.
# They have already been set for you if you are running locally within a devenv or the Jupyter lab set up by Docker compose.
import os
# os.environ["LOMAS_CLIENT_APP_URL"] = "https://lomas.example.com:443"
# os.environ["LOMAS_CLIENT_OIDC_DISCOVERY_URL"] = "https://dex.example.com:443/.well-known/openid-configuration"
# os.environ["LOMAS_CLIENT_TELEMETRY__ENABLED"] = "false"
# os.environ["LOMAS_CLIENT_TELEMETRY__COLLECTOR_ENDPOINT"] = "http://otel.example.com:445"
# os.environ["LOMAS_CLIENT_TELEMETRY__COLLECTOR_INSECURE"] = "true"
# os.environ["LOMAS_CLIENT_TELEMETRY__SERVICE_ID"] = "my-app-client"
# os.environ["LOMAS_CLIENT_REALM"] = "lomas"
# We set these ones because they are specific to this notebook.
os.environ["LOMAS_CLIENT_USER_NAME"] = "dr.fso@example.com"
os.environ["LOMAS_CLIENT_USER_PASSWORD"] = "dr.fso"
os.environ["LOMAS_CLIENT_DATASET_NAME"] = "FSO_INCOME_SYNTHETIC"
# Note that all client settings can also be passed as keyword arguments to the Client constructor.
# eg. client = Client(user_name = "Dr.Antartica") takes precedence over setting the "LOMAS_CLIENT_USER_NAME"
# environment variable.
[ ]:
client = Client()
[15:26:02] WARNING Keycloak or Lomas service configured without TLS -> using oauthlib insecure http_client.py:31 transport
Step 3: Metadata and dummy dataset
Getting dataset metadata
Dr. FSO has never seen the data and as a first step to understand what is available to her, she would like to check the metadata of the dataset. Therefore, she just needs to call the get_dataset_metadata() function of the client. As this is public information, this does not cost any budget.
This function returns metadata information in a format based on SmartnoiseSQL dictionary format, where among other, there is information about all the available columns, their type, bound values (see Smartnoise page for more details). Any metadata is required for Smartnoise-SQL is also required here and additional information such that the different categories in a string type column column can be added.
[ ]:
income_metadata = client.get_dataset_metadata()
income_metadata
DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'get_dataset_metadata' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC'}.
{'max_ids': 1,
'rows': 2032543,
'row_privacy': True,
'censor_dims': True,
'clamp_counts': True,
'clamp_columns': True,
'use_dpsu': False,
'columns': {'region': {'private_id': False,
'nullable_proportion': 0.0,
'max_partition_length': 474690,
'max_influenced_partitions': None,
'max_partition_contributions': None,
'type': 'int',
'precision': 32,
'cardinality': 7,
'categories': [1, 2, 3, 4, 5, 6, 7]},
'eco_branch': {'private_id': False,
'nullable_proportion': 0.0,
'max_partition_length': 34330,
'max_influenced_partitions': None,
'max_partition_contributions': None,
'type': 'int',
'precision': 32,
'cardinality': 72,
'categories': [8,
10,
11,
13,
14,
15,
16,
17,
18,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
35,
37,
38,
41,
42,
43,
45,
46,
47,
49,
50,
52,
53,
55,
56,
58,
59,
60,
61,
62,
63,
64,
65,
66,
68,
69,
70,
71,
72,
73,
74,
75,
77,
78,
79,
80,
81,
82,
85,
86,
87,
88,
90,
91,
92,
93,
94,
95,
96]},
'profession': {'private_id': False,
'nullable_proportion': 0.0,
'max_partition_length': 78857,
'max_influenced_partitions': None,
'max_partition_contributions': None,
'type': 'int',
'precision': 32,
'cardinality': 28,
'categories': [10,
21,
22,
23,
24,
25,
31,
32,
33,
34,
41,
42,
43,
51,
52,
53,
61,
62,
71,
72,
73,
74,
81,
83,
91,
92,
93,
94]},
'education': {'private_id': False,
'nullable_proportion': 0.0,
'max_partition_length': 268697,
'max_influenced_partitions': None,
'max_partition_contributions': None,
'type': 'int',
'precision': 32,
'cardinality': 8,
'categories': [1, 2, 3, 4, 5, 6, 7, 8]},
'age': {'private_id': False,
'nullable_proportion': 0.0,
'max_partition_length': 53952,
'max_influenced_partitions': None,
'max_partition_contributions': None,
'type': 'int',
'precision': 32,
'lower': 0,
'upper': 120},
'sex': {'private_id': False,
'nullable_proportion': 0.0,
'max_partition_length': 1397824,
'max_influenced_partitions': None,
'max_partition_contributions': None,
'type': 'int',
'precision': 32,
'cardinality': 2,
'categories': [0, 1]},
'income': {'private_id': False,
'nullable_proportion': 0.0,
'max_partition_length': None,
'max_influenced_partitions': None,
'max_partition_contributions': None,
'type': 'float',
'precision': 64,
'lower': 1000.0,
'upper': 100000.0,
'int_with_nulls': False}}}
Get a dummy dataset
Now, that she has seen and understood the metadata, she wants to get an even better understanding of the dataset (but is still not able to see it). A solution to have an idea of what the dataset looks like it to create a dummy dataset.
Based on the public metadata of the dataset, a random dataframe can be created created. By default, there will be 100 rows and the seed is set to 42 to ensure reproducibility, but these 2 variables can be changed to obtain different dummy datasets. Getting a dummy dataset does not affect the budget as there is no differential privacy here. It is not a synthetic dataset and all that could be learn here is already present in the public metadata (it is created randomly on the fly based on the metadata).
Dr. FSO first create a dummy dataset with 200 rows and chooses a seed of 0.
[ ]:
NB_ROWS = 200
SEED = 0
[ ]:
dummy_lf = client.get_dummy_dataset(nb_rows=NB_ROWS, seed=SEED, lazy=True)
dummy_lf.collect()
DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'get_dummy_dataset' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'dummy_nb_rows': 200, 'dummy_seed': 0}.
Datetime type mismatch: The Polars LazyFrame currently uses 'str' for datetime fields, which may not match the expected metadata types. This is a temporary workaround and will be resolved in a future release (>=0.13).
| region | eco_branch | profession | education | age | sex | income |
|---|---|---|---|---|---|---|
| i32 | i32 | i32 | i32 | i32 | i32 | f64 |
| 6 | 27 | 94 | 5 | 111 | 1 | 1611.50605 |
| 5 | 52 | 33 | 8 | 24 | 0 | 72395.412826 |
| 4 | 35 | 81 | 6 | 41 | 0 | 67983.841861 |
| 2 | 27 | 25 | 5 | 113 | 1 | 66033.243543 |
| 3 | 88 | 41 | 4 | 119 | 0 | 69054.085229 |
| … | … | … | … | … | … | … |
| 7 | 77 | 93 | 1 | 119 | 0 | 37851.861395 |
| 3 | 74 | 33 | 7 | 21 | 0 | 21927.13039 |
| 7 | 95 | 72 | 4 | 51 | 1 | 41515.893667 |
| 3 | 58 | 34 | 8 | 25 | 1 | 44467.752841 |
| 6 | 62 | 83 | 4 | 102 | 0 | 99534.680535 |
[ ]:
test = client.get_dummy_dataset(nb_rows=NB_ROWS, seed = SEED)
DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'get_dummy_dataset' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'dummy_nb_rows': 200, 'dummy_seed': 0}.
[ ]:
test.dtypes
region int32
eco_branch int32
profession int32
education int32
age int32
sex int32
income float64
dtype: object
Step 4: Prepare the pipeline
It is necessary to prepare the pipeline before sending the query to the client.
[ ]:
import polars as pl
a. mean
[ ]:
# Income bounds
income_lower_bound, income_upper_bound = income_metadata["columns"]["income"]["lower"], income_metadata["columns"]["income"]["upper"]
[ ]:
plan = dummy_lf.select(
pl.col("income").dp.mean(bounds=(income_lower_bound, income_upper_bound), scale=(100_000,1)
))
Step 5: Send the queries
a. Dummy queries
[ ]:
res = client.opendp.query(plan, dummy = False, nb_rows = NB_ROWS, seed=SEED)
print(res.result.value)
/home/aymond/work/lomas/lomas/client/lomas_client/libraries/opendp.py:59: UserWarning: 'json' serialization format of LazyFrame is deprecated
body_json["opendp_json"] = opendp_pipeline.serialize(format="json")
DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"Select":{"expr":[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum" :{"Function":{"input":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Lit eral":{"Float":100000.0}}],"function":{"Clip":{"has_min":true,"has_max":true} },"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":true ,"flags":"ALLOW_GROUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Int":100000 }}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/sta te/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noi se","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"","che ck_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"F unction":{"input":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"N ull"},{"Literal":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/wor k/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/open dp.abi3.so","symbol":"noise","kwargs":[]}},"options":{"collect_groups":"Eleme ntWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}]," input":{"DataFrameScan":{"df":{"columns":[{"name":"region","datatype":"Int32" ,"bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5,4,4,7,2,6,5,1, 3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7,3,5,7,5,6,5,5 ,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2,5,5,1,1,3,6,3, 6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7,2,6,7,1,3,5,1 ,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2,6,6,5,7,7,2,1, 1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_branch","datatype" :"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94,30,46,58,68,4 7,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,30,14,53,82,64, 14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31,79,62,85,59,77 ,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85,93,21,80,45,1 3,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71,65,92,78,20,1 1,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87,22,55,65,37,6 1,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,28,60,21,17,69, 13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56,95,11,61,49,8, 59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bit_settings":"" ,"values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,51,53,73,33,24, 72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32,23,61,22,23,21 ,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31,22,21,61,32,2 5,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,51,92,91,21,53, 83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81,93,81,72,34,61 ,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23,41,72,33,81,1 0,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,72,92,33,32,74, 61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33,72,34,83]},{"n ame":"education","datatype":"Int32","bit_settings":"","values":[5,8,6,5,4,1,1 ,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2,8,7,2,5,3,4,5, 8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6,2,7,5,4,1,2,6 ,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4,8,3,3,3,2,7,7, 3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1,3,3,6,5,7,4,8 ,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2,5,6,8,1,7,4,8, 4]},{"name":"age","datatype":"Int32","bit_settings":"","values":[111,24,41,11 3,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,73,86,103,118,6 4,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94,22,20,26,69,60 ,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62,70,56,74,34,5 5,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87,31,38,18,54,8 6,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112,108,6,5,89,23, 22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23,55,8,89,93,85 ,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72,67,6,46,37,75, 38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51,25,102]},{"nam e":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1,0,1,0,0,1,0,0 ,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1, 0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1 ,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0, 1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,1,1,1,0 ,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0]},{"na me":"income","datatype":"Float64","bit_settings":"","values":[1611.5060496435 385,72395.41282556736,67983.84186121338,66033.24354264204,69054.08522901933,5 9040.15689082983,12412.616354772928,67251.16851562508,1653.2538542897753,1910 1.445016515365,42666.962114339476,38458.56866045681,12777.551079037243,43268. 80279994885,62738.1071187109,38368.87972171097,71141.4488453842,23861.2874424 49426,15238.701954821421,75141.08460436016,67204.08484644344,43507.6986361814 9,14539.961196953593,66704.69019356873,75245.61924269522,17230.322667574772,6 9240.87195608823,36208.071551796806,91596.74287407863,75402.42907323074,28099 .385853106236,93864.6056441426,3498.0428543588146,19297.577433361428,24948.39 4143566366,73475.92825361855,53090.635019660534,46973.16538151256,23030.80053 844617,75890.2439256015,12593.534397107696,25486.78082008073,80829.6716379226 4,45653.698982143105,87804.95592336128,60564.74631899335,79164.92004887982,19 552.924019982987,32305.964899970208,38293.89912826758,49925.72138232143,47774 .23542327551,82424.14960066472,18145.862659292216,85297.10554833556,89015.583 12019755,8476.384520548665,1929.6465924970514,29982.54430913398,40673.7320083 94865,97074.4912681022,8069.4511082947965,78349.22125760184,48067.07040518514 ,13857.478952540328,37241.9505583952,38709.23930101016,25113.67752991244,3014 2.011994864097,42571.96428905492,96263.87809656067,46427.19632917672,95063.36 619911942,4022.6750867719975,7544.915598748731,3753.7747135296563,66928.51918 797307,22803.036420265722,58065.597948011804,79741.24742493703,33849.57794719 187,25322.07177819959,72815.45012691691,48113.88153665747,15771.80445888076,9 657.066629499175,73979.58261280264,86180.82115301354,89145.84575006778,51498. 811740985664,16192.002070100069,23340.083815569324,45898.86501307257,85333.87 998695576,65369.5444646916,28146.488738379096,75837.92551416076,44108.5773567 4041,98293.63057422236,43443.98661099572,83882.43854145108,2439.6215047409187 ,72103.90524422366,40449.365835706296,50401.92149099364,20683.754236192304,93 021.6398589719,20764.856324737557,56597.0837034392,60137.21673410351,85985.89 930265165,47199.98742887538,83159.23683493392,52865.75985846356,95677.1312828 3927,71944.1755394946,91298.4208374175,94293.6926985568,80422.36947548781,131 14.387112955168,13318.431225200588,62007.93327940807,27849.461593434626,39130 .08009840097,18208.98948573911,76454.99464297837,85595.27266090916,14147.6580 79364532,52166.65873963943,40106.28006976111,79211.51648009919,47034.23771737 224,73350.09586566911,57044.28378136128,97846.56328793522,42543.67451884676,9 8779.41609634721,42128.41974602035,19084.19648769007,78426.02498330359,27900. 181232962725,57009.718352670534,64955.492909241344,20768.048557147977,4406.28 6632124431,98716.3010124358,81921.62416471273,13246.820240988227,84948.973582 19269,26554.889973409285,25481.18929844428,77489.01868793309,75978.8392233550 8,84749.77704927203,14528.548780779218,75011.03134728348,47512.56355304741,33 262.45740461117,73695.98487734183,84669.16501486194,32923.614998754085,16326. 344109385736,99176.78711505492,91999.80893455193,29694.2738317877,81627.01649 196685,9879.628999422268,91342.04483791182,77690.57129123538,20489.4483612921 3,30273.037452772223,59959.93062925894,36220.008758907905,73887.147778798,596 43.92406505537,21495.836604230975,61400.84147851358,2391.8494297422735,12063. 033715001378,16959.573893558514,36014.09348992197,2179.0640957607648,93060.84 484270416,24711.386591753875,27793.216494060624,38188.59024482016,94133.13285 711575,35830.11358565577,43682.15276425513,30552.21997774239,97648.2584701275 8,37120.86526185778,9270.204677973548,66140.25702966859,71943.88715083216,378 51.86139530687,21927.13038953886,41515.893667174234,44467.75284072402,99534.6 8053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch":"Int32","pro fession":"Int32","education":"Int32","age":"Int32","sex":"Int32","income":"Fl oat64"}}}},"options":{"run_parallel":true,"duplicate_check":true,"should_broa dcast":true}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
shape: (1, 1)
┌─────────────┐
│ income │
│ --- │
│ f64 │
╞═════════════╡
│ 7052.583325 │
└─────────────┘
By default, the client will use a laplace mechanism. Note that Dr. FSO can also use a Gaussian mechanism if wanted.
[ ]:
res = client.opendp.query(plan, mechanism = "gaussian", fixed_delta = 1.0, dummy = True, nb_rows = NB_ROWS, seed=SEED)
print(res.result.value)
[15:26:05] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'dummy_opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'dummy_nb_rows': 200, 'dummy_seed': 0, 'opendp_json': '{"Select":{"expr":[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum" :{"Function":{"input":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Lit eral":{"Float":100000.0}}],"function":{"Clip":{"has_min":true,"has_max":true} },"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":true ,"flags":"ALLOW_GROUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Int":100000 }}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/sta te/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noi se","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"","che ck_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"F unction":{"input":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"N ull"},{"Literal":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/wor k/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/open dp.abi3.so","symbol":"noise","kwargs":[]}},"options":{"collect_groups":"Eleme ntWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}]," input":{"DataFrameScan":{"df":{"columns":[{"name":"region","datatype":"Int32" ,"bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5,4,4,7,2,6,5,1, 3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7,3,5,7,5,6,5,5 ,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2,5,5,1,1,3,6,3, 6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7,2,6,7,1,3,5,1 ,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2,6,6,5,7,7,2,1, 1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_branch","datatype" :"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94,30,46,58,68,4 7,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,30,14,53,82,64, 14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31,79,62,85,59,77 ,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85,93,21,80,45,1 3,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71,65,92,78,20,1 1,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87,22,55,65,37,6 1,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,28,60,21,17,69, 13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56,95,11,61,49,8, 59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bit_settings":"" ,"values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,51,53,73,33,24, 72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32,23,61,22,23,21 ,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31,22,21,61,32,2 5,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,51,92,91,21,53, 83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81,93,81,72,34,61 ,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23,41,72,33,81,1 0,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,72,92,33,32,74, 61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33,72,34,83]},{"n ame":"education","datatype":"Int32","bit_settings":"","values":[5,8,6,5,4,1,1 ,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2,8,7,2,5,3,4,5, 8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6,2,7,5,4,1,2,6 ,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4,8,3,3,3,2,7,7, 3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1,3,3,6,5,7,4,8 ,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2,5,6,8,1,7,4,8, 4]},{"name":"age","datatype":"Int32","bit_settings":"","values":[111,24,41,11 3,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,73,86,103,118,6 4,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94,22,20,26,69,60 ,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62,70,56,74,34,5 5,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87,31,38,18,54,8 6,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112,108,6,5,89,23, 22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23,55,8,89,93,85 ,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72,67,6,46,37,75, 38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51,25,102]},{"nam e":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1,0,1,0,0,1,0,0 ,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1, 0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1 ,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0, 1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,1,1,1,0 ,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0]},{"na me":"income","datatype":"Float64","bit_settings":"","values":[1611.5060496435 385,72395.41282556736,67983.84186121338,66033.24354264204,69054.08522901933,5 9040.15689082983,12412.616354772928,67251.16851562508,1653.2538542897753,1910 1.445016515365,42666.962114339476,38458.56866045681,12777.551079037243,43268. 80279994885,62738.1071187109,38368.87972171097,71141.4488453842,23861.2874424 49426,15238.701954821421,75141.08460436016,67204.08484644344,43507.6986361814 9,14539.961196953593,66704.69019356873,75245.61924269522,17230.322667574772,6 9240.87195608823,36208.071551796806,91596.74287407863,75402.42907323074,28099 .385853106236,93864.6056441426,3498.0428543588146,19297.577433361428,24948.39 4143566366,73475.92825361855,53090.635019660534,46973.16538151256,23030.80053 844617,75890.2439256015,12593.534397107696,25486.78082008073,80829.6716379226 4,45653.698982143105,87804.95592336128,60564.74631899335,79164.92004887982,19 552.924019982987,32305.964899970208,38293.89912826758,49925.72138232143,47774 .23542327551,82424.14960066472,18145.862659292216,85297.10554833556,89015.583 12019755,8476.384520548665,1929.6465924970514,29982.54430913398,40673.7320083 94865,97074.4912681022,8069.4511082947965,78349.22125760184,48067.07040518514 ,13857.478952540328,37241.9505583952,38709.23930101016,25113.67752991244,3014 2.011994864097,42571.96428905492,96263.87809656067,46427.19632917672,95063.36 619911942,4022.6750867719975,7544.915598748731,3753.7747135296563,66928.51918 797307,22803.036420265722,58065.597948011804,79741.24742493703,33849.57794719 187,25322.07177819959,72815.45012691691,48113.88153665747,15771.80445888076,9 657.066629499175,73979.58261280264,86180.82115301354,89145.84575006778,51498. 811740985664,16192.002070100069,23340.083815569324,45898.86501307257,85333.87 998695576,65369.5444646916,28146.488738379096,75837.92551416076,44108.5773567 4041,98293.63057422236,43443.98661099572,83882.43854145108,2439.6215047409187 ,72103.90524422366,40449.365835706296,50401.92149099364,20683.754236192304,93 021.6398589719,20764.856324737557,56597.0837034392,60137.21673410351,85985.89 930265165,47199.98742887538,83159.23683493392,52865.75985846356,95677.1312828 3927,71944.1755394946,91298.4208374175,94293.6926985568,80422.36947548781,131 14.387112955168,13318.431225200588,62007.93327940807,27849.461593434626,39130 .08009840097,18208.98948573911,76454.99464297837,85595.27266090916,14147.6580 79364532,52166.65873963943,40106.28006976111,79211.51648009919,47034.23771737 224,73350.09586566911,57044.28378136128,97846.56328793522,42543.67451884676,9 8779.41609634721,42128.41974602035,19084.19648769007,78426.02498330359,27900. 181232962725,57009.718352670534,64955.492909241344,20768.048557147977,4406.28 6632124431,98716.3010124358,81921.62416471273,13246.820240988227,84948.973582 19269,26554.889973409285,25481.18929844428,77489.01868793309,75978.8392233550 8,84749.77704927203,14528.548780779218,75011.03134728348,47512.56355304741,33 262.45740461117,73695.98487734183,84669.16501486194,32923.614998754085,16326. 344109385736,99176.78711505492,91999.80893455193,29694.2738317877,81627.01649 196685,9879.628999422268,91342.04483791182,77690.57129123538,20489.4483612921 3,30273.037452772223,59959.93062925894,36220.008758907905,73887.147778798,596 43.92406505537,21495.836604230975,61400.84147851358,2391.8494297422735,12063. 033715001378,16959.573893558514,36014.09348992197,2179.0640957607648,93060.84 484270416,24711.386591753875,27793.216494060624,38188.59024482016,94133.13285 711575,35830.11358565577,43682.15276425513,30552.21997774239,97648.2584701275 8,37120.86526185778,9270.204677973548,66140.25702966859,71943.88715083216,378 51.86139530687,21927.13038953886,41515.893667174234,44467.75284072402,99534.6 8053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch":"Int32","pro fession":"Int32","education":"Int32","age":"Int32","sex":"Int32","income":"Fl oat64"}}}},"options":{"run_parallel":true,"duplicate_check":true,"should_broa dcast":true}}}', 'fixed_delta': 1.0, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.GAUSSIAN: 'gaussian'>}.
shape: (1, 1)
┌──────────────┐
│ income │
│ --- │
│ f64 │
╞══════════════╡
│ 49980.429526 │
└──────────────┘
b. budget estimation
[ ]:
res = client.opendp.cost(plan, mechanism = "laplace")
print(res)
[15:26:07] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'estimate_opendp_cost' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"Select":{"expr":[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum" :{"Function":{"input":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Lit eral":{"Float":100000.0}}],"function":{"Clip":{"has_min":true,"has_max":true} },"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":true ,"flags":"ALLOW_GROUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Int":100000 }}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/sta te/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noi se","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"","che ck_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"F unction":{"input":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"N ull"},{"Literal":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/wor k/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/open dp.abi3.so","symbol":"noise","kwargs":[]}},"options":{"collect_groups":"Eleme ntWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}]," input":{"DataFrameScan":{"df":{"columns":[{"name":"region","datatype":"Int32" ,"bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5,4,4,7,2,6,5,1, 3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7,3,5,7,5,6,5,5 ,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2,5,5,1,1,3,6,3, 6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7,2,6,7,1,3,5,1 ,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2,6,6,5,7,7,2,1, 1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_branch","datatype" :"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94,30,46,58,68,4 7,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,30,14,53,82,64, 14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31,79,62,85,59,77 ,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85,93,21,80,45,1 3,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71,65,92,78,20,1 1,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87,22,55,65,37,6 1,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,28,60,21,17,69, 13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56,95,11,61,49,8, 59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bit_settings":"" ,"values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,51,53,73,33,24, 72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32,23,61,22,23,21 ,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31,22,21,61,32,2 5,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,51,92,91,21,53, 83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81,93,81,72,34,61 ,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23,41,72,33,81,1 0,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,72,92,33,32,74, 61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33,72,34,83]},{"n ame":"education","datatype":"Int32","bit_settings":"","values":[5,8,6,5,4,1,1 ,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2,8,7,2,5,3,4,5, 8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6,2,7,5,4,1,2,6 ,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4,8,3,3,3,2,7,7, 3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1,3,3,6,5,7,4,8 ,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2,5,6,8,1,7,4,8, 4]},{"name":"age","datatype":"Int32","bit_settings":"","values":[111,24,41,11 3,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,73,86,103,118,6 4,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94,22,20,26,69,60 ,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62,70,56,74,34,5 5,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87,31,38,18,54,8 6,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112,108,6,5,89,23, 22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23,55,8,89,93,85 ,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72,67,6,46,37,75, 38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51,25,102]},{"nam e":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1,0,1,0,0,1,0,0 ,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1, 0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1 ,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0, 1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,1,1,1,0 ,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0]},{"na me":"income","datatype":"Float64","bit_settings":"","values":[1611.5060496435 385,72395.41282556736,67983.84186121338,66033.24354264204,69054.08522901933,5 9040.15689082983,12412.616354772928,67251.16851562508,1653.2538542897753,1910 1.445016515365,42666.962114339476,38458.56866045681,12777.551079037243,43268. 80279994885,62738.1071187109,38368.87972171097,71141.4488453842,23861.2874424 49426,15238.701954821421,75141.08460436016,67204.08484644344,43507.6986361814 9,14539.961196953593,66704.69019356873,75245.61924269522,17230.322667574772,6 9240.87195608823,36208.071551796806,91596.74287407863,75402.42907323074,28099 .385853106236,93864.6056441426,3498.0428543588146,19297.577433361428,24948.39 4143566366,73475.92825361855,53090.635019660534,46973.16538151256,23030.80053 844617,75890.2439256015,12593.534397107696,25486.78082008073,80829.6716379226 4,45653.698982143105,87804.95592336128,60564.74631899335,79164.92004887982,19 552.924019982987,32305.964899970208,38293.89912826758,49925.72138232143,47774 .23542327551,82424.14960066472,18145.862659292216,85297.10554833556,89015.583 12019755,8476.384520548665,1929.6465924970514,29982.54430913398,40673.7320083 94865,97074.4912681022,8069.4511082947965,78349.22125760184,48067.07040518514 ,13857.478952540328,37241.9505583952,38709.23930101016,25113.67752991244,3014 2.011994864097,42571.96428905492,96263.87809656067,46427.19632917672,95063.36 619911942,4022.6750867719975,7544.915598748731,3753.7747135296563,66928.51918 797307,22803.036420265722,58065.597948011804,79741.24742493703,33849.57794719 187,25322.07177819959,72815.45012691691,48113.88153665747,15771.80445888076,9 657.066629499175,73979.58261280264,86180.82115301354,89145.84575006778,51498. 811740985664,16192.002070100069,23340.083815569324,45898.86501307257,85333.87 998695576,65369.5444646916,28146.488738379096,75837.92551416076,44108.5773567 4041,98293.63057422236,43443.98661099572,83882.43854145108,2439.6215047409187 ,72103.90524422366,40449.365835706296,50401.92149099364,20683.754236192304,93 021.6398589719,20764.856324737557,56597.0837034392,60137.21673410351,85985.89 930265165,47199.98742887538,83159.23683493392,52865.75985846356,95677.1312828 3927,71944.1755394946,91298.4208374175,94293.6926985568,80422.36947548781,131 14.387112955168,13318.431225200588,62007.93327940807,27849.461593434626,39130 .08009840097,18208.98948573911,76454.99464297837,85595.27266090916,14147.6580 79364532,52166.65873963943,40106.28006976111,79211.51648009919,47034.23771737 224,73350.09586566911,57044.28378136128,97846.56328793522,42543.67451884676,9 8779.41609634721,42128.41974602035,19084.19648769007,78426.02498330359,27900. 181232962725,57009.718352670534,64955.492909241344,20768.048557147977,4406.28 6632124431,98716.3010124358,81921.62416471273,13246.820240988227,84948.973582 19269,26554.889973409285,25481.18929844428,77489.01868793309,75978.8392233550 8,84749.77704927203,14528.548780779218,75011.03134728348,47512.56355304741,33 262.45740461117,73695.98487734183,84669.16501486194,32923.614998754085,16326. 344109385736,99176.78711505492,91999.80893455193,29694.2738317877,81627.01649 196685,9879.628999422268,91342.04483791182,77690.57129123538,20489.4483612921 3,30273.037452772223,59959.93062925894,36220.008758907905,73887.147778798,596 43.92406505537,21495.836604230975,61400.84147851358,2391.8494297422735,12063. 033715001378,16959.573893558514,36014.09348992197,2179.0640957607648,93060.84 484270416,24711.386591753875,27793.216494060624,38188.59024482016,94133.13285 711575,35830.11358565577,43682.15276425513,30552.21997774239,97648.2584701275 8,37120.86526185778,9270.204677973548,66140.25702966859,71943.88715083216,378 51.86139530687,21927.13038953886,41515.893667174234,44467.75284072402,99534.6 8053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch":"Int32","pro fession":"Int32","education":"Int32","age":"Int32","sex":"Int32","income":"Fl oat64"}}}},"options":{"run_parallel":true,"duplicate_check":true,"should_broa dcast":true}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
epsilon=2.0018346351313037 delta=0.0
[ ]:
res = client.opendp.cost(plan, mechanism = "gaussian", fixed_delta = 0.001)
print(res)
[15:26:08] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'estimate_opendp_cost' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"Select":{"expr":[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum" :{"Function":{"input":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Lit eral":{"Float":100000.0}}],"function":{"Clip":{"has_min":true,"has_max":true} },"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":true ,"flags":"ALLOW_GROUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Int":100000 }}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/sta te/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noi se","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"","che ck_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"F unction":{"input":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"N ull"},{"Literal":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/wor k/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/open dp.abi3.so","symbol":"noise","kwargs":[]}},"options":{"collect_groups":"Eleme ntWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}]," input":{"DataFrameScan":{"df":{"columns":[{"name":"region","datatype":"Int32" ,"bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5,4,4,7,2,6,5,1, 3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7,3,5,7,5,6,5,5 ,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2,5,5,1,1,3,6,3, 6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7,2,6,7,1,3,5,1 ,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2,6,6,5,7,7,2,1, 1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_branch","datatype" :"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94,30,46,58,68,4 7,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,30,14,53,82,64, 14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31,79,62,85,59,77 ,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85,93,21,80,45,1 3,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71,65,92,78,20,1 1,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87,22,55,65,37,6 1,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,28,60,21,17,69, 13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56,95,11,61,49,8, 59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bit_settings":"" ,"values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,51,53,73,33,24, 72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32,23,61,22,23,21 ,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31,22,21,61,32,2 5,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,51,92,91,21,53, 83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81,93,81,72,34,61 ,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23,41,72,33,81,1 0,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,72,92,33,32,74, 61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33,72,34,83]},{"n ame":"education","datatype":"Int32","bit_settings":"","values":[5,8,6,5,4,1,1 ,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2,8,7,2,5,3,4,5, 8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6,2,7,5,4,1,2,6 ,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4,8,3,3,3,2,7,7, 3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1,3,3,6,5,7,4,8 ,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2,5,6,8,1,7,4,8, 4]},{"name":"age","datatype":"Int32","bit_settings":"","values":[111,24,41,11 3,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,73,86,103,118,6 4,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94,22,20,26,69,60 ,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62,70,56,74,34,5 5,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87,31,38,18,54,8 6,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112,108,6,5,89,23, 22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23,55,8,89,93,85 ,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72,67,6,46,37,75, 38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51,25,102]},{"nam e":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1,0,1,0,0,1,0,0 ,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1, 0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1 ,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0, 1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,1,1,1,0 ,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0]},{"na me":"income","datatype":"Float64","bit_settings":"","values":[1611.5060496435 385,72395.41282556736,67983.84186121338,66033.24354264204,69054.08522901933,5 9040.15689082983,12412.616354772928,67251.16851562508,1653.2538542897753,1910 1.445016515365,42666.962114339476,38458.56866045681,12777.551079037243,43268. 80279994885,62738.1071187109,38368.87972171097,71141.4488453842,23861.2874424 49426,15238.701954821421,75141.08460436016,67204.08484644344,43507.6986361814 9,14539.961196953593,66704.69019356873,75245.61924269522,17230.322667574772,6 9240.87195608823,36208.071551796806,91596.74287407863,75402.42907323074,28099 .385853106236,93864.6056441426,3498.0428543588146,19297.577433361428,24948.39 4143566366,73475.92825361855,53090.635019660534,46973.16538151256,23030.80053 844617,75890.2439256015,12593.534397107696,25486.78082008073,80829.6716379226 4,45653.698982143105,87804.95592336128,60564.74631899335,79164.92004887982,19 552.924019982987,32305.964899970208,38293.89912826758,49925.72138232143,47774 .23542327551,82424.14960066472,18145.862659292216,85297.10554833556,89015.583 12019755,8476.384520548665,1929.6465924970514,29982.54430913398,40673.7320083 94865,97074.4912681022,8069.4511082947965,78349.22125760184,48067.07040518514 ,13857.478952540328,37241.9505583952,38709.23930101016,25113.67752991244,3014 2.011994864097,42571.96428905492,96263.87809656067,46427.19632917672,95063.36 619911942,4022.6750867719975,7544.915598748731,3753.7747135296563,66928.51918 797307,22803.036420265722,58065.597948011804,79741.24742493703,33849.57794719 187,25322.07177819959,72815.45012691691,48113.88153665747,15771.80445888076,9 657.066629499175,73979.58261280264,86180.82115301354,89145.84575006778,51498. 811740985664,16192.002070100069,23340.083815569324,45898.86501307257,85333.87 998695576,65369.5444646916,28146.488738379096,75837.92551416076,44108.5773567 4041,98293.63057422236,43443.98661099572,83882.43854145108,2439.6215047409187 ,72103.90524422366,40449.365835706296,50401.92149099364,20683.754236192304,93 021.6398589719,20764.856324737557,56597.0837034392,60137.21673410351,85985.89 930265165,47199.98742887538,83159.23683493392,52865.75985846356,95677.1312828 3927,71944.1755394946,91298.4208374175,94293.6926985568,80422.36947548781,131 14.387112955168,13318.431225200588,62007.93327940807,27849.461593434626,39130 .08009840097,18208.98948573911,76454.99464297837,85595.27266090916,14147.6580 79364532,52166.65873963943,40106.28006976111,79211.51648009919,47034.23771737 224,73350.09586566911,57044.28378136128,97846.56328793522,42543.67451884676,9 8779.41609634721,42128.41974602035,19084.19648769007,78426.02498330359,27900. 181232962725,57009.718352670534,64955.492909241344,20768.048557147977,4406.28 6632124431,98716.3010124358,81921.62416471273,13246.820240988227,84948.973582 19269,26554.889973409285,25481.18929844428,77489.01868793309,75978.8392233550 8,84749.77704927203,14528.548780779218,75011.03134728348,47512.56355304741,33 262.45740461117,73695.98487734183,84669.16501486194,32923.614998754085,16326. 344109385736,99176.78711505492,91999.80893455193,29694.2738317877,81627.01649 196685,9879.628999422268,91342.04483791182,77690.57129123538,20489.4483612921 3,30273.037452772223,59959.93062925894,36220.008758907905,73887.147778798,596 43.92406505537,21495.836604230975,61400.84147851358,2391.8494297422735,12063. 033715001378,16959.573893558514,36014.09348992197,2179.0640957607648,93060.84 484270416,24711.386591753875,27793.216494060624,38188.59024482016,94133.13285 711575,35830.11358565577,43682.15276425513,30552.21997774239,97648.2584701275 8,37120.86526185778,9270.204677973548,66140.25702966859,71943.88715083216,378 51.86139530687,21927.13038953886,41515.893667174234,44467.75284072402,99534.6 8053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch":"Int32","pro fession":"Int32","education":"Int32","age":"Int32","sex":"Int32","income":"Fl oat64"}}}},"options":{"run_parallel":true,"duplicate_check":true,"should_broa dcast":true}}}', 'fixed_delta': 0.001, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.GAUSSIAN: 'gaussian'>}.
epsilon=5.426133277165123 delta=0.001
c. Actual queries
[ ]:
res = client.opendp.query(plan, mechanism = "laplace")
print(res.result.value)
[15:26:10] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"Select":{"expr":[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum" :{"Function":{"input":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Lit eral":{"Float":100000.0}}],"function":{"Clip":{"has_min":true,"has_max":true} },"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":true ,"flags":"ALLOW_GROUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Int":100000 }}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/sta te/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noi se","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"","che ck_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"F unction":{"input":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"N ull"},{"Literal":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/wor k/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/open dp.abi3.so","symbol":"noise","kwargs":[]}},"options":{"collect_groups":"Eleme ntWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}]," input":{"DataFrameScan":{"df":{"columns":[{"name":"region","datatype":"Int32" ,"bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5,4,4,7,2,6,5,1, 3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7,3,5,7,5,6,5,5 ,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2,5,5,1,1,3,6,3, 6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7,2,6,7,1,3,5,1 ,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2,6,6,5,7,7,2,1, 1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_branch","datatype" :"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94,30,46,58,68,4 7,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,30,14,53,82,64, 14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31,79,62,85,59,77 ,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85,93,21,80,45,1 3,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71,65,92,78,20,1 1,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87,22,55,65,37,6 1,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,28,60,21,17,69, 13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56,95,11,61,49,8, 59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bit_settings":"" ,"values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,51,53,73,33,24, 72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32,23,61,22,23,21 ,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31,22,21,61,32,2 5,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,51,92,91,21,53, 83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81,93,81,72,34,61 ,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23,41,72,33,81,1 0,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,72,92,33,32,74, 61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33,72,34,83]},{"n ame":"education","datatype":"Int32","bit_settings":"","values":[5,8,6,5,4,1,1 ,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2,8,7,2,5,3,4,5, 8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6,2,7,5,4,1,2,6 ,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4,8,3,3,3,2,7,7, 3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1,3,3,6,5,7,4,8 ,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2,5,6,8,1,7,4,8, 4]},{"name":"age","datatype":"Int32","bit_settings":"","values":[111,24,41,11 3,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,73,86,103,118,6 4,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94,22,20,26,69,60 ,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62,70,56,74,34,5 5,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87,31,38,18,54,8 6,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112,108,6,5,89,23, 22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23,55,8,89,93,85 ,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72,67,6,46,37,75, 38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51,25,102]},{"nam e":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1,0,1,0,0,1,0,0 ,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1, 0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1 ,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0, 1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,1,1,1,0 ,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0]},{"na me":"income","datatype":"Float64","bit_settings":"","values":[1611.5060496435 385,72395.41282556736,67983.84186121338,66033.24354264204,69054.08522901933,5 9040.15689082983,12412.616354772928,67251.16851562508,1653.2538542897753,1910 1.445016515365,42666.962114339476,38458.56866045681,12777.551079037243,43268. 80279994885,62738.1071187109,38368.87972171097,71141.4488453842,23861.2874424 49426,15238.701954821421,75141.08460436016,67204.08484644344,43507.6986361814 9,14539.961196953593,66704.69019356873,75245.61924269522,17230.322667574772,6 9240.87195608823,36208.071551796806,91596.74287407863,75402.42907323074,28099 .385853106236,93864.6056441426,3498.0428543588146,19297.577433361428,24948.39 4143566366,73475.92825361855,53090.635019660534,46973.16538151256,23030.80053 844617,75890.2439256015,12593.534397107696,25486.78082008073,80829.6716379226 4,45653.698982143105,87804.95592336128,60564.74631899335,79164.92004887982,19 552.924019982987,32305.964899970208,38293.89912826758,49925.72138232143,47774 .23542327551,82424.14960066472,18145.862659292216,85297.10554833556,89015.583 12019755,8476.384520548665,1929.6465924970514,29982.54430913398,40673.7320083 94865,97074.4912681022,8069.4511082947965,78349.22125760184,48067.07040518514 ,13857.478952540328,37241.9505583952,38709.23930101016,25113.67752991244,3014 2.011994864097,42571.96428905492,96263.87809656067,46427.19632917672,95063.36 619911942,4022.6750867719975,7544.915598748731,3753.7747135296563,66928.51918 797307,22803.036420265722,58065.597948011804,79741.24742493703,33849.57794719 187,25322.07177819959,72815.45012691691,48113.88153665747,15771.80445888076,9 657.066629499175,73979.58261280264,86180.82115301354,89145.84575006778,51498. 811740985664,16192.002070100069,23340.083815569324,45898.86501307257,85333.87 998695576,65369.5444646916,28146.488738379096,75837.92551416076,44108.5773567 4041,98293.63057422236,43443.98661099572,83882.43854145108,2439.6215047409187 ,72103.90524422366,40449.365835706296,50401.92149099364,20683.754236192304,93 021.6398589719,20764.856324737557,56597.0837034392,60137.21673410351,85985.89 930265165,47199.98742887538,83159.23683493392,52865.75985846356,95677.1312828 3927,71944.1755394946,91298.4208374175,94293.6926985568,80422.36947548781,131 14.387112955168,13318.431225200588,62007.93327940807,27849.461593434626,39130 .08009840097,18208.98948573911,76454.99464297837,85595.27266090916,14147.6580 79364532,52166.65873963943,40106.28006976111,79211.51648009919,47034.23771737 224,73350.09586566911,57044.28378136128,97846.56328793522,42543.67451884676,9 8779.41609634721,42128.41974602035,19084.19648769007,78426.02498330359,27900. 181232962725,57009.718352670534,64955.492909241344,20768.048557147977,4406.28 6632124431,98716.3010124358,81921.62416471273,13246.820240988227,84948.973582 19269,26554.889973409285,25481.18929844428,77489.01868793309,75978.8392233550 8,84749.77704927203,14528.548780779218,75011.03134728348,47512.56355304741,33 262.45740461117,73695.98487734183,84669.16501486194,32923.614998754085,16326. 344109385736,99176.78711505492,91999.80893455193,29694.2738317877,81627.01649 196685,9879.628999422268,91342.04483791182,77690.57129123538,20489.4483612921 3,30273.037452772223,59959.93062925894,36220.008758907905,73887.147778798,596 43.92406505537,21495.836604230975,61400.84147851358,2391.8494297422735,12063. 033715001378,16959.573893558514,36014.09348992197,2179.0640957607648,93060.84 484270416,24711.386591753875,27793.216494060624,38188.59024482016,94133.13285 711575,35830.11358565577,43682.15276425513,30552.21997774239,97648.2584701275 8,37120.86526185778,9270.204677973548,66140.25702966859,71943.88715083216,378 51.86139530687,21927.13038953886,41515.893667174234,44467.75284072402,99534.6 8053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch":"Int32","pro fession":"Int32","education":"Int32","age":"Int32","sex":"Int32","income":"Fl oat64"}}}},"options":{"run_parallel":true,"duplicate_check":true,"should_broa dcast":true}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
shape: (1, 1)
┌────────────┐
│ income │
│ --- │
│ f64 │
╞════════════╡
│ 7052.65482 │
└────────────┘
[ ]:
res = client.opendp.query(plan, mechanism = "gaussian", fixed_delta = 0.001)
print(res.result.value)
[15:26:12] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"Select":{"expr":[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum" :{"Function":{"input":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Lit eral":{"Float":100000.0}}],"function":{"Clip":{"has_min":true,"has_max":true} },"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":true ,"flags":"ALLOW_GROUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Int":100000 }}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/sta te/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noi se","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"","che ck_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"F unction":{"input":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"N ull"},{"Literal":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/wor k/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/open dp.abi3.so","symbol":"noise","kwargs":[]}},"options":{"collect_groups":"Eleme ntWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}]," input":{"DataFrameScan":{"df":{"columns":[{"name":"region","datatype":"Int32" ,"bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5,4,4,7,2,6,5,1, 3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7,3,5,7,5,6,5,5 ,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2,5,5,1,1,3,6,3, 6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7,2,6,7,1,3,5,1 ,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2,6,6,5,7,7,2,1, 1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_branch","datatype" :"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94,30,46,58,68,4 7,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,30,14,53,82,64, 14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31,79,62,85,59,77 ,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85,93,21,80,45,1 3,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71,65,92,78,20,1 1,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87,22,55,65,37,6 1,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,28,60,21,17,69, 13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56,95,11,61,49,8, 59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bit_settings":"" ,"values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,51,53,73,33,24, 72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32,23,61,22,23,21 ,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31,22,21,61,32,2 5,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,51,92,91,21,53, 83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81,93,81,72,34,61 ,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23,41,72,33,81,1 0,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,72,92,33,32,74, 61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33,72,34,83]},{"n ame":"education","datatype":"Int32","bit_settings":"","values":[5,8,6,5,4,1,1 ,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2,8,7,2,5,3,4,5, 8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6,2,7,5,4,1,2,6 ,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4,8,3,3,3,2,7,7, 3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1,3,3,6,5,7,4,8 ,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2,5,6,8,1,7,4,8, 4]},{"name":"age","datatype":"Int32","bit_settings":"","values":[111,24,41,11 3,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,73,86,103,118,6 4,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94,22,20,26,69,60 ,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62,70,56,74,34,5 5,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87,31,38,18,54,8 6,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112,108,6,5,89,23, 22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23,55,8,89,93,85 ,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72,67,6,46,37,75, 38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51,25,102]},{"nam e":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1,0,1,0,0,1,0,0 ,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0,0,0,0,1, 0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1 ,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,1,1,0, 1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1,1,1,1,1,0 ,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0]},{"na me":"income","datatype":"Float64","bit_settings":"","values":[1611.5060496435 385,72395.41282556736,67983.84186121338,66033.24354264204,69054.08522901933,5 9040.15689082983,12412.616354772928,67251.16851562508,1653.2538542897753,1910 1.445016515365,42666.962114339476,38458.56866045681,12777.551079037243,43268. 80279994885,62738.1071187109,38368.87972171097,71141.4488453842,23861.2874424 49426,15238.701954821421,75141.08460436016,67204.08484644344,43507.6986361814 9,14539.961196953593,66704.69019356873,75245.61924269522,17230.322667574772,6 9240.87195608823,36208.071551796806,91596.74287407863,75402.42907323074,28099 .385853106236,93864.6056441426,3498.0428543588146,19297.577433361428,24948.39 4143566366,73475.92825361855,53090.635019660534,46973.16538151256,23030.80053 844617,75890.2439256015,12593.534397107696,25486.78082008073,80829.6716379226 4,45653.698982143105,87804.95592336128,60564.74631899335,79164.92004887982,19 552.924019982987,32305.964899970208,38293.89912826758,49925.72138232143,47774 .23542327551,82424.14960066472,18145.862659292216,85297.10554833556,89015.583 12019755,8476.384520548665,1929.6465924970514,29982.54430913398,40673.7320083 94865,97074.4912681022,8069.4511082947965,78349.22125760184,48067.07040518514 ,13857.478952540328,37241.9505583952,38709.23930101016,25113.67752991244,3014 2.011994864097,42571.96428905492,96263.87809656067,46427.19632917672,95063.36 619911942,4022.6750867719975,7544.915598748731,3753.7747135296563,66928.51918 797307,22803.036420265722,58065.597948011804,79741.24742493703,33849.57794719 187,25322.07177819959,72815.45012691691,48113.88153665747,15771.80445888076,9 657.066629499175,73979.58261280264,86180.82115301354,89145.84575006778,51498. 811740985664,16192.002070100069,23340.083815569324,45898.86501307257,85333.87 998695576,65369.5444646916,28146.488738379096,75837.92551416076,44108.5773567 4041,98293.63057422236,43443.98661099572,83882.43854145108,2439.6215047409187 ,72103.90524422366,40449.365835706296,50401.92149099364,20683.754236192304,93 021.6398589719,20764.856324737557,56597.0837034392,60137.21673410351,85985.89 930265165,47199.98742887538,83159.23683493392,52865.75985846356,95677.1312828 3927,71944.1755394946,91298.4208374175,94293.6926985568,80422.36947548781,131 14.387112955168,13318.431225200588,62007.93327940807,27849.461593434626,39130 .08009840097,18208.98948573911,76454.99464297837,85595.27266090916,14147.6580 79364532,52166.65873963943,40106.28006976111,79211.51648009919,47034.23771737 224,73350.09586566911,57044.28378136128,97846.56328793522,42543.67451884676,9 8779.41609634721,42128.41974602035,19084.19648769007,78426.02498330359,27900. 181232962725,57009.718352670534,64955.492909241344,20768.048557147977,4406.28 6632124431,98716.3010124358,81921.62416471273,13246.820240988227,84948.973582 19269,26554.889973409285,25481.18929844428,77489.01868793309,75978.8392233550 8,84749.77704927203,14528.548780779218,75011.03134728348,47512.56355304741,33 262.45740461117,73695.98487734183,84669.16501486194,32923.614998754085,16326. 344109385736,99176.78711505492,91999.80893455193,29694.2738317877,81627.01649 196685,9879.628999422268,91342.04483791182,77690.57129123538,20489.4483612921 3,30273.037452772223,59959.93062925894,36220.008758907905,73887.147778798,596 43.92406505537,21495.836604230975,61400.84147851358,2391.8494297422735,12063. 033715001378,16959.573893558514,36014.09348992197,2179.0640957607648,93060.84 484270416,24711.386591753875,27793.216494060624,38188.59024482016,94133.13285 711575,35830.11358565577,43682.15276425513,30552.21997774239,97648.2584701275 8,37120.86526185778,9270.204677973548,66140.25702966859,71943.88715083216,378 51.86139530687,21927.13038953886,41515.893667174234,44467.75284072402,99534.6 8053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch":"Int32","pro fession":"Int32","education":"Int32","age":"Int32","sex":"Int32","income":"Fl oat64"}}}},"options":{"run_parallel":true,"duplicate_check":true,"should_broa dcast":true}}}', 'fixed_delta': 0.001, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.GAUSSIAN: 'gaussian'>}.
shape: (1, 1)
┌─────────────┐
│ income │
│ --- │
│ f64 │
╞═════════════╡
│ 7052.547831 │
└─────────────┘
Group_by examples
[ ]:
# Grouped by "sex"
plan = dummy_lf.group_by("sex").agg([
pl.col("income").dp.mean(bounds=(income_lower_bound, income_upper_bound), scale=(100_000.0,1))
])
[ ]:
res = client.opendp.query(plan, dummy=True)
print(res.result.value)
[15:26:15] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'dummy_opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'dummy_nb_rows': 100, 'dummy_seed': 42, 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"}],"aggs":[{"BinaryExpr":{"le ft":{"Function":{"input":[{"Agg":{"Sum":{"Function":{"input":[{"Column":"inco me"},{"Literal":{"Float":1000.0}},{"Literal":{"Float":100000.0}}],"function": {"Clip":{"has_min":true,"has_max":true}},"options":{"collect_groups":"Element Wise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}},{"Li teral":"Null"},{"Literal":{"Float":100000.0}}],"function":{"FfiPlugin":{"lib" :"/home/aymond/work/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packag es/opendp/lib/opendp.abi3.so","symbol":"noise","kwargs":[]}},"options":{"coll ect_groups":"ElementWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GR OUP_AWARE"}}},"op":"TrueDivide","right":{"Function":{"input":[{"Agg":{"Count" :[{"Column":"income"},true]}},{"Literal":"Null"},{"Literal":{"Int":1}}],"func tion":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv/l ib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noise","kwar gs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"","check_length s":true,"flags":"ALLOW_GROUP_AWARE"}}}}}],"maintain_order":false,"options":{" dynamic":null,"rolling":null,"slice":null}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
shape: (2, 2)
┌─────┬──────────────┐
│ sex ┆ income │
│ --- ┆ --- │
│ i64 ┆ f64 │
╞═════╪══════════════╡
│ 1 ┆ 53158.954711 │
│ 0 ┆ 54451.814467 │
└─────┴──────────────┘
[ ]:
plan = dummy_lf.group_by(["sex","region"]).agg([
pl.col("income").dp.mean(bounds=(income_lower_bound, income_upper_bound), scale=(100_000.0,1))
])
[ ]:
res = client.opendp.query(plan, dummy=True)
print(res.result.value)
[15:26:17] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'dummy_opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'dummy_nb_rows': 100, 'dummy_seed': 42, 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"},{"Column":"region"}],"aggs" :[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum":{"Function":{"inp ut":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Literal":{"Float":100 000.0}}],"function":{"Clip":{"has_min":true,"has_max":true}},"options":{"coll ect_groups":"ElementWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GR OUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Float":100000.0}}],"function" :{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv/lib/py thon3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noise","kwargs":[ ]}},"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":tr ue,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"Function":{"inp ut":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"Null"},{"Litera l":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/ .devenv/state/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","s ymbol":"noise","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_s tr":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}],"maintain_order ":false,"options":{"dynamic":null,"rolling":null,"slice":null}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
shape: (14, 3)
┌─────┬────────┬───────────────┐
│ sex ┆ region ┆ income │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ f64 │
╞═════╪════════╪═══════════════╡
│ 1 ┆ 6 ┆ 53909.184317 │
│ 0 ┆ 5 ┆ 27208.31976 │
│ 1 ┆ 1 ┆ 17537.821376 │
│ 0 ┆ 3 ┆ 47801.024405 │
│ 0 ┆ 4 ┆ 72924.112691 │
│ … ┆ … ┆ … │
│ 0 ┆ 1 ┆ 137012.229989 │
│ 1 ┆ 5 ┆ 60167.841749 │
│ 1 ┆ 3 ┆ 57417.794368 │
│ 0 ┆ 6 ┆ 36612.841715 │
│ 1 ┆ 7 ┆ 34733.437236 │
└─────┴────────┴───────────────┘
[ ]:
res = client.opendp.cost(plan, mechanism = "gaussian", fixed_delta = 0.001)
print(res)
[15:26:19] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'estimate_opendp_cost' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"},{"Column":"region"}],"aggs" :[{"BinaryExpr":{"left":{"Function":{"input":[{"Agg":{"Sum":{"Function":{"inp ut":[{"Column":"income"},{"Literal":{"Float":1000.0}},{"Literal":{"Float":100 000.0}}],"function":{"Clip":{"has_min":true,"has_max":true}},"options":{"coll ect_groups":"ElementWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GR OUP_AWARE"}}}}},{"Literal":"Null"},{"Literal":{"Float":100000.0}}],"function" :{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv/lib/py thon3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"noise","kwargs":[ ]}},"options":{"collect_groups":"ElementWise","fmt_str":"","check_lengths":tr ue,"flags":"ALLOW_GROUP_AWARE"}}},"op":"TrueDivide","right":{"Function":{"inp ut":[{"Agg":{"Count":[{"Column":"income"},true]}},{"Literal":"Null"},{"Litera l":{"Int":1}}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/ .devenv/state/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","s ymbol":"noise","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_s tr":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}}}],"maintain_order ":false,"options":{"dynamic":null,"rolling":null,"slice":null}}}', 'fixed_delta': 0.001, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.GAUSSIAN: 'gaussian'>}.
epsilon=5.4211867379729455 delta=0.001
Quantile examples
[ ]:
candidates = list(range(1_000, 100_000, 1000))
[ ]:
plan = dummy_lf.select(
pl.col("income").dp.quantile(alpha=.75, candidates=candidates, scale=1.)
)
[ ]:
res = client.opendp.query(plan)
print(res.result.value)
[15:26:20] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"Select":{"expr":[{"Function":{"input":[{"Function":{"input":[{"Function":{ "input":[{"Column":"income"},{"Literal":{"Float":0.75}},{"Literal":{"Series": {"name":"","datatype":"Int64","bit_settings":"","values":[1000,2000,3000,4000 ,5000,6000,7000,8000,9000,10000,11000,12000,13000,14000,15000,16000,17000,180 00,19000,20000,21000,22000,23000,24000,25000,26000,27000,28000,29000,30000,31 000,32000,33000,34000,35000,36000,37000,38000,39000,40000,41000,42000,43000,4 4000,45000,46000,47000,48000,49000,50000,51000,52000,53000,54000,55000,56000, 57000,58000,59000,60000,61000,62000,63000,64000,65000,66000,67000,68000,69000 ,70000,71000,72000,73000,74000,75000,76000,77000,78000,79000,80000,81000,8200 0,83000,84000,85000,86000,87000,88000,89000,90000,91000,92000,93000,94000,950 00,96000,97000,98000,99000]}}}],"function":{"FfiPlugin":{"lib":"/home/aymond/ work/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/o pendp.abi3.so","symbol":"discrete_quantile_score","kwargs":[]}},"options":{"c ollect_groups":"GroupWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_G ROUP_AWARE | RETURNS_SCALAR"}}},{"Literal":{"String":"min"}},{"Literal":{"Float":1.0}}],"f unction":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/ven v/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"report_no isy_max","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"" ,"check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},{"Literal":{"Series":{"n ame":"","datatype":"Int64","bit_settings":"","values":[1000,2000,3000,4000,50 00,6000,7000,8000,9000,10000,11000,12000,13000,14000,15000,16000,17000,18000, 19000,20000,21000,22000,23000,24000,25000,26000,27000,28000,29000,30000,31000 ,32000,33000,34000,35000,36000,37000,38000,39000,40000,41000,42000,43000,4400 0,45000,46000,47000,48000,49000,50000,51000,52000,53000,54000,55000,56000,570 00,58000,59000,60000,61000,62000,63000,64000,65000,66000,67000,68000,69000,70 000,71000,72000,73000,74000,75000,76000,77000,78000,79000,80000,81000,82000,8 3000,84000,85000,86000,87000,88000,89000,90000,91000,92000,93000,94000,95000, 96000,97000,98000,99000]}}}],"function":{"FfiPlugin":{"lib":"/home/aymond/wor k/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/open dp.abi3.so","symbol":"index_candidates","kwargs":[]}},"options":{"collect_gro ups":"ElementWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWA RE"}}}],"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","datatype ":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5,4,4,7 ,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7,3,5, 7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2,5,5,1 ,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7,2,6, 7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2,6,6,5 ,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_branch"," datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94,30,4 6,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,30,14, 53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31,79,62 ,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85,93,2 1,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71,65,9 2,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87,22,5 5,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,28,60, 21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56,95,11 ,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bit_set tings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,51,53, 73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32,23,61 ,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31,22,2 1,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,51,92, 91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81,93,81 ,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23,41,7 2,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,72,92, 33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33,72,34 ,83]},{"name":"education","datatype":"Int32","bit_settings":"","values":[5,8, 6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2,8,7,2 ,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6,2,7, 5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4,8,3,3 ,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1,3,3, 6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2,5,6,8 ,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values":[111 ,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,73,86, 103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94,22,20 ,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62,70,5 6,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87,31,3 8,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112,108,6 ,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23,55,8 ,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72,67,6, 46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51,25,10 2]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1,0,1, 0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0,0,1,0 ,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,1,0, 0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,1 ,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,1, 1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0,0,1,1 ,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1611.5 060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054.0852 2901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.253854289 7753,19101.445016515365,42666.962114339476,38458.56866045681,12777.5510790372 43,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842,2386 1.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43507.6 9863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230.32266 7574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.42907323 074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.577433361428 ,24948.394143566366,73475.92825361855,53090.635019660534,46973.16538151256,23 030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80829.6 7163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164.92004 887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.72138232 143,47774.23542327551,82424.14960066472,18145.862659292216,85297.10554833556, 89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398,4067 3.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,48067.07 040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.6775299 1244,30142.011994864097,42571.96428905492,96263.87809656067,46427.19632917672 ,95063.36619911942,4022.6750867719975,7544.915598748731,3753.7747135296563,66 928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703,33849 .57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771.8044 5888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.845750067 78,51498.811740985664,16192.002070100069,23340.083815569324,45898.86501307257 ,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076,4410 8.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439.6215 047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.754236 192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.21673410351 ,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356,9567 7.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.369475 48781,13114.387112955168,13318.431225200588,62007.93327940807,27849.461593434 626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090916,1 4147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919,47034 .23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543.6745 1884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.024983303 59,27900.181232962725,57009.718352670534,64955.492909241344,20768.04855714797 7,4406.286632124431,98716.3010124358,81921.62416471273,13246.820240988227,849 48.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75978.8 3922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512.56355 304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.6149987540 85,16326.344109385736,99176.78711505492,91999.80893455193,29694.2738317877,81 627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20489.4 4836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887.1477 78798,59643.92406505537,21495.836604230975,61400.84147851358,2391.84942974227 35,12063.033715001378,16959.573893558514,36014.09348992197,2179.0640957607648 ,93060.84484270416,24711.386591753875,27793.216494060624,38188.59024482016,94 133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97648.2 5847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.887150 83216,37851.86139530687,21927.13038953886,41515.893667174234,44467.7528407240 2,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch":"In t32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32","in come":"Float64"}}}},"options":{"run_parallel":true,"duplicate_check":true,"sh ould_broadcast":true}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
shape: (1, 1)
┌────────┐
│ income │
│ --- │
│ i64 │
╞════════╡
│ 8000 │
└────────┘
Quantile with group_by
[ ]:
plan = dummy_lf.group_by("sex").agg([
pl.col("income").dp.quantile(alpha=.25, candidates=candidates, scale=(100.)),
])
[ ]:
res = client.opendp.query(plan)
print(res.result.value)
[15:26:23] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"}],"aggs":[{"Function":{"inpu t":[{"Function":{"input":[{"Function":{"input":[{"Column":"income"},{"Literal ":{"Float":0.25}},{"Literal":{"Series":{"name":"","datatype":"Int64","bit_set tings":"","values":[1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,11000, 12000,13000,14000,15000,16000,17000,18000,19000,20000,21000,22000,23000,24000 ,25000,26000,27000,28000,29000,30000,31000,32000,33000,34000,35000,36000,3700 0,38000,39000,40000,41000,42000,43000,44000,45000,46000,47000,48000,49000,500 00,51000,52000,53000,54000,55000,56000,57000,58000,59000,60000,61000,62000,63 000,64000,65000,66000,67000,68000,69000,70000,71000,72000,73000,74000,75000,7 6000,77000,78000,79000,80000,81000,82000,83000,84000,85000,86000,87000,88000, 89000,90000,91000,92000,93000,94000,95000,96000,97000,98000,99000]}}}],"funct ion":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv/li b/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"discrete_quan tile_score","kwargs":[]}},"options":{"collect_groups":"GroupWise","fmt_str":" ","check_lengths":true,"flags":"ALLOW_GROUP_AWARE | RETURNS_SCALAR"}}},{"Literal":{"String":"min"}},{"Literal":{"Float":100.0}}], "function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/v env/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"report_ noisy_max","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str": "","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},{"Literal":{"Series":{ "name":"","datatype":"Int64","bit_settings":"","values":[1000,2000,3000,4000, 5000,6000,7000,8000,9000,10000,11000,12000,13000,14000,15000,16000,17000,1800 0,19000,20000,21000,22000,23000,24000,25000,26000,27000,28000,29000,30000,310 00,32000,33000,34000,35000,36000,37000,38000,39000,40000,41000,42000,43000,44 000,45000,46000,47000,48000,49000,50000,51000,52000,53000,54000,55000,56000,5 7000,58000,59000,60000,61000,62000,63000,64000,65000,66000,67000,68000,69000, 70000,71000,72000,73000,74000,75000,76000,77000,78000,79000,80000,81000,82000 ,83000,84000,85000,86000,87000,88000,89000,90000,91000,92000,93000,94000,9500 0,96000,97000,98000,99000]}}}],"function":{"FfiPlugin":{"lib":"/home/aymond/w ork/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/op endp.abi3.so","symbol":"index_candidates","kwargs":[]}},"options":{"collect_g roups":"ElementWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_A WARE"}}}],"maintain_order":false,"options":{"dynamic":null,"rolling":null,"sl ice":null}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
shape: (2, 2)
┌─────┬────────┐
│ sex ┆ income │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪════════╡
│ 1 ┆ 6000 │
│ 0 ┆ 5000 │
└─────┴────────┘
Quantile with group_by on mulitple columns
[ ]:
plan = dummy_lf.group_by(["sex", "region"]).agg([
pl.col("income").dp.quantile(alpha=.75, candidates=candidates, scale=(100.)),
])
[ ]:
res = client.opendp.query(plan)
print(res.result.value)
[15:26:25] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"},{"Column":"region"}],"aggs" :[{"Function":{"input":[{"Function":{"input":[{"Function":{"input":[{"Column" :"income"},{"Literal":{"Float":0.75}},{"Literal":{"Series":{"name":"","dataty pe":"Int64","bit_settings":"","values":[1000,2000,3000,4000,5000,6000,7000,80 00,9000,10000,11000,12000,13000,14000,15000,16000,17000,18000,19000,20000,210 00,22000,23000,24000,25000,26000,27000,28000,29000,30000,31000,32000,33000,34 000,35000,36000,37000,38000,39000,40000,41000,42000,43000,44000,45000,46000,4 7000,48000,49000,50000,51000,52000,53000,54000,55000,56000,57000,58000,59000, 60000,61000,62000,63000,64000,65000,66000,67000,68000,69000,70000,71000,72000 ,73000,74000,75000,76000,77000,78000,79000,80000,81000,82000,83000,84000,8500 0,86000,87000,88000,89000,90000,91000,92000,93000,94000,95000,96000,97000,980 00,99000]}}}],"function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/. devenv/state/venv/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","sy mbol":"discrete_quantile_score","kwargs":[]}},"options":{"collect_groups":"Gr oupWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_AWARE | RETURNS_SCALAR"}}},{"Literal":{"String":"min"}},{"Literal":{"Float":100.0}}], "function":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/v env/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"report_ noisy_max","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str": "","check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},{"Literal":{"Series":{ "name":"","datatype":"Int64","bit_settings":"","values":[1000,2000,3000,4000, 5000,6000,7000,8000,9000,10000,11000,12000,13000,14000,15000,16000,17000,1800 0,19000,20000,21000,22000,23000,24000,25000,26000,27000,28000,29000,30000,310 00,32000,33000,34000,35000,36000,37000,38000,39000,40000,41000,42000,43000,44 000,45000,46000,47000,48000,49000,50000,51000,52000,53000,54000,55000,56000,5 7000,58000,59000,60000,61000,62000,63000,64000,65000,66000,67000,68000,69000, 70000,71000,72000,73000,74000,75000,76000,77000,78000,79000,80000,81000,82000 ,83000,84000,85000,86000,87000,88000,89000,90000,91000,92000,93000,94000,9500 0,96000,97000,98000,99000]}}}],"function":{"FfiPlugin":{"lib":"/home/aymond/w ork/lomas/lomas/.devenv/state/venv/lib/python3.13/site-packages/opendp/lib/op endp.abi3.so","symbol":"index_candidates","kwargs":[]}},"options":{"collect_g roups":"ElementWise","fmt_str":"","check_lengths":true,"flags":"ALLOW_GROUP_A WARE"}}}],"maintain_order":false,"options":{"dynamic":null,"rolling":null,"sl ice":null}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
shape: (14, 3)
┌─────┬────────┬────────┐
│ sex ┆ region ┆ income │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪════════╪════════╡
│ 1 ┆ 1 ┆ 9000 │
│ 1 ┆ 6 ┆ 9000 │
│ 0 ┆ 2 ┆ 7000 │
│ 1 ┆ 2 ┆ 9000 │
│ 1 ┆ 7 ┆ 7000 │
│ … ┆ … ┆ … │
│ 0 ┆ 4 ┆ 8000 │
│ 0 ┆ 6 ┆ 8000 │
│ 0 ┆ 3 ┆ 8000 │
│ 0 ┆ 5 ┆ 7000 │
│ 1 ┆ 3 ┆ 9000 │
└─────┴────────┴────────┘
Income distribution for partitions of the population:
Prepare the pipeline
[ ]:
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
[ ]:
# Partitions
PARTITIONS = ['sex', 'region']
# Prepare a list of candidates
candidates = [x * 250.0 for x in range(8, 52)]
[ ]:
def make_quantile_pipeline(quantile):
# Create expression
return dummy_lf.group_by(["sex", "region"]).agg([
pl.col("income").dp.quantile(alpha=quantile, candidates=candidates, scale=1.),
])
[ ]:
q25 = make_quantile_pipeline(0.25)
q50 = make_quantile_pipeline(0.5)
q75 = make_quantile_pipeline(0.75)
[ ]:
r25 = client.opendp.query(q25)
r50 = client.opendp.query(q50)
r75 = client.opendp.query(q75)
/home/aymond/work/lomas/lomas/client/lomas_client/libraries/opendp.py:59: UserWarning: 'json' serialization format of LazyFrame is deprecated
body_json["opendp_json"] = opendp_pipeline.serialize(format="json")
[15:26:29] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"},{"Column":"region"}],"aggs" :[{"Function":{"input":[{"Function":{"input":[{"Function":{"input":[{"Column" :"income"},{"Literal":{"Float":0.25}},{"Literal":{"Series":{"name":"","dataty pe":"Float64","bit_settings":"","values":[2000.0,2250.0,2500.0,2750.0,3000.0, 3250.0,3500.0,3750.0,4000.0,4250.0,4500.0,4750.0,5000.0,5250.0,5500.0,5750.0, 6000.0,6250.0,6500.0,6750.0,7000.0,7250.0,7500.0,7750.0,8000.0,8250.0,8500.0, 8750.0,9000.0,9250.0,9500.0,9750.0,10000.0,10250.0,10500.0,10750.0,11000.0,11 250.0,11500.0,11750.0,12000.0,12250.0,12500.0,12750.0]}}}],"function":{"FfiPl ugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv/lib/python3.13 /site-packages/opendp/lib/opendp.abi3.so","symbol":"discrete_quantile_score", "kwargs":[]}},"options":{"collect_groups":"GroupWise","fmt_str":"","check_len gths":true,"flags":"ALLOW_GROUP_AWARE | RETURNS_SCALAR"}}},{"Literal":{"String":"min"}},{"Literal":{"Float":1.0}}],"f unction":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/ven v/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"report_no isy_max","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"" ,"check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},{"Literal":{"Series":{"n ame":"","datatype":"Float64","bit_settings":"","values":[2000.0,2250.0,2500.0 ,2750.0,3000.0,3250.0,3500.0,3750.0,4000.0,4250.0,4500.0,4750.0,5000.0,5250.0 ,5500.0,5750.0,6000.0,6250.0,6500.0,6750.0,7000.0,7250.0,7500.0,7750.0,8000.0 ,8250.0,8500.0,8750.0,9000.0,9250.0,9500.0,9750.0,10000.0,10250.0,10500.0,107 50.0,11000.0,11250.0,11500.0,11750.0,12000.0,12250.0,12500.0,12750.0]}}}],"fu nction":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv /lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"index_cand idates","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"", "check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}],"maintain_order":false," options":{"dynamic":null,"rolling":null,"slice":null}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
[15:26:32] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"},{"Column":"region"}],"aggs" :[{"Function":{"input":[{"Function":{"input":[{"Function":{"input":[{"Column" :"income"},{"Literal":{"Float":0.5}},{"Literal":{"Series":{"name":"","datatyp e":"Float64","bit_settings":"","values":[2000.0,2250.0,2500.0,2750.0,3000.0,3 250.0,3500.0,3750.0,4000.0,4250.0,4500.0,4750.0,5000.0,5250.0,5500.0,5750.0,6 000.0,6250.0,6500.0,6750.0,7000.0,7250.0,7500.0,7750.0,8000.0,8250.0,8500.0,8 750.0,9000.0,9250.0,9500.0,9750.0,10000.0,10250.0,10500.0,10750.0,11000.0,112 50.0,11500.0,11750.0,12000.0,12250.0,12500.0,12750.0]}}}],"function":{"FfiPlu gin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv/lib/python3.13/ site-packages/opendp/lib/opendp.abi3.so","symbol":"discrete_quantile_score"," kwargs":[]}},"options":{"collect_groups":"GroupWise","fmt_str":"","check_leng ths":true,"flags":"ALLOW_GROUP_AWARE | RETURNS_SCALAR"}}},{"Literal":{"String":"min"}},{"Literal":{"Float":1.0}}],"f unction":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/ven v/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"report_no isy_max","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"" ,"check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},{"Literal":{"Series":{"n ame":"","datatype":"Float64","bit_settings":"","values":[2000.0,2250.0,2500.0 ,2750.0,3000.0,3250.0,3500.0,3750.0,4000.0,4250.0,4500.0,4750.0,5000.0,5250.0 ,5500.0,5750.0,6000.0,6250.0,6500.0,6750.0,7000.0,7250.0,7500.0,7750.0,8000.0 ,8250.0,8500.0,8750.0,9000.0,9250.0,9500.0,9750.0,10000.0,10250.0,10500.0,107 50.0,11000.0,11250.0,11500.0,11750.0,12000.0,12250.0,12500.0,12750.0]}}}],"fu nction":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv /lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"index_cand idates","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"", "check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}],"maintain_order":false," options":{"dynamic":null,"rolling":null,"slice":null}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
[15:26:34] DEBUG User 'dr.fso@example.com') is making a request to url http_client.py:77 'http://localhost:48080/' at the endpoint 'opendp_query' with query params: {'dataset_name': 'FSO_INCOME_SYNTHETIC', 'opendp_json': '{"GroupBy":{"input":{"DataFrameScan":{"df":{"columns":[{"name":"region","dat atype":"Int32","bit_settings":"","values":[6,5,4,2,3,1,1,1,2,6,5,7,4,5,7,6,5, 4,4,7,2,6,5,1,3,7,4,1,6,6,6,2,1,7,1,4,1,3,4,3,3,1,1,1,1,5,4,5,2,5,6,3,4,7,6,7 ,3,5,7,5,6,5,5,3,7,1,5,6,6,4,3,3,3,4,6,7,1,7,4,3,5,5,2,3,6,5,4,3,6,3,3,7,2,2, 5,5,1,1,3,6,3,6,3,2,6,7,1,1,5,3,5,2,7,4,7,6,5,2,6,1,4,3,7,2,7,1,5,5,7,3,7,5,7 ,2,6,7,1,3,5,1,4,5,6,7,3,4,4,7,2,4,1,3,7,5,3,7,5,7,1,4,6,6,3,4,3,4,2,6,1,3,2, 6,6,5,7,7,2,1,1,6,7,7,5,7,7,1,1,7,1,7,6,7,3,2,4,7,3,7,3,6]},{"name":"eco_bran ch","datatype":"Int32","bit_settings":"","values":[27,52,35,27,88,79,21,91,94 ,30,46,58,68,47,21,92,70,11,80,73,24,64,55,11,91,72,33,10,16,75,21,55,88,91,3 0,14,53,82,64,14,66,37,27,46,86,94,21,60,75,29,30,28,26,87,26,27,20,18,78,31, 79,62,85,59,77,80,14,60,49,31,49,45,53,80,81,65,72,94,65,41,15,59,27,62,10,85 ,93,21,80,45,13,90,92,13,62,81,78,45,85,81,18,8,17,41,17,15,29,66,56,30,93,71 ,65,92,78,20,11,86,45,14,52,42,47,46,33,53,53,95,70,77,8,33,95,30,55,86,65,87 ,22,55,65,37,61,96,74,33,14,24,30,87,30,80,30,69,56,94,60,91,94,74,65,85,96,2 8,60,21,17,69,13,72,81,23,69,43,88,90,61,60,72,61,74,24,78,56,75,56,33,16,56, 95,11,61,49,8,59,77,74,95,58,62]},{"name":"profession","datatype":"Int32","bi t_settings":"","values":[94,33,81,25,41,71,61,25,71,61,92,61,91,93,22,22,52,5 1,53,73,33,24,72,41,93,21,72,73,32,22,33,42,94,91,31,51,61,92,23,74,92,92,32, 23,61,22,23,21,25,91,71,62,94,51,21,24,32,71,34,33,23,72,10,43,73,52,72,81,31 ,22,21,61,32,25,73,81,93,51,52,94,52,25,32,93,21,81,71,51,83,81,43,61,74,71,5 1,92,91,21,53,83,22,41,52,34,72,94,41,74,23,51,10,42,10,91,94,22,81,72,33,81, 93,81,72,34,61,81,73,31,42,41,72,42,42,53,61,23,92,42,24,10,43,73,33,83,25,23 ,41,72,33,81,10,94,21,83,10,42,33,94,71,94,42,52,52,74,52,92,25,51,31,91,23,7 2,92,33,32,74,61,53,91,22,32,41,92,22,43,51,10,42,71,42,33,61,94,23,33,93,33, 72,34,83]},{"name":"education","datatype":"Int32","bit_settings":"","values": [5,8,6,5,4,1,1,6,6,5,1,7,7,5,3,7,5,8,3,3,7,2,3,4,6,7,7,4,5,5,7,2,3,6,2,3,8,2, 8,7,2,5,3,4,5,8,8,1,2,6,2,3,5,2,8,6,2,3,6,3,5,8,3,2,3,5,5,1,6,2,6,8,2,7,1,5,6 ,2,7,5,4,1,2,6,4,6,8,6,6,5,3,1,5,2,1,5,5,4,6,8,7,8,1,2,3,5,6,6,8,2,2,3,2,6,4, 8,3,3,3,2,7,7,3,5,8,4,8,3,2,1,6,1,2,5,4,2,5,8,8,1,7,4,4,4,7,2,5,6,4,6,1,6,3,1 ,3,3,6,5,7,4,8,1,3,2,4,8,2,2,4,7,1,7,7,4,1,4,6,7,2,6,5,7,6,7,7,6,4,8,5,7,1,2, 5,6,8,1,7,4,8,4]},{"name":"age","datatype":"Int32","bit_settings":"","values" :[111,24,41,113,119,11,17,0,113,39,64,119,101,32,45,100,59,20,113,70,93,115,7 3,86,103,118,64,69,80,118,54,101,33,94,13,107,41,76,17,43,11,63,119,27,32,94, 22,20,26,69,60,64,3,81,37,92,100,13,35,75,21,50,42,74,89,83,38,70,97,88,95,62 ,70,56,74,34,55,27,61,84,95,84,21,23,45,117,3,81,35,64,10,101,105,58,94,57,87 ,31,38,18,54,86,94,102,23,82,32,44,44,69,71,68,7,113,103,46,69,19,76,106,112, 108,6,5,89,23,22,76,7,95,21,73,76,23,48,14,118,61,17,98,89,26,41,9,67,66,6,23 ,55,8,89,93,85,99,96,48,54,35,20,33,87,43,120,69,80,63,96,42,74,77,104,81,72, 67,6,46,37,75,38,71,60,41,61,36,26,66,119,74,74,73,106,46,51,68,67,119,21,51, 25,102]},{"name":"sex","datatype":"Int32","bit_settings":"","values":[1,0,0,1 ,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,1,0,1,0, 0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0 ,1,0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1, 1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0 ,0,1,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,1,0,0, 0,1,1,0]},{"name":"income","datatype":"Float64","bit_settings":"","values":[1 611.5060496435385,72395.41282556736,67983.84186121338,66033.24354264204,69054 .08522901933,59040.15689082983,12412.616354772928,67251.16851562508,1653.2538 542897753,19101.445016515365,42666.962114339476,38458.56866045681,12777.55107 9037243,43268.80279994885,62738.1071187109,38368.87972171097,71141.4488453842 ,23861.287442449426,15238.701954821421,75141.08460436016,67204.08484644344,43 507.69863618149,14539.961196953593,66704.69019356873,75245.61924269522,17230. 322667574772,69240.87195608823,36208.071551796806,91596.74287407863,75402.429 07323074,28099.385853106236,93864.6056441426,3498.0428543588146,19297.5774333 61428,24948.394143566366,73475.92825361855,53090.635019660534,46973.165381512 56,23030.80053844617,75890.2439256015,12593.534397107696,25486.78082008073,80 829.67163792264,45653.698982143105,87804.95592336128,60564.74631899335,79164. 92004887982,19552.924019982987,32305.964899970208,38293.89912826758,49925.721 38232143,47774.23542327551,82424.14960066472,18145.862659292216,85297.1055483 3556,89015.58312019755,8476.384520548665,1929.6465924970514,29982.54430913398 ,40673.732008394865,97074.4912681022,8069.4511082947965,78349.22125760184,480 67.07040518514,13857.478952540328,37241.9505583952,38709.23930101016,25113.67 752991244,30142.011994864097,42571.96428905492,96263.87809656067,46427.196329 17672,95063.36619911942,4022.6750867719975,7544.915598748731,3753.77471352965 63,66928.51918797307,22803.036420265722,58065.597948011804,79741.24742493703, 33849.57794719187,25322.07177819959,72815.45012691691,48113.88153665747,15771 .80445888076,9657.066629499175,73979.58261280264,86180.82115301354,89145.8457 5006778,51498.811740985664,16192.002070100069,23340.083815569324,45898.865013 07257,85333.87998695576,65369.5444646916,28146.488738379096,75837.92551416076 ,44108.57735674041,98293.63057422236,43443.98661099572,83882.43854145108,2439 .6215047409187,72103.90524422366,40449.365835706296,50401.92149099364,20683.7 54236192304,93021.6398589719,20764.856324737557,56597.0837034392,60137.216734 10351,85985.89930265165,47199.98742887538,83159.23683493392,52865.75985846356 ,95677.13128283927,71944.1755394946,91298.4208374175,94293.6926985568,80422.3 6947548781,13114.387112955168,13318.431225200588,62007.93327940807,27849.4615 93434626,39130.08009840097,18208.98948573911,76454.99464297837,85595.27266090 916,14147.658079364532,52166.65873963943,40106.28006976111,79211.51648009919, 47034.23771737224,73350.09586566911,57044.28378136128,97846.56328793522,42543 .67451884676,98779.41609634721,42128.41974602035,19084.19648769007,78426.0249 8330359,27900.181232962725,57009.718352670534,64955.492909241344,20768.048557 147977,4406.286632124431,98716.3010124358,81921.62416471273,13246.82024098822 7,84948.97358219269,26554.889973409285,25481.18929844428,77489.01868793309,75 978.83922335508,84749.77704927203,14528.548780779218,75011.03134728348,47512. 56355304741,33262.45740461117,73695.98487734183,84669.16501486194,32923.61499 8754085,16326.344109385736,99176.78711505492,91999.80893455193,29694.27383178 77,81627.01649196685,9879.628999422268,91342.04483791182,77690.57129123538,20 489.44836129213,30273.037452772223,59959.93062925894,36220.008758907905,73887 .147778798,59643.92406505537,21495.836604230975,61400.84147851358,2391.849429 7422735,12063.033715001378,16959.573893558514,36014.09348992197,2179.06409576 07648,93060.84484270416,24711.386591753875,27793.216494060624,38188.590244820 16,94133.13285711575,35830.11358565577,43682.15276425513,30552.21997774239,97 648.25847012758,37120.86526185778,9270.204677973548,66140.25702966859,71943.8 8715083216,37851.86139530687,21927.13038953886,41515.893667174234,44467.75284 072402,99534.68053539825]}]},"schema":{"fields":{"region":"Int32","eco_branch ":"Int32","profession":"Int32","education":"Int32","age":"Int32","sex":"Int32 ","income":"Float64"}}}},"keys":[{"Column":"sex"},{"Column":"region"}],"aggs" :[{"Function":{"input":[{"Function":{"input":[{"Function":{"input":[{"Column" :"income"},{"Literal":{"Float":0.75}},{"Literal":{"Series":{"name":"","dataty pe":"Float64","bit_settings":"","values":[2000.0,2250.0,2500.0,2750.0,3000.0, 3250.0,3500.0,3750.0,4000.0,4250.0,4500.0,4750.0,5000.0,5250.0,5500.0,5750.0, 6000.0,6250.0,6500.0,6750.0,7000.0,7250.0,7500.0,7750.0,8000.0,8250.0,8500.0, 8750.0,9000.0,9250.0,9500.0,9750.0,10000.0,10250.0,10500.0,10750.0,11000.0,11 250.0,11500.0,11750.0,12000.0,12250.0,12500.0,12750.0]}}}],"function":{"FfiPl ugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv/lib/python3.13 /site-packages/opendp/lib/opendp.abi3.so","symbol":"discrete_quantile_score", "kwargs":[]}},"options":{"collect_groups":"GroupWise","fmt_str":"","check_len gths":true,"flags":"ALLOW_GROUP_AWARE | RETURNS_SCALAR"}}},{"Literal":{"String":"min"}},{"Literal":{"Float":1.0}}],"f unction":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/ven v/lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"report_no isy_max","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"" ,"check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}},{"Literal":{"Series":{"n ame":"","datatype":"Float64","bit_settings":"","values":[2000.0,2250.0,2500.0 ,2750.0,3000.0,3250.0,3500.0,3750.0,4000.0,4250.0,4500.0,4750.0,5000.0,5250.0 ,5500.0,5750.0,6000.0,6250.0,6500.0,6750.0,7000.0,7250.0,7500.0,7750.0,8000.0 ,8250.0,8500.0,8750.0,9000.0,9250.0,9500.0,9750.0,10000.0,10250.0,10500.0,107 50.0,11000.0,11250.0,11500.0,11750.0,12000.0,12250.0,12500.0,12750.0]}}}],"fu nction":{"FfiPlugin":{"lib":"/home/aymond/work/lomas/lomas/.devenv/state/venv /lib/python3.13/site-packages/opendp/lib/opendp.abi3.so","symbol":"index_cand idates","kwargs":[]}},"options":{"collect_groups":"ElementWise","fmt_str":"", "check_lengths":true,"flags":"ALLOW_GROUP_AWARE"}}}],"maintain_order":false," options":{"dynamic":null,"rolling":null,"slice":null}}}', 'fixed_delta': None, 'pipeline_type': <OpenDpPipelineType.POLARS: 'polars'>, 'mechanism': <OpenDpMechanism.LAPLACE: 'laplace'>}.
Let us put together the results and show them in a table. Notice that the output is a polars dataframe, we thus need to transform it to a pandas DataFrame if we want to work with pandas.
[ ]:
r25 = r25.result.value.to_pandas()
r50 = r50.result.value.to_pandas()
r75 = r75.result.value.to_pandas()
[ ]:
results = pd.merge(r25, r50, on=PARTITIONS, suffixes=('_25', '_50'))
results = pd.merge(results, r75, on=PARTITIONS)
results.sort_values(by = ['region', 'sex']).head()
| sex | region | income_25 | income_50 | income | |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 5000.0 | 6250.0 | 7750.0 |
| 7 | 1 | 1 | 5750.0 | 7000.0 | 8750.0 |
| 1 | 0 | 2 | 4750.0 | 6000.0 | 7250.0 |
| 11 | 1 | 2 | 5500.0 | 7000.0 | 8500.0 |
| 3 | 0 | 3 | 5000.0 | 6250.0 | 7750.0 |
Visualise results
[ ]:
def quantile_data(q1, q2, q3):
return np.concatenate((np.random.uniform(q1, q2, size=50), np.random.uniform(q2, q3, size=50)))
results['data'] = results.apply(
lambda row: quantile_data(row["income_25"], row["income_50"], row["income"]),
axis=1,
)
results['sex'] = results['sex'].replace({0: 'woman', 1: 'man'})
results['region'] = results['region'].replace({1: 'Lemanique', 2: 'Mittleland', 3: 'North-West', 4: 'Zürich', 5: 'Oriental', 6: 'Central', 7: 'Ticino'})
results = results.explode('data', ignore_index=True)
[ ]:
plt.figure(figsize=(10, 6))
sns.boxplot(x="region", y="data", hue="sex", data=results, palette="Set1", width=0.5);
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.xlabel('Regions', fontsize=15)
plt.ylabel('Income per month (in CHF)', fontsize=15)
plt.title('Income per partition of the population', fontsize=16)
plt.show()