Training a ML Model usin Docker Container

Training a ML Model usin Docker Container

Description:

  • Pulling a Docker image of CentOS from DockerHub and creating a new container.
  • Launching the Docker container.
  • Installing Python on top of the Docker container.
  • Installing the required libraries for the machine learning model.
  • Creating and running the Python code, and getting the desired output.


STEP 1:

  • The first step is to check whether Docker is installed in the system or not. For installing Docker the command used is:- "yum install docker-ce".
  • Checking the status of Docker if it's running or not, the command used is:- "systemctl status docker".
  • Then pulling the Docker image of CentOS from DockerHub and creating a container.
No alt text provided for this image
  • For launching the container the command used is:- "docker run -it --name <CONTAINER_NAME> <OS_NAME>:<version>".
No alt text provided for this image

STEP 2:

  • Installing Python on top of the docker container using the command:- "yum install python 3".
No alt text provided for this image
No alt text provided for this image

STEP 3:

  • Copying the data set from the local host (Base OS) to the Docker container on which we train the ML model.
  • The command used for the above stated step is:- "docker cp <file_name> <container_name>:<dest>"
No alt text provided for this image
  • Starting the container in Docker using the command:- "docker start <container_name>".
No alt text provided for this image

STEP 4:

  • Installing the required libraries to load the Machine Learning model, the command used to install these libraries is:- "pip3 install <library_name>".
No alt text provided for this image
No alt text provided for this image
  • Creating the Python code for prediction using Linear Regression.
No alt text provided for this image
  • The output of the Machine Learning model:
No alt text provided for this image

I hope that this article helps in gaining an insight of how to train a ML model on Docker, and if there is any feedback please feel free to reach out.

Thank You.

To view or add a comment, sign in

More articles by Ritvik Ranjan

Others also viewed

Explore content categories