Skip to content

Commit

Permalink
merge and fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Dec 2, 2024
2 parents 3c6b2eb + 006643a commit 9d26ffc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
14 changes: 14 additions & 0 deletions dp_wizard/app/analysis_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ def analysis_ui():
with {int(confidence * 100)}% confidence.
"""
),
ui.markdown(
"""
What is the approximate number of rows in the dataset?
This number is only used for the simulation
and not the final calculation.
"""
),
ui.input_select(
"row_count",
"Estimated Rows",
choices=["100", "1000", "10000"],
selected="100",
),
),
),
ui.output_ui("columns_ui"),
Expand Down Expand Up @@ -128,6 +141,7 @@ def columns_ui():
name=column_ids_to_names[column_id],
contributions=contributions(),
epsilon=epsilon(),
row_count=int(input.row_count()),
lower_bounds=lower_bounds,
upper_bounds=upper_bounds,
bin_counts=bin_counts,
Expand Down
2 changes: 2 additions & 0 deletions dp_wizard/app/components/column_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def column_server(
name: str,
contributions: int,
epsilon: float,
row_count: int,
lower_bounds: reactive.Value[dict[str, float]],
upper_bounds: reactive.Value[dict[str, float]],
bin_counts: reactive.Value[dict[str, int]],
Expand Down Expand Up @@ -177,6 +178,7 @@ def column_plot():
# Exit early to avoid divide-by-zero.
return None
accuracy, histogram = make_accuracy_histogram(
row_count=row_count,
lower=lower_x,
upper=upper_x,
bin_count=bin_count,
Expand Down
9 changes: 7 additions & 2 deletions dp_wizard/utils/dp_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


def make_accuracy_histogram(
row_count: int,
lower: float,
upper: float,
bin_count: int,
Expand All @@ -22,7 +23,12 @@ def make_accuracy_histogram(
"""
Creates fake data between lower and upper, and then returns a DP histogram from it.
>>> accuracy, histogram = make_accuracy_histogram(
... lower=0, upper=10, bin_count=5, contributions=1, weighted_epsilon=1)
... row_count=100,
... lower=0, upper=10,
... bin_count=5,
... contributions=1,
... weighted_epsilon=1
... )
>>> accuracy
3.37...
>>> histogram
Expand All @@ -42,7 +48,6 @@ def make_accuracy_histogram(
# Mock data only depends on lower and upper bounds, so it could be cached,
# but I'd guess this is dominated by the DP operations,
# so not worth optimizing.
row_count = 100
df = mock_data({"value": ColumnDef(lower, upper)}, row_count=row_count)

# TODO: When this is stable, merge it to templates, so we can be
Expand Down
4 changes: 4 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def expect_no_error():
download_results_button = page.get_by_role("button", name="Download results")
assert download_results_button.is_disabled()

# Currently the only change when the estimated rows changes is the plot,
# but we could have the confidence interval in the text...
page.get_by_label("Estimated Rows").select_option("1000")

# Set column details:
page.get_by_label("grade").check()
expect_visible(simulation)
Expand Down

0 comments on commit 9d26ffc

Please sign in to comment.