Creating Machine Learning Model on Docker Container
In this blog, we will be discussing how we will be creating a machine learning model in a Docker Container and using the model for some predictions. For the task, we will be creating a fundamental machine learning model which can predict height of son according to their father’s height.
First, we need to have Docker installed inside our Linux Operating. Here I am using RedHat Linux, so we need to configure yum to install docker. We need to create a .repo file inside our /etc/yum.repos.d/. We have created a file docker.repo, and then inside the file, we have configured the repo. You can see the below image for the same.
# yum install docker --nobest# systemctl start docker# systemctl enable docker
These command will install docker and will start docker service and enable it permanentaly.
# systemctl status docker
docker run -it --name Ml centos
After runing this command we will land on our docker os
Now we have to install python3 library
docker cp <file name> osname:path
By runing this command we will copy all the files in our docker container.
For running our ML code we need some libraries first we have to install pip3
#yum install python3-pip -y#pip3 install pandas#pip3 install sckit-learn#pip3 install joblib
Now we will run our linear regression code and this will create model and store model in height_predictor.pk file
Now this predictor.pk file we will use in our python code where we will take input from the user to predict height.
when we run predictor.py we will get output like this.
github url — https://github.com/A-zish/ML_Linear_regression.git