Deploying Machine Learning model using python in Docker Container
Task Description:
- Pull the docker container image of CentOS image from Docker Hub and create a new container
- Install the python software on the top of docker container
- In Container you need to copy / create machine learning model which you have created
Machine Learning:
It is a branch of Artificial Intelligence which focuses on the the use of data and algorithms to imitate the human intelligence in the way the humans learn gradually and improving its accuracy.
phases implemented during a machine learning project are data collection, feature selection, data pre-processing, building datasets, model training and refinement, evaluation, and deployment to production.
Docker:
Docker is a open source toll 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 ship it all out as one package . All that is needed for programs distributed through Docker is inside the image and does not intersect with the primary system and other containers.
In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things.
Docker is a tool that is designed to benefit both developers and system administrators, making it a part of many DevOps (developers + operations) toolchains.
Pre-requisites:
- Linux[RHEL 8]
- Docker installed
Step 1: Start Docker and check status of Docker
To start Docker use command: <systemctl start docker>To check status of the docker use command: <systemctl status docker>
Step 2: Launch Docker image
Step 3:To Check that you are inside the OS that you have launched
command: cat /etc/os-release
Step 4: Now we need to install required packages to create a model
- If yum command is not working
- Python installation
command : yum install python3
- Install numpy , pandas, Scikit-learn Libraries
command: pip3 install numpy command: pip3 install pandas
command: pip3 install Scikit-learn
Step 5: To copy file from base OS (RHEL 8) to Docker container
command: docker cp <file_name> <docker_id>:<path in which file to be stored in the container>
Step 6: Open the python file
command: vi salary_predictor.py (vi <program_filename>)
Step 7 : Execute the program
command: python3 salary_predictor.py