Prediction Model on Docker Container

Shivani Mandloi
3 min readMay 27, 2021

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 the docker container

◼ In Container you need to copy/create a machine learning model which you have created in the Jupiter notebook

Let's get started..!!!

👩‍💻 Prerequisite

Docker configured in base OS

  1. Launching a Docker container named SalaryPrediction

Further, In this container, we will create a prediction model.

2. Installing Python in the docker container using command

#yum install python3

3. Now to create a machine model we need certain modules and library

so, for installing we use pip3

packages needed:

  • pandas
  • sklearn

using command #pip3 install <library_name>

command to install pandas library
command to install sklearn library

4. Creating a workspace for the project.

5. Now, to train the model in docker container we need a dataset inside a docker container

here, I am using an experience /salary data set

so coping dataset from base OS to docker container using the following command

coping dataset from base OS to docker container

6. Create a python file model.py this file will train and create a model based on a given dataset.

6. Running model.py to train and create our model that will predict an employee's salary based on their experience.

7. Now, creating a python program that will predict an employee's salary using the above-trained model.

this file is internally loading the trained model

Now let’s check our model,

Running prediction.py

Giving input to the model

And our model is working …

Hope you find it interesting..!!!

--

--