Streamlit

Get familiarized with the Streamlit framework.

We'll cover the following

Introduction

After training a PyCaret model that performs well and is sufficiently accurate, we can consider putting it to production. After all, running machine learning experiments may be interesting, but typically our goal is to develop a useful product or service that provides value to users. The most common way to utilize a machine learning model is to deploy it as a web application or application programming interface (API).

The Python ecosystem provides numerous tools and libraries that can help us deploy a model, including various web application frameworks. For example, Django is a high-level, secure, and scalable web framework that can quickly develop and deploy applications. Another popular library is Flask. It’s considered a microframework because of its minimal core functionality, which can be extended as needed with a multitude of libraries. We can also deploy our machine learning model as a REST API using a specialized framework such as the powerful FastAPI library. After we develop an application or API, the next step is to deploy it on a cloud computing service such as Amazon Web Services, Microsoft Azure, or Google Cloud. These services provide numerous advanced features, including virtual machines, support for containerized apps with Kubernetes, cloud storage, and many others.

In this chapter, our goal is to develop machine learning web applications with the Streamlit framework. We’ll focus on two case studies, one based on regression and the other on classification.After we develop these applications, we’ll deploy them using the Streamlit Cloud service.

The Streamlit framework

Streamlit is a Python framework designed to enable the effortless development of machine learning and data science web applications. It is an excellent choice for beginners because it’s easy to use and has numerous powerful features. Streamlit includes a variety of widgets, such as radio buttons, checkboxes, sliders, and text inputs. Furthermore, it supports several visualization libraries that can be used to plot pandas dataframes such as Matplotlib, Vega-Lite, and deck.gl. As a result of those features, developing a machine learning application based on Streamlit is particularly convenient.

Get hands-on with 1200+ tech skills courses.