Predicting Salary Using Linear Regression Model On Top of Docker Container

Utkarsh Pande
2 min readMay 30, 2021

--

TASKS TO BE DONE:-

👉 Pull the Docker container image of CentOS image from DockerHub and create a new container

👉 Install the Python software on the top of the docker container

👉 In Container you need to copy the machine learning model which you have created in the jupyter notebook.

Linear Regression

It is the basic model of Supervised Learning(Regression). It is used when we want to predict the value of a variable based on the value of another variable. The variable we want to predict is called the dependent variable.

Now we Have to Save the Model and Put in Docker Container so we can Create an Image and Push It in Docker Hub. So we Can Pull that Image Again And Again So we can use it In the future.

Docker Hub: — It Is A Centralized Repository where we Keep all the images so anyone can download from there and use the images.

Docker Provide us Container Which we Provision the OS within the second

Docker Container:- Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

=> Step to save the Model

filename = ‘final_model’
final = pickle.dump(model, open(filename, ‘wb’)

Now we have to Launch Docker Container first we have to pull the centos image:-

docker pull centos:7

After Launching Docker Container We have to install Python3 and Keras library in the Docker container.

yum install python3 -y
pip install — upgrade pip
pip3 install keras
pip3 install sklearn

Now we have to upload our model into Docker Container from our Base OS.

docker cp model_name container_id:/folder
docker cp ./final_model 12f5ecf40757:/model

Now we can check whether our model is working fine or not:

Here, we get our final result as we wanted. Thus, in this way, we can add a Machine learning model to a docker container for further use.

#Task-1

--

--