Skip to content

Commit

Permalink
Merge branch 'rebuild-website'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Shotwell committed Apr 9, 2024
2 parents 985f7e5 + f485182 commit 918e955
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
1 change: 1 addition & 0 deletions apps/problem-sets/1-getting-started/1.1-data-frame/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

infile = Path(__file__).parent / "simulated-data.csv"
df = pd.read_csv(infile)
df = df.drop(columns=["text"])


@render.____
Expand Down
3 changes: 1 addition & 2 deletions apps/problem-sets/1-getting-started/1.3-filter-input/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Add a select input to the app which lets the user select one of the accounts. For reference the account list is:
`["Berge & Berge", "Fritsch & Fritsch", "Hintz & Hintz", "Mosciski and Sons", "Wolff Ltd"`
]`
`["Berge & Berge", "Fritsch & Fritsch", "Hintz & Hintz", "Mosciski and Sons", "Wolff Ltd"]`
7 changes: 5 additions & 2 deletions apps/problem-sets/1-getting-started/1.4-filter-connect/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shiny.express import render, ui
from shiny.express import render, ui, input
import pandas as pd
from pathlib import Path
from data_import import df
Expand All @@ -18,5 +18,8 @@

@render.data_frame
def table():
account_counts = df.groupby("sub_account").size().reset_index(name="counts")
account_subset = df
account_counts = (
account_subset.groupby("sub_account").size().reset_index(name="counts")
)
return account_counts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
)


@render.data_frame
def table():
account_subset = df[df["account"] == input.account()]
account_counts = (
account_subset.groupby("sub_account").size().reset_index(name="counts")
)
return account_counts


@render_plotly
def precision_recall_plot():
account_subset = df[df["account"] == input.account()]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
We have a second sidebad input which allows the user to filter the dataset by the number of characters in the `text` field.
Add a second reactive calculation to the app which filters the `account_data()` reactive.

For `input.chars()` returns a tuple with the lower and upper range of a value, and you can filter the data frame with:
For reference `input.chars()` returns a tuple with the lower and upper range of a value, and you can filter the data frame with:
`df[df["text"].str.len().between(*input.chars()]`.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def account_data():

@reactive.calc()
def character_filter():
return account_data()[(account_data()["text"].str.len().between(*input.chars()))]
return account_data()[account_data()["text"].str.len().between(*input.chars())]


with ui.sidebar():
Expand Down
16 changes: 9 additions & 7 deletions apps/problem-sets/3-reactivity/3.2-stacking-reactives/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from plots import plot_auc_curve, plot_precision_recall_curve, plot_score_distribution
from shinywidgets import render_plotly


@reactive.calc
def account_data():
return df[df["account"] == input.account()]


with ui.sidebar():
ui.input_select(
"account",
Expand Down Expand Up @@ -32,14 +38,11 @@

@render_plotly
def metric():
account_subset = df[df["account"] == input.account()]
if input.metric() == "ROC Curve":
return plot_auc_curve(
account_subset, "is_electronics", "training_score"
)
return plot_auc_curve(account_data, "is_electronics", "training_score")
else:
return plot_precision_recall_curve(
account_subset, "is_electronics", "training_score"
account_data(), "is_electronics", "training_score"
)

ui.input_select("metric", "Metric", choices=["ROC Curve", "Precision Recall"])
Expand All @@ -49,5 +52,4 @@ def metric():

@render_plotly
def score_dist():
account_subset = df[df["account"] == input.account()]
return plot_score_distribution(account_subset)
return plot_score_distribution(account_data())
1 change: 0 additions & 1 deletion exercises/1-hello-world.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ from helpers import problem_tabs
```

# Exercise 1.0 - Hello World

```{python}
# | echo: false
Expand Down
3 changes: 3 additions & 0 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ def find_problem_set_folder(base_path, target_path):

path = find_problem_set_folder("apps/problem-sets", folder_name)

formatted_title = "## " + folder_name.replace("-", " ").title()

block = QuartoPrint(
[
formatted_title,
"::::: {.column-screen-inset}",
"::: {.panel-tabset}",
"## Goal",
Expand Down

0 comments on commit 918e955

Please sign in to comment.