streamlit
Quickly Build and Deploy a Dashboard with Streamlit
Deploying your Streamlit application to Heroku to showcase your Data Solution

With the launch of Streamlit, developing a dashboard for your machine learning solution has been made incredibly easy.
Streamlit is an open source app framework specifically designed for ML engineers working with Python. It allows you to create a stunning looking application with only a few lines of code.
I want to take this opportunity to demonstrate the apps you can build using Streamlit. But mostly, to show you the steps necessary to bring your application into production using Heroku.
1. Streamlit
A few of the advantages of using Streamlit tools like Dash and Flask:
- It embraces Python scripting; No HTML knowledge is needed!
- Less code is needed to create a beautiful application
- No callbacks are needed since widgets are treated as variables
- Data caching simplifies and speeds up computation pipelines.
Have a look at this post which might help you understand the architecture of Streamlit. Moreover, this post
Installation
Streamlit can easily be installed with the following command:
pip install streamlit
Use the following command to see a demonstration of an application with example code:
streamlit hello
Doing this will result in the following page to be opened:

2. Demos
Above from the streamlit hello demo above there are a few more complex demos available online for you to try out. I will list a few (including mine) below such that you will have an idea of the possibilities:
The Udacity Self-driving Car Image Browser
This demo shows how the Udacity car dataset can be combined with object detection in less than 300 lines of code to create a complete Streamlit Demo app.

First, install OpenCV so that the images can be analyzed:
pip install --upgrade streamlit opencv-pythonNext, simply run the app:
streamlit run https://raw.githubusercontent.com/streamlit/demo-self-driving/master/app.pyUber Pickups in New York City
This is a Streamlit demo to show how you can interactively visualize Uber pickups in New York City.

Simply run the code below after installing Streamlit:
streamlit run https://raw.githubusercontent.com/streamlit/demo-uber-nyc-pickups/master/app.pyBoard Game Exploration
As many Board Game Geeks like myself track the scores of board game matches I decided to create an application allowing for the exploration of this data. You can view this application live here, or you can run it locally by following the steps below.

Since I make use of several.py files, you first need to clone the repository:
git clone https://github.com/MaartenGr/boardgame.git BoardGameThen, simply go to the folder and run Streamlit:
cd BoardGame
streamlit run app.pyNOTE: You can use your own data if you like by simply providing the URL to your data.
3. Creating an Application
In this section, I will demonstrate how to create a simple application seeing as the main purpose of this post is to prepare your project for deployment.
If you want more in-depth examples check out Streamlits API or check this or this post which nicely describes many of its features.
But first, let me introduce some basic features that you are likely to be using in your own apps.
Selection Widgets
One of the main features of Streamlit is the usage of widgets. There are many widgets available including the following:
- SelectBox
age = streamlit.selectbox("Choose your age: ", np.arange(18, 66, 1))
- Slider
age = streamlit.slider("Choose your age: ", min_value=16,
max_value=66, value=35, step=1)
- MultiSelect
artists = st.multiselect("Who are your favorite artists?",
["Michael Jackson", "Elvis Presley",
"Eminem", "Billy Joel", "Madonna"])
Caching
The problem with many dashboarding tools is that data is reloaded every time you select an option or switch between pages. Fortunately, Streamlit has an amazing option allowing you to cache the data and only run it if it has not been run before.
















