Skip to main content
Create an interactive app for business users to consume an ML model in a simple and intuitive way, for example requesting a Churn prediction for one given customer. This template is for developing a UI to easily consume ML models. By following this template, you can create ML-powered interactive applications that can be easily used by a wide range of business users, and that can deliver real value and insights to end-users. This tutorial is tailored for the Churn Prediction model, but can be modified to work with other models as well.

Import required modules & load models

Building a UI

The app is designed to allow users to Search records by customer name and obtain churn predictions for a customer. The UI includes a Submit button to get the records and initiate the analysis process.
image Learn more about Streamlit functionality here. We are applying the user search to find records in an SQL query:

Write a function to make predictions

Now we will define the function makePrediction that takes a user_input parameter as input. It uses a previously trained encoder and model object to predict the Churn probability of customer:

Logic for Submit button

When the submit button is pressed, the makePrediction() function is called with the user input as the argument. The predicted churn score for each found record is extracted from the function’s returned result. Depending on the predicted score, the UI displays a message. We also plot a bar chart for Prediction vs Customer name.
image image

What’s Next

  1. You can make real-time predictions on new incoming data and send alerts to Slack if the model makes a prediction above a certain threshold.
  2. You can make predictions on real-time incoming data using the saved model. Learn more about making real-time predictions on new incoming data.