Machine Learning in Docker

Vibhanshusharma
3 min readMay 27, 2021

Aim-

To create/copy model created using Jupyter Notebook in Docker container and using it to predict values.

Here the image used is of CentOS.

The base OS on which docker is running is Redhat

Machine Learning

Machine learning is an application of artificial intelligence (AI) that provides systems the ability to automatically learn and improve from experience without being explicitly programmed. Machine learning focuses on the development of computer programs that can access data and use it to learn for themselves.

The process of learning begins with observations or data, such as examples, direct experience, or instruction, in order to look for patterns in data and make better decisions in the future based on the examples that we provide. The primary aim is to allow the computers to learn automatically without human intervention or assistance and adjust actions accordingly.

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.

Steps required to complete the task

1 Install the docker in Redhat with the help of Yum.

“yum install docker-ce —nobest”

2 Start the docker by entering the command.

“systemctl start docker”

3 Pull centOS image and run it.

In my case centOS image was already there so no need to download again.

4 Install python and all other packages required to run the model.(Scikit-learn, pandas and joblib using pip after python is installed.)

5 Now create the model in Jupyter Notebook.

6 Now we need to copy the file i.e ‘marks.pk1’ to the base OS in which docker is running which in my case is Redhat. For this you need a software which is called WinSCP(used to copy files from one OS to other OS).

Now the files are copied to Redhat.

7 Now go to the location in your Redhat.

Here marks.pk1 is copied

8 Now to copy the file from Redhat to your CentOS on docker you need to know the name of the container by using command “docker ps” and after that write the following as shown in the picture below.

Here elastic_ganguly is my docker name.

9 Now locate the file in your Docker container.

You can see the file is copied successfully.

10 Now use this file to predict.

Task is done.

Hence the task is completed successfully.

--

--