Value of dashboards in data reporting

Examples:

  • Let the viewer explore the many different inputs to an analysis.
  • Let an expert viewer experiment with the tuning parameter of an analysis.
  • Some projects are not a data analysis, but just a data showcase.
  • Quickly and easily show another team what you're doing, for faster feedback.

In class today: We will build and deploy a dashboard

Let's imagine you had done the analysis in this Deepnote project and you wanted to turn it into a dashboard.

We will do exactly that in the first half of today's class, then deploy it online in the second half. To get started:

  1. Create a new folder on your computer where we will do that work.
  2. Downloading both the notebook and dataset files from that Deepnote project into that new folder.

If this is easy for you...

...and so you finish creating a Streamlit dashboard before we get to the class break, then you should do the following things, in this order:

  1. See if anyone on your team would like help with something they're stuck on. (Although I will be helping out as the instructor, there's only one of me, and I'd love your help sharing your knowledge!)
  2. There is a slide about optional additional features you could add to your Streamlit app. Once you're sure no one on your team could use your help with anything, try those.
  3. If you've done all that stuff and it's still not break time, go ahead and start your break early.

If this is hard for you...

...don't worry! It's a very technical set of content for today. I suggest these ways to get help:

  1. Be sure you've carefully followed the course notes. They should tell you almost every little step you need.
  2. Request that the instructor visits your breakout group, so that I can help you get un-stuck.
  3. If someone in your group is ahead of you and seems to know what's going on, ask for their advice.

Step 1. Convert the notebook to a Python script

If needed, review the technique for this in this section of the course notes.

The final result should be that you can run your Python script in either of the following ways, and see the resulting plot.

  • from the command line, python baseball-example.py
  • from within your favorite IDE, such as VS Code or PyCharm, with a Run command

Step 2. Bring in Streamlit

If needed, review the technique for this in this section of the course notes.

You know this is working if you can run streamlit run baseball-example.py from the command line and view the result in your browser.

Recall that any changes you make to your Python script after that can be automatically updated in the browser if you click the "Always rerun" button when prompted.

Step 3. Factor out parameters

If needed, review the technique for this in this section of the course notes.

This should not change the way that your dashboard behaves at all.

But in the end, your dashboard should begin with the declaration of a few constants, perhaps like these:

  • first_year
  • last_year
  • position

(But exactly which parameters you choose to factor out is up to you.)

Step 4. Create input controls

If needed, review the technique for this in this section of the course notes.

When this is complete, each of the parameters you created in the previous step should have an input control visible on your dashboard.

If you chose the parameters I suggested in the previous slide, you might do something like this:

  • Let the user pick the first year with a slider.
  • Let the user pick the last year with another slider.
  • Let the user pick the position from a drop-down "select" box (though that wasn't introduced until the subsequent section of the notes).

Step 5. Improvements

If needed, review the options for improvements listed in this section of the course notes.

In particular, ensure that:

  • the layout of the inputs and chart in your app is visually attractive, and
  • each input and chart is explained with appropriate prompts or titles, so that the first-time visitor will understand them.

If you have time

If you finish the previous steps early, check out my version of this project online.

What do you notice that's different? Can you add those features to yours as well?

To help you figure out what to try, here's a list.

  • Combine the first and last year into a single "double slider." Try Googling it to see how.
  • Speed up the data loading with @st.cache, as described in this section of the course notes.
  • Instead of position abbreviations (P, C, etc.), use readable words (Pitcher, Catcher, etc.).

Break

We'll take a break at this point.

Deploying your app to Heroku

The second half of class will consist entirely of deploying your app to Heroku. This can be challenging! I'll offer as much help as I can.

Follow the procedure outlined in the second half of today's course notes.

If you finish before class is done:

  1. Paste into our Microsoft Teams chat a link to your working app, so everyone can see (including me).
  2. Help at least one of your teammates complete the task as well.
  3. Then feel free to leave early!

Thinking ahead: your Final Project

Recall that some part of your final project must be a dashboard running live on the web.

This has two consequences as you think ahead about that project:

  1. Ensure that you choose a dataset and analysis that could benefit from a dashboard.
  2. Ensure that at least one of the people on your team is comfortable using today's content to deploy a dashboard.