Deployment Of Machine Learning model inside Docker Container
Hello connections!!
In this article, i am going to deploy a machine learning model inside docker container. To run docker container, i used RHEL8 as base OS.
About model:- My model is based on salary prediction of employee, on the basis of working experience of employees( in years ).
Task Description:-
* Pull the Docker container image of CentOS image from DockerHub and create a new container.
* Install the Python software on the top of docker container.
* In Container deploy machine learning model.
let's start the task:-
step 1:- First of all i need docker container engine on base os, i have already installed docker. Command to check version:- docker --version
step 2:- I need first to start the docker service by using command:- systemctl start docker
step 3:- Now i have to pull/download container image(centos:latest)
Command to pull docker image for centos:- docker pull centos:latest
docker image for centos downloaded successfully. by using command:- docker images we can check available images.
step 4:- Now i am going to launch a docker container from docker image centos:latest by Command:- docker run -it --name my_os centos:latest
step 5:- Now i have to install python3 on docker container by using command:- yum install python3 -y
step 6:- I require some library of python to run machine learning program like:- numpy, pandas and scikit-learn. So using pip3 command i installed these library on docker container. Command used to install libraries:- pip3 install numpy pandas scikit-learn
Now environment for machine learning is ready, now i have to deploy my machine learning model on docker container. First of all i create a directory/workspace with name myapp on container, and copy machine learning program, .csv file on myapp workspace, from windows working space. I have created the model on jupyter notebook in windows, but my task is to run ml program on docker container.
step 7:- Machine Learning program for salary prediction as shown below, i use joblib library here to save my model after trained/learned my model once, we don't need to trained our model again and again, if we save the model.
step 8:- I write a python program to use the trained model and predict salary as shown below.
step 9:- Now time to test the model:- to test the model run the python program as shown in below
Program ran successfully and give the output, so i can say my task is completed successfully.
Thank you for reading !