An End to End Web App to detect anomalies from ECG signals with Streamlit
This tutorial focus on building a web application with MLflow, Sagemaker and Streamlit

_You can find the full code of train.py here._
We can run the code and try different combinations of hyperparameters, such as model_name (if or Autoencoder), contamination rate in case we are using the Isolation Forest, number of epochs, and batch size if we switch to Autoencoder.
Now, we updated the stage of the model and we are ready to switch to the next step!
It's important to note that the Isolation Forest returns -1 when an observation is anomalous, otherwise 1. To compare it with the ground truth, we need to map the values, 1 for anomalous and 0 for normal. If you run the script, you should obtain an output like this:
If the file is uploaded and the button is selected, a scatterplot representing the ECG signals of a patient will appear. Like before, it compares the true values versus the predictions. In addition to these features, you can also change the value of the patient ID through the following code
After you push all changes in GitHub, we can deploy the app using Streamlit. It's very easy and straightforward. If you want more info, click the link to this YouTube video. The link to my deployed app is here.
Final thought:
Congratulations! You reached the end of this project focused on detecting anomalies from ECG signals. It can be overwhelming at first when switching from one tool to another, but it gives satisfaction when you reach results! In particular, a web application can be a cute and intuitive way to share your work with other people. Thanks for reading. Have a nice day!
Check out the code in my DagsHub repository:
Did you like my article? Become a member and get unlimited access to new data science posts every day! It's an indirect way of supporting me without any extra cost to you. If you are already a member, subscribe to get emails whenever I publish new data science and python guides!








