Product

Monday, 16 March 2026

How to Quickly Deploy Machine Learning Models with Streamlit

 

How to Quickly Deploy Machine Learning Models with Streamlit

How to Quickly Deploy Machine Learning Models with Streamlit
Image by Author | Ideogram

This article will navigate you through the deployment of a simple machine learning (ML) for regression using Streamlit. This novel platform streamlines and simplifies deploying artifacts like ML systems as Web services.

A Glimpse of the Model Being Deployed

The focus of this how-to article is to showcase the steps to have an ML model up and running in the cloud in a matter of minutes. Therefore, we’ll stick to building and deploying an extremely simple linear regression model that predicts house prices based on just one attribute: the house size in square feet.

This is the code we’ll take as starting point:

Some quick notes about the main() method above:

  • Streamlit is primarily used to define the user interface for interacting with the model once deployed.
  • The model is first trained by calling a previously defined method, after which an input field and a button will appear to let the user introduce a house size and obtain a price prediction.
  • Upon clicking on a buttonStreamlit handles model inference and not only returns and displays the prediction, but also adds a Plotly interactive visualization of the prediction alongside the training data.
  • The 🏠 emoji was purely intended 😉

The code shown above should execute correctly even if you tried a Python notebook like Jupyter or Colab — provided it comes preceded with pip install instructions for installing the necessary dependencies — but this won’t allow you to interact with the deployed model: for this, we must venture a tiny bit into the wild!

Deploying the Model

To do the actual deployment, first copy and paste the above code into a .py file, created or uploaded into a GitHub repository of your own. In the same GitHub directory, you’ll also need a requirements.txt file containing these dependencies:

Make sure your target GitHub directory looks like this:

Required files in Github repository to deploy an ML model with Streamlit

We will deploy the model by linking these files with Streamlit Cloud app. Register on the website and click on Create App in the upper right corner. You should see a few options:

Creating a Streamlit App via GitHub to deploy our ML model

Let’s go for the first option: deploy a public app from Github.

Next, we’ll introduce the necessary elements to deploy our model as a Streamlit app: the Github repository URL, the branch and main file (the .py file we saved earlier), and an optional app URL from which anyone will be able to access. You’ll quickly notice that Streamlit makes this step easy by automatically figuring out part of this info.

Deploying an app with Streamlit

Click on deploy, cross your fingers, and hopefully that’s it! Your deployed model is now accessible. The resulting interface:

Interface for deployed ML model with Streamlit

Interface for deployed machine learning model with Streamlit
Image by Author

Model deployed: well done!

No comments:

Post a Comment

Connect broadband

AI:List AI views on when for a naive kin after prolonged life suppression coercive behaviour by family members after demise of father with trauma for kin ocd formed after forced to do rituals, family tribal values honor specific activities, utmost religious activities occult witchcraft enforced to do by elder sibling his wife and mother thrice with great celibacy turned the kundalini activated after deep celibacy penance shouting physical Mental financial Extortion by sibling with toxic behaviours and the wife mother and then mockery suppression asking about who’re your worth backbiting among relatives sector toon negligence of intelligence intuitive behaviour- all religious psychological traps when not work and lead to loss of consciousness of kin trance state recovered by governance with technocrats using AI - kin was asked by mother that he’s to go the male should not be seen in house he’s many absurd thought forcefully in brain mind and outsiders already feel awkward of this kin unresponsive behaviour due to TBI PTSD ocd cvt and tell at workplace social gathering he’s to go and asked for sector toon extortion and mockery in various sense due to un practical behaviour negligence of body building due to neglect ion if essential food nutrition and stubbed suppressed in every sense in religious psychological traps by family members AI humanoid using various neural networks and LLMs for kin and required steps.

  List AI views on when for a naive kin after prolonged life suppression coercive behaviour by family members after demise of father with tr...