Skip to content

Commit

Permalink
Logarithmic epsilon slider (#65)
Browse files Browse the repository at this point in the history
* log epsilon slider

* Use CSS to hide numbers we do not need
  • Loading branch information
mccalluc authored Oct 18, 2024
1 parent 8abbb29 commit 792a768
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dp_creator_ii/app/analysis_panel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from math import pow

from shiny import ui, reactive, render

from dp_creator_ii.mock_data import mock_data, ColumnDef
Expand All @@ -22,10 +24,8 @@ def analysis_ui():
"Values above 1 will add less noise to the data, "
"but have greater risk of revealing individual data."
),
ui.markdown(
"[TODO: Logarithmic slider]"
"(https://github.com/opendp/dp-creator-ii/issues/25)"
),
ui.input_slider("log_epsilon_slider", None, -1, 1, 0, step=0.1),
ui.output_text("epsilon"),
ui.markdown(
"## Preview\n"
"These plots assume a normal distribution for the columns you've selected, "
Expand All @@ -39,6 +39,14 @@ def analysis_ui():


def analysis_server(input, output, session):
@reactive.calc
def epsilon_calc():
return pow(10, input.log_epsilon_slider())

@render.text
def epsilon():
return f"Epsilon: {epsilon_calc():0.3}"

@render.plot()
def plot_preview():
min_x = 0
Expand Down
5 changes: 5 additions & 0 deletions dp_creator_ii/app/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ body {
#top_level_nav {
margin-bottom: 1em;
}

/* Rather than engineer a new widget, hide the numbers we don't want. */
.irs-min, .irs-max, .irs-single {
display: none;
}

0 comments on commit 792a768

Please sign in to comment.