Salary Prediction Model Under Docker Us Machine Learning
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
---------------------------------------------------------------------------------------------------------------
First of all you need to install docker inside the Linux Operating System, in my case i'm using RedHat Enterprise 8 based on Linux Kernel. Follow the steps below to install Docker inside RHEL8 -
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost ~]# vim docker_ce.repo
Now you need to write the repo configuration for yum to install the docker-ce.
[root@localhost ~]# yum repolist
[root@localhost ~]# yum install docker-ce --nobest -y
[root@localhost ~]# systemctl start docker
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
Systemctl command will start the docker and stop the firewalld temporary. setenforce 0 will disable the SELinux so that container have proper connectivity with the internet.
[root@localhost ~]# docker pull centos:latest
It will pull the latest image of centOS from the dockerhub.com, here centos is image name and latest is tag of image.
[root@localhost ~]# docker run -it --name task1 centos:latest
It will launch the docker container name as task1 from centos image which i have pulled earlier. -it will help in getting the interactive terminal of docker container.
It will install the python version 3 inside the container so that we can work on machine learning using python. It will also install pip3 to download python modules.
[root@645938c93574 /]# pip3 install pandas
[root@645938c93574 /]# pip3 install joblib
[root@645938c93574 /]# pip3 install sklearn
Now all the required modules are installed in the docker container that is required by the ml for salary prediction model.
Now make a file task1.py
Here pandas module help in loading the data-set use by the machine learning model for prediction. Linear Regression is used to predict the salary based on the experience of the Employee.
Joblib help in saving the model created by through machine learning. It will save the model in hard disk so next time we have to just load the model for any prediction. Save this file and run the below command.
It will run the file using the python and create the model and save in the same folder.
It will create the app of salary predictor for the company manager so that he can decide the salary based on the Experience of Employee.
As you can see when you run this app it will ask for the Employee Experience.