Deploy and Test Heart Failure Prediction ML model in under 2 minutes
Deploy, test and monitor Heart Failure Prediction Machine Learning model using Random Forest Classifier on Clouderizer
Life is short and a heart attack can make it shorter. Unexpectedly! Granted, this is not an article about healthcare but the advancements in machine learning (ML) have found application here which brings us to what this article is about: Clouderizer — an easy to use ‘ML Ops’ platform that can quickly serve up a prediction using an ML model (in this case, about heart failure).
For the sake of completeness and recreatibility, let’s generate a model from a public dataset and deploy that on Clouderizer. The specifics of the data and model creation are in the model building section below, for those interested. Now, let’s dive straight into model deployment.
Model deployment is a completely different ball game than model development. Data scientists typically hand over their model to engineering team for implementing a secure, reliable and scalable deployment. Clouderizer can help check off all these boxes and more. It gives you all the controls and features you need for easily creating an API, delivering an out of the box intuitive web interface with an intuitive analytics dashboard, debugging any potential runtime errors early on, updating your deployments with zero downtime, performing preprocessing or postprocessing, retraining your model and reliably running your deployments.
Here are the Clouderizer screenshots that back up the above claims.
Step 1: Signup at Clouderizer
Step 2: Create a new project and upload your model file. In this case, we have created a python model(pickle file).
Step 3: Write, check and upload your Prediction code.
Step 4: Add your input features (age, ejection_fraction, serum_creatinine, serum_sodium) and output (death_event) feature details.
The advanced settings in the output attributes section can be used for customising the visual imagery and text on the scoring UI page.
Step 5: Deploy the model.
You can deploy the model on clouderizer’s Standard/High Memory/GPU machines.
Step 6: And after successful deployment, we are live! Click on the auto generated showcase URL to do predictions from an intuitive UI where you have the option to provide your input in a form or do bulk predictions by uploading a csv file, give feedback and update real values.
To retrain your model, enable Model Retraining in settings and provide your training API endpoint URL to continue. I will cover more details about retraining in a separate article.
And click on Retrain Model to start retraining.
You can also update your existing model and update the deployment, with zero downtime. Also, you can change any of the things related to your deployment like prediction, preprocessing/post processing code or input/output features etc., and update the deployment for the changes to reflect in your deployed API or UI.
You can click on update deployment. if the instance is already running, a hot swap will deploy the updated model.
You can view various statistics, error metrics for the predictions made by your users on your analytics dashboard — all downloadable as a csv file.
Bring practically any model built using open source or proprietary tools to the Clouderizer platform, it ensures the rest is taken care of.
I chose kaggle’s heart failure prediction dataset to build a model that predicts the chances of heart failure. This dataset looked clean to me and so there was no need for any data cleaning. For feature selection, I used correlation matrix to identify the more relevant features that are correlated to death_event.
Feature Selection, Modelling and Packaging the model
I selected features (Age, serum_creatinine, serum_sodium and ejection_fraction) whose correlation value with death_event is less than -0.2 or greater than 0.2. Using these features, various classifiers were run out of which Random Forest gave the best accuracy. So, I built my model with it and packaged using python’s pickle library. Please refer to below github link for more details.
This is a demonstration of the end to end workflow of building the model and deploying it. I have chosen 'heart failure…
I hope you found this article helpful. Thank you for reading!