ML with Docker for Salary Prediction

chinmay waykole
3 min readMay 27, 2021

HOLAAAA🙌

In this blog I am going to make a Machine learning model in a docker container, for predicting the salary of a person according to the years of experience the person has.

Let us first know what Machine learning and docker is:

Machine Learning

The field of study that gives computers the ability to learn without being explicitly programmed is called machine learning. Machine learning is a program that learns from past experience(E) with respect to some tasks(T) and performance measure (P), if it’s performance tasks in T as measured by P improves with experience.

Docker

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.

Technologies used

👉Python

👉Docker

👉Linux

Lets Begin!!!! 🤩

Step1

Pull the centos docker image by using docker pull centos:8 as shown in fig1
make sure you have a active connection.

Step 1

Step 2:

Now launch the docker container using
docker run -it — name <name_of_container> centos:8

Step 2

Step 3:

To know what container is active open a new terminal and use the docker ps command to check . This shows the container name, image name and status.

Step 3

Step 4:

Now we have to import the dataset and model in the container to do this first make sure you have these files in your file manager in Linux and go to the respective directory
To copy use command docker cp SalaryData.csv ML:/SalaryData.csv where ML is the container name.

Step 4

Step 5:

To install Python use yum install python3.
Check to have yum configured on your device.

Step 5

Step 6:

Install numpy, pandas, scikit-learn using pip3 install command

Step 7:

create a python file to edit using vi salary_pred.py

Step 7

Step 8:

Press i to edit the file and type the following code where we call the model and predict the result.

Step 8

Step 9:

Run the code using python3 command

Step 9

Here is my GitHub repository

Contact me on LinkedIn for any queries:

Thank you!!😊

--

--