Moving data science models from a Proof-Of-Concept (POC) in some notebooks to a Minimal Viable Product (MVP) that provides business value can be a tough transition. This can have a multitude of reasons:
- The amount of engineering work required to integrate your model into existing systems.
- The slow (or nonexistent) feedback cycle with your users, resulting in a very slow cycle time for the last few remaining tweaks.
- Lack of trust by your users in your model, resulting in your amazing model remaining unused.
To get started, you need to install Streamlit, which can be done using pip or pipenv commands on Windows, macOS, and Linux.
We’ve been there ourselves: spending a lot of time productizing a data science application, only to find out that our users didn’t like how it turned out and did not want to use it…
Even though these problems are largely process-related, there are tools that can help mitigate or reduce their impact. One such tool is Streamlit, a simple, Python-based dashboarding tool.
Why Streamlit?
In this blog post, we will highlight three uses of Streamlit that have helped us productionize machine learning models and move from POC to MVP quickly. Streamlit enables developers to build and deploy data-driven web applications with attractive user interfaces. Additionally, we provide three tips to help you get started on building these dashboards.
Three Ways Streamlit Can Help Data Scientists Move from POC to MVP
1. Streamlit as a Prediction Serving Tool
If your users will interact with your model through graphs or manual interpretation of its predictions, a Streamlit dashboard can be valuable for prediction serving. The ease and speed of building and deploying apps using Streamlit make it an ideal choice for this purpose.
In some use cases, there was a trade-off between integrating the predictions into an existing react-based web app (requiring front-end engineers) or into a new Streamlit dashboard. Setting up a new Streamlit app resulted in significant time savings; data scientists could iterate on the product and visualizations without needing software engineering capacity. This sped up the feedback loop with end-users. Once everyone was happy, the predictions could be integrated into the final product. Streamlit can also be used to build dashboards for prediction serving, enhancing the user experience.
2. Streamlit as a Monitoring Tool
During the development cycle of your model, data scientists and users spend time developing evaluation metrics. These metrics are used to check if the model is fit for performance before it goes live. However, evaluation doesn’t stop there. When moving towards the production phase, you need to think about and set up monitoring for your model.
Streamlit is excellent for this purpose. Its ease of creating meaningful visualizations allows for dashboards that both the data science team and users can use. This interaction helps users understand the model better and builds trust. Additionally, Streamlit can be used to create data apps for monitoring purposes, providing real-time insights and enhancing model reliability.
3. Streamlit for Providing Model Insights
You can set up a dashboard that provides more insight into the model than just performance characteristics. Add visualizations about the input data or features your model is currently making predictions on, and information about different forms of model drift. This involvement can build trust and might even help users participate in the debugging process, creating a fast feedback cycle. The benefits of streamlit apps for providing model insights include ease of use, interactive visualizations, and a streamlined feedback loop.
Why Streamlit Makes Web Apps Easy
The core benefit of Streamlit is that it is Python-based. Many of the graphs and visualizations created during model development can be reused in a Streamlit dashboard with minimal effort. Streamlit allows you to reuse any Python code you have already written, saving considerable time compared to non-Python-based tools. You can accomplish many tasks with only a few lines of code.
To get started, you need to install Streamlit using the command pip install streamlit. Once installed, you can import Streamlit and other necessary libraries to build your web application. For example, you can use import streamlit as st to start adding text, titles, headers, and visualizations to your app.
Creating a new file for your Streamlit app is straightforward. You can create a new file named streamlit_app.py and start building your application. Streamlit allows you to build user interfaces with only a few lines of code, making it accessible even for those without front-end knowledge.
Streamlit focuses on simplicity and accessibility for deploying machine learning models. It includes features like authentication and role-based access controls, but organizations dealing with highly sensitive data might need additional security measures.
For scalability, Streamlit is effective for quick prototyping and small to medium-scale applications. However, it may face performance issues as the user base grows or data volume increases.
Streamlit integrates well with other machine learning tools and environments, such as TensorFlow, PyTorch, and scikit-learn, making it a versatile tool for integrating various aspects of a machine learning workflow into an accessible dashboard.
Excited About Building Your Own Dashboard? Here Are 3 Tips to Get Started with Only a Few Lines
- Try Out the Infra Setup First Before committing to building a full dashboard, ensure you have a location to run it that can be accessed by your users. Options for deployment can be found on the Streamlit forum.
- Keep It Simple & Know When to Move On Streamlit is great for initial predictions and user interactions. Use it during the POC and MVP phases, but be prepared to move on to more complex solutions if needed.
- Build a Hello-World Streamlit Template for Your Organization Providing a template for data science teams can save time and frustration. This template should take care of engineering parts and document steps to get an app live. Streamlit makes it easy to share data apps with your team, ensuring smooth collaboration and deployment.
Conclusion
We believe Python-based dashboarding tools like Streamlit can be fantastic for getting results and insights in front of your users without a large development investment. This can speed up the iteration process of your ML applications and help you create value with AI faster.
Interested in how we used Streamlit in practice at one of our clients? Check out our recorded talk at PyData Berlin 2022.