Python/Streamlit
Set up your component repository to use the Python/pip/Streamlit stack. With the Docker Generic scaffolder, developers can create a Dockerfile that allows using Python in connection with the Streamlit framework. Streamlit self-describes as an open-source app framework for machine learning and data science teams to create beautiful web apps in minutes.
What we will build
This article takes you step-by-step through creating what is considered the Hello World application of machine learning.
Given a set of inputs, our model will predict which type of flower the inputs most likely relate to. The model is based on the Iris data set. The Iris Dataset contains four features (length and width of sepals and petals) of 50 samples of three species of Iris (Iris setosa, Iris versicolor, and Iris virginica).
Iris setosa | Iris versicolor | Iris virginica |
---|---|---|
This is the user interface we are aiming at:
Prerequisites
To understand the following example and customize it to your needs, you may need prior technical knowledge:
- Python (!)
- Python’s data analysis and machine learning libraries (pandas, scikit-learn)
- A little Markdown
- Basics of Git (commit and push operations)
- Basic knowledge of Dockerfile in case the provided Dockerfile needs customization
Steps
We follow a five-step process. In what follows, we present a high-level overview. For a detailed overview, refer to our step-by-step video. The code for this example can be found here.
Step 1: Create a CodeNOW python scaffolder (< 5 mn)
- Use the Docker Generic scaffolder.
- Update the
Dockerfile
andrequirements.txt
files.
Step 2: Implement the user interface for your model
- Put your code in the
app.py
file.
Step 3: Test everything locally
- In the
src
directory, runstreamlit run app.py
. - Check that the user interface is displayed and works as expected.
Step 4: Build & deploy the app in CodeNOW (< 5 mn)
- Commit and push your changes.
- Go to your CodeNOW instance.
- Select your application then your Python component.
- Build the component and deploy the application (check Deploy immediately after build).
- Once build and deployment are successful, get the deployment URL.
Step 5: Tell your users about it
- Email the deployment URL to your target users.
- Eagerly await their feedback!!!
Screencast: watch us do it in 5 mn
Interesting links
- For more data science examples using Python, see the Data Professor YouTube channel by Prof. Nantasenamat.
- Streamlit's documentation.