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.Create a function to get records on search
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, themakePrediction() 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.
What’s Next
- 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.
- You can make predictions on real-time incoming data using the saved model. Learn more about making real-time predictions on new incoming data.
