Streamlit: the easiest way to build and share data apps
an invaluable skill to add to your data visualization toolkit.
With the explosion of data science has come a challenge of figuring out the best way to develop, deploy, and share data science insights. Model outputs tend to best be engaged with in dynamic, interactive dashboards, but old methods of app deployment required the skills of a front-end engineer, or the output would lack the intricacy of a visualization that would help a stakeholder buy into the value of models and insights.
Developing a way to surface the results of a data science model should be a capability that’s easily handled by data scientists. A data scientist probably is already proficient in Python - why not use this as a way to easily spin up a data app? Thanks to Streamlit, that is now possible.
Streamlit, recently acquired by data storage and management unicorn Snowflake, is an absolute game changer in a data scientist’s tool kit for delivering insights, sharing mock results, and testing out projects before diving into full stack development.
let’s build an app.
Getting started with Streamlit is extremely simple. You’ll need Python and Streamlit installed on your computer.
Open a Terminal window and run:
pip install streamlit
streamlit hello
(If you are getting errors with pip, you’ll need to set up Python and pip most likely. Check out this article to get set up).
If you see a page similar to this, you’re set up to start using Streamlit! As you can see, the browser says localhost. While what you’re looking at looks like a website, it’s not on the world wide web quite yet. You’re looking at a local browser that only you can see as you develop your Streamlit app. When you’re ready for this to be on the real internet, you can deploy your app to “production”. More on that later.
writing your streamlit app
Open up your local development environment, like Visual Studio or PyCharm (my personal favorite). You’ll start by creating a file, let’s name it app.py.
Within app.py, you’ll be able to write out whatever you’d like rendered in your application.
In a simple project, with app.py, I can spin up a quick local app by typing
streamlit run app.py
For more on what you can build in Streamlit, check out their docs here.
integrating machine learning into your app
Streamlit makes it easier than ever to integrate machine learning into an application that an end user can interact with, surfacing interactive visualizations to model predictions on the fly.
If you’re looking to build a fully integrated app, I recommend building alongside a Youtube video. Patrick does an awesome job to walk through building a model based off Stack Overflow’s Developer survey, then integrate his model’s findings into a Streamlit app. So much to learn in just an hour long video!
If you want to go all the way and deploy your app, check this video out.
Want to make your app a little more fun? Use Lottie Animations to add lightweight animations to your app with just a few lines of code. They’re extra easy to integrate into your Streamlit app and level up your visuals with minimal lift.
the value of streamlit’s product
As a data scientist who finds the area where data science meets the consumer very fascinating (point one, this newsletter), Streamlit’s product caught my eye from their very early days. Three key elements of the product captured my attention right away: they are 1) Python based, 2) requires no front-end experience to use, and 3) allow for seamless deployment in a matter of clicks to the web.
To bring data science to everyone, enabling data scientists to forego the potentially heavy lift that can be front-end web development and empowering not just data scientists but anyone to create easy to use apps in minutes drives the accessibility of powerful model insights forward. Streamlit is great for low fidelity proof-of-concepts, user-friendly demos, or as a playground for interacting with a machine learning model. No experience is necessary to build a Streamlit app - that’s powerful.
Streamlit enables interaction with an incredible variety of machine learning models - the gallery speaks for itself:
Chef: discover new and unique recipes using NLP powered models
Tweets: generates tweets and corresponding images OpenAI's GPT-3 based Davinci model for texts and DALL·E for images
Surfboard Volume: uses an AI model to predict the volume surfboard you should use during your next session (30L all the way!)
Thanks for reading this week’s post. Let me know if you have any ideas, thoughts, or feedback. I’ll see you all next week.