Integration of Machine Learning Model inside Docker Container
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 you need to copy/create machine learning model which you have created in jupyter notebook
STEP-1: First of all, I have pull the latest version of centOS image from docker hub. Then I have created a new container named sptask1 using the below command:
docker run β it β β name sptask1 centos:latest
STEP 2: Now we need to install python3 on the top of docker container. We can install python by using the below command.
yum install python3-pip
Now we have to install some libraries like sklearn and pandas in python which are necessary for creating machine learning model. we use pip3 install <libraryname>
STEP 3: In Container you need to copy/create machine learning model. I have created a directory named sp using mkdir command and inside sp folder, I have inserted salary.csv dataset from my RHEL system using command below:
docker cp /root/downloads/salary.csv sptask1:/sp/
Now as we have dataset inside the docker container, Now we create a python code to train our machine learning model . Here I use vi <filename.py> command to open python file console and execute python code using
python3 <filename.py>
In the below code, I have imported some python libraries and created a machine learning model. After the model created, I used joblib module to save our ML model inside the folder.
After dumping the model, using python code ,we load the our ML model and and print the predicted value of our salary.
After executing this 2 codes, we get our desired output i.e. our salary predicted value.
Now, we have successfully created a machine learning model and predicted the salary value using it.
Thanks for reading!!!!!