Skip to content

Commit

Permalink
contributions in output
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Dec 19, 2024
1 parent 7175484 commit 704f771
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
7 changes: 3 additions & 4 deletions dp_wizard/utils/code_generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def _make_queries(self):

def _make_query(self, column_name):
indentifier = name_to_identifier(column_name)
title = f"DP counts for {column_name}"
accuracy_name = f"{indentifier}_accuracy"
histogram_name = f"{indentifier}_histogram"
return (
Expand All @@ -117,19 +116,19 @@ def _make_query(self, column_name):
)
.fill_blocks(
OUTPUT_BLOCK=self._make_output(
title=title,
column_name=column_name,
accuracy_name=accuracy_name,
histogram_name=histogram_name,
)
)
.finish()
)

def _make_output(self, title: str, accuracy_name: str, histogram_name: str):
def _make_output(self, column_name: str, accuracy_name: str, histogram_name: str):
return (
Template(f"{self.root_template}_output")
.fill_values(
TITLE=title,
COLUMN_NAME=column_name,
)
.fill_expressions(
ACCURACY_NAME=accuracy_name,
Expand Down
7 changes: 6 additions & 1 deletion dp_wizard/utils/code_generators/no-tests/_notebook_output.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# CONFIDENCE_NOTE
plot_histogram(HISTOGRAM_NAME, error=ACCURACY_NAME, cutoff=0, title=TITLE)
column_name = COLUMN_NAME
title = (
f"DP counts for {column_name}, "
f"assuming {contributions} contributions per invidual"
)
plot_histogram(HISTOGRAM_NAME, error=ACCURACY_NAME, cutoff=0, title=title)
1 change: 1 addition & 0 deletions dp_wizard/utils/code_generators/no-tests/_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def flatten_dict(dictionary, parent_key=""):
"data": CSV_PATH,
"epsilon": EPSILON,
"columns": COLUMNS,
"contributions": contributions,
},
"outputs": OUTPUTS,
}
Expand Down
6 changes: 3 additions & 3 deletions dp_wizard/utils/code_generators/no-tests/_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
COLUMNS_BLOCK


def get_context(csv_path):
def get_context_contributions(csv_path):
CONTEXT_BLOCK
return context
return context, contributions


if __name__ == "__main__":
Expand All @@ -18,6 +18,6 @@ def get_context(csv_path):
"--csv", required=True, help="Path to csv containing private data"
)
args = parser.parse_args()
context = get_context(csv_path=args.csv)
context, contributions = get_context_contributions(csv_path=args.csv)

QUERIES_BLOCK
6 changes: 5 additions & 1 deletion dp_wizard/utils/code_generators/no-tests/_script_output.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
print(TITLE)
column_name = COLUMN_NAME
print(
f"DP counts for {column_name}, "
f"assuming {contributions} contributions per invidual"
)
print(CONFIDENCE_NOTE, ACCURACY_NAME)
print(HISTOGRAM_NAME)

0 comments on commit 704f771

Please sign in to comment.