⚜ 𝗠𝗮𝗰𝗵𝗶𝗻𝗲 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝘂𝘀𝗶𝗻𝗴 𝗖𝗼𝗻𝘁𝗮𝗶𝗻𝗲𝗿𝗶𝘇𝗮𝘁𝗶𝗼𝗻 𝗧𝗲𝗰𝗵𝗻𝗼𝗹𝗼𝗴𝘆💻 ⚜
Technology was not what it was many years ago. It has changed and is evolving continuously. 💻
In today’s world, we can say that Machine Learning is the most trending technology. Almost all the big companies are trying to automate things using Artificial Intelligence.
But the challenge faced by them is that the ML model that is created is somehow not getting deployed to the production world.
The percentage of AI models created but never put into production in large enterprises has been estimated to be as much as 90% or more.
With massive investments in data science teams, platforms, and infrastructure, the number of AI projects is dramatically increasing — along with the number of missed opportunities. Unfortunately, most projects are not showing the value that business leaders expect and are introducing new risks that need to be managed.
✨ The solution to the above problem statement is MLOps. ✨
🔰 But, what exactly is MLOps? 🤔 💻
Simply put, MLOps is when DevOps is applied to machine learning. MLOps can be looked upon as the communication between data scientists and the production or operations team of an organization or business. Collaborative in nature, MLOps is designated for eliminating unnecessary functions or waste and automate processes as much as possible that helps in producing consistent and richer business or organizational insights using machine learning.
📍 The first thing we need for MLOps is — 𝗖𝗼𝗻𝘁𝗮𝗶𝗻𝗲𝗿𝗶𝘇𝗮𝘁𝗶𝗼𝗻 𝘁𝗲𝗰𝗵𝗻𝗼𝗹𝗼𝗴𝘆.
Containerization is defined as a form of operating system virtualization, through which applications are run in isolated user spaces called containers, all using the same shared operating system (OS).
For using containerization technology we have many tools like Docker, Podman, etc.
Now let’s get into some hands-on practical implementing the topic. 😍
Before that certain pre-requisites need to be taken care of. I will be using 𝗥𝗲𝗱𝗛𝗮𝘁 𝗘𝗻𝘁𝗲𝗿𝗽𝗿𝗶𝘀𝗲 𝗟𝗶𝗻𝘂𝘅 ( 𝗥𝗛𝗘𝗟 ) 𝟴 for doing this practical.
❗ Your yum should be configured in the system. ❗
Now for installing the Docker community edition into the system create a repo file in the location /etc/yum.repos.d/ with the name docker-ce.repo
📍 Note: The name of the repo file can be anything of your choice but the extension should be “.repo” only.
Now open the repo file with any of your favorite editors and copy the below lines to configure docker.
Now your Docker should be configured in your system. ✨
Run the following command to install docker.
yum install docker-ce --nobest -y
It will install the docker community edition software along with all the dependencies that it might require.
Here I will be using a Dockerfile to create the container image.The container image will have the machine learning code and the dataset.
The goal is when we run a container from this image then the ML code will create the model and then start the app for prediction.
❗ This point will be more clear when we go onto the practicals.
First create a directory containing all the required files.
My directory structure looks something as follows -
[root@localhost ML]# tree
└── salary_predictor.py0 directories, 4 files
- “Salary_Data.csv” is the dataset file.
- “salaryLR.py” is the file that contains the Linear Regression code.
- “salary_predictor.py” is the app that will be used by the user for predicting the salary.
You can get the salary dataset from the following link.
Now let’s come onto the Dockerfile.
FROM centos:latestMAINTAINER RAHUL SIL <email@example.com>RUN dnf install python3 ncurses net-tools -y && \
pip3 install numpy pandas joblib scikit-learnWORKDIR /root/MLCOPY * /root/ML/RUN python3 salaryLR.py
CMD ["python3", "salary_predictor.py" ]
Lets build the dockerfile.
docker build -t linear_regression:v1.0 .
After the dockerfile gets executed you can confirm that a new linear_regression:v1.0 image has been created and stored in the local repository using the following command.
Now lets use the image to run and use the ML model.
This way we have sucessfully implemented the task of running a Machine Learning model inside a docker container. ✨😍
I will soon come up with a blog where I will be explaining the basics of docker and the commnds of docker, dockerfile that I have used here. Stay tuned for that !!
You can get all the code for this task from the below link.
I hope you liked this article.💖
Would definitely like to hear your views on this and feedbacks so that I can improve on those points in future articles. 🙌 Comment your views below.
You can also check my LinkedIn profile and connect with me.
Follow me on medium as I will come up with articles on various technologies like Cloud Computing, DevOps, Automation and their integration.
Rahul Sil - Certified Kubernetes Application Developer ( CKAD ) - ARTH - The School of Technologies…
Hello everyone, I am Rahul Sil, a technology enthusiast. I love playing with technology and to try out various…
That’s all for now. Thank You !! 😊✌