ML model creation on Docker Container
In this article, I am going to create a salary prediction model based on the years of experience using Linear Regression with the help of a docker container in Red-Hat Linux.
Task Description :
✍🏻 We have to pull the docker container image of CentOs image from DockerHub and create a new container to run the image.
✍🏻 In the launched container, we need to load the salary dataset from base os (Red-Hat) to CentOs
✍🏻 Now in the container, we created the machine learning model and predicted the output of salary as per user input.
Stepwise Implementation :
1. Install Docker:
yum install docker-ce — nobest -y
2. Start the docker services:
systemctl start docker
3. Enable docker: The below command will enable the docker services
systemctl enable docker
4. Now we pulled the image of cent os on docker.
5. Now for the first time run the pulled image on docker conatiner.
6. But suppose we close the running docker and want to start the stopped docker once again then we have to write the below commands.
7. Now in CentOS which is running on containers we have to install python to use all the libraries of python for the building ML model.
8. We installed some useful libraries of python using ‘pip3’ command , first we installed ‘pandas’ library to read the dataset into data frame.
9. After pandas we installed sckit-learn library to create the model using Linear Regression which is one of the method of scikit-learn library.
10. Now, since all the installation of useful python libraries is completed we first copied the dataset from base os which is RedHat to CentOs running on docker container.
11. Now we created a python file ‘task1.py’ and there first loaded the dataset, then selected the independent features in x variable and target feature which is our outcome in y variable. After that first, we converted the x from pandas to NumPy array and changed its shape from 1D to 2D. Now we used Linear Regression method to build the model with parameters x & y. At last we just predicted the output salary based on years of experience given as input.
12. We checked the prediction output of our model by giving different years of experience as input.
Hence, after all this we finished out task successfully! Thank You for Reading it :)