Implementation of Machine learning model in Docker container
Task 01 👨🏻💻
Task Description 📄
👉 Pull the Docker container image of CentOS image from DockerHub 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
Step 1
👉 Pull the Docker container image of CentOS image from DockerHub and create a new container
For pull container image we write command :
“docker pull centos” #by default take latest version
For Run container we use command:
“docker run -it <name_of_container>”
and we can take container name as we want for these we use command:
“docker run -it — name <choice_name> <original_name>”
Step 2
👉 Install the Python software on the top of docker container
We have to install python3 in our container
so we use the command:
“yum install python3”
We also need of some other packages and library to perform machine learning model like
1. sklearn pandas
2.scikit-learn
Now we copy our dataset(.csv) file into docker container from the base OS(linux) .we use command:
docker cp <name of dataset with full path> <image ID>: <path where to paste>
Now we can check our dataset file is in our container
We need to install vim for writing python code
so we use command:
“yum install vim”
Step3
Now our all system is setup we just write a python code of implement machine learning model .In this code we use linear Regression model
Step5
In python code ,we created a model and we split our data also in train and test data .now in last we print our model’s coefficient value and we also predict the output at input(x=2.5)
so that’s all.
This is how we can simply apply machine learning predictions inside a docker container.