End-to-end MLOPS(Machine Learning Operations) is simply the process of management of the entire machine learning lifecycle, from data preparation to model maintenance. The MLOPS has phases, let us look at each.
- Data preprocessing: This is the first phase in end-to-end MLOPS and involves the collection of data from sources like sensors, logs, social media, etc, cleaning it using special software tools like openrefine, winpure, etc, and making it suitable for storage and use for future engineering designs.
- Model Development: Here, cleaned data is used to train models in a variety of techniques with the end goal being to ensure generalization of the outcome.
- Deployment: After data training comes deployment in the real working environment. Here, we automate repetitive tasks, using tools like Google Cloud AutoML, Data Robot, BigML, TPOT(Tree-based Pipeline Optimization Tool.), TransmorgrifAI, etc.
- Model monitoring: After deployment, we log and continuously monitor the performance of our deployed model by analyzing key performance metrics.
- Model compliance: To avoid legal issues and penalties, our deployed model is monitored to perform according to the dictates of regulatory agencies.
- Model maintenance: To ensure optimal working conditions, our model is continuously maintained.
Table of Contents
ToggleTools For MLOps
There are lots of tools out there one can employ for MLOPS, in this article, we will engage with Streamlit and Terrafoam. Now that we have known what MLOPS is, let us explore Streamlit and Terrafoam and their benefits in the MLOPS process.
Streamlit.
Is an open-source Python library that allows one the privilege to build and share interactive web apps for machine learning and other purposes. Streamlit Inc., the developer of Streamlit, was founded by Adrien Treuille, Amanda Kelly, and Thiago Teixeira.
Terrafoam.
Is a machine learning development tool, built in AWS to handle the full machine learning and natural language processing (NLP) lifecycle. Terraform enable data scientists and machine learning engineers with little coding experience to turn machine learning models into interactive web applications. The process involves importing a trained model built with any of the libraries like TensorFlow, PyTorch, etc., into Terraform and then training to achieve a desired outcome. Now that we know about Streamlit and Terraform, let’s learn to install them on our devices.
Streamlit Installation.
We can install Streamlit from the Python terminal by:
1. Running pip install streamlit.
2. Create a new Python script by Importing Streamlit and adding your code.
3. Launch your Streamlit app by executing streamlit run your_script.py in the terminal.
From the above, you can see how easy it is to launch an app using a few lines of code.
Building Machine Learning Models With Terraform.
Terraform, just like Streamlit, helps one build the infrastructure needed to train and deploy machine learning models. To install Terraform on Windows, we first install Chocolatey. Then from your power shell, run Choco install terraform.
Make sure to verify the installation by checking the terraform version in the power shell through: terraform version.
Alternatively, one can add Terraform binary to system path after download from https://www.terraform.io/.
For MACOS installation.
We use homebrew and run the following codes:
brew tap hashicorp/tap
brew install hashicorp/tap/terraform.
For Linux installation.
1. First, update and install required packages by using : sudo apt update && sudo apt install -y gnupg software-properties-common
2. Then, add Hashicorp’s GPG Key: wget -O- https://apt.releases.hashicorp.com/gpg | gpg –dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
3. Add Hashicorp’s repo: echo “deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main” | sudo tee /etc/apt/sources.list.d/hashicorp.list
4. Update and install Terraform: sudo apt update && sudo apt install terraform.
After installation comes usage. To use Terraform to train and deploy machine learning models, we do the following:
· Writing Terraform Config
· Deploying with Terraform: Run terrefoam apply to spin up your infrastructure
· Train your model
· Deploy your model.
Benefits of using Terrfoam to train ML models.
1. One needs very little or no coding experience to set up a machine-learning modeling environment.
2. Terraform allows automation and scaling of deployed machine learning models to test environments without manual intervention.
3. With Terraform being open source and the infrastructure configuration stored as code, one can easily control changes with time.
4. Terraform has a unified configuration characteristic that allows teams to efficiently manage all infrastructure aspects, thus reducing overhead running costs.
5. At Terraform, changes to the infrastructure are recorded, making it easier to produce reports for audit purposes. Finally, Terraform employs segmentation in its approach to infrastructure provisioning, thus reducing the risk of compromised sections affecting other areas.
Benefits of using Streamlit to train machine learning models.
1. With little or no coding experience, one can leverage Streamlit to transform Python script into a functional web app.
2. Streamlit comes with built-in widgets like buttons and sliders that simplify the creation of the interactive user interface.
3. Streamlit easily integrates with Python libraries thus, simplifying deployment tasks which helps for a better understanding of model behavior.
4. This tool is open source with a vibrant community base who work to support its growth. The community reports on security vulnerabilities for easy patches and also contributes to plugins all aimed towards strengthening the security architecture.
Conclusion.
In this article, we have explored the end-to-end MLOPs workflow, covering the essential steps to build, deploy and manage machine learning models efficiently. We looked at the use of two powerful tools, Terraform and Streamlit, to build and deploy machine learning models. By leveraging Streamlit for interactive model visualization and Terraform for infrastructure automation, we established a scalable and reproducible deployment pipeline.