How to create a Machine learning model on docker

Anirudh Diwan
3 min readMay 30, 2021

Step-1

1.)Firstly install the docker on the base operating system.Now to pull the docker container image of Centos use the following command

docker pull centos:latest

2.)Now to run the container on base operating system use the following command

docker run -it — name anii centos:latest

STEP-2

To Install the python software on the top of docker container ,use the following command.

yum install python3-pip

To use various function,we need to import various libraries.We can install the libraries on container by using the following command

yum install pandas

yum install numpy

yum install sklearn

Step-3

1.)Now we need to copy the dataset from base os to container.

So firstly in the container we make a directory with name salary-prediction-model(mkdir salary-prediction-model).Now we can copy our dataset inside this directory salary-prediction-model with the help of following command.

docker cp Salary_Data.csv anii:salary-prediction-model

2.)Now inside salary-prediction-model directory we will create a file salary-prediction.py(vi salary-prediction.py).

And now in this file we will create our model and then save the model.

3.)Now we will create another file predict-salary.py.

Now in this file we will import our saved model and then we will the predict the salary on the basis of experience.

--

--