Machine Learning model inside Docker Container
Mohd Mubin Girach
MLOps & DevOps Engineer at NIQ Brandbank | Azure ML Studio | Kubernetes | OpenShift | Azure | AWS | RedHat & Microsoft Certified | Cloud & AI Infrastructure Specialist | Cloud-Native AI Ops
Hola, readers !!
So, in this article I would be providing information on creating a Machine learning model inside a Docker container
First things first we need to install docker in our system
I am using a RHEL 8 virtual machine for it ,so to install docker we would use the following command
# yum install docker-ce
Once it is installed we would pull an image from docker registry
# docker pull centos:latest
Further we would be launch a container with the same image
#docker run -it centos:latest
Then once we are into the terminal we need our csv file containing the dataset
For which I would be using the container id which can be found using
#docker ps -a
Next we would copy the file to our docker container using
# docker cp <source of the file> containerid:<dest path>
No we need to install python3 and the import libraries needed for our machine learning inside the container
#yum install python3
#pip3 install pandas
#pip3 install sklearn
Now we would launch the python3 shell >import pandas and LinearRegression
Now ,we would start working on the model for machine learning basically data pre-processing steps
- -Read our csv file and assign a variable to it
- Reshape one of the column from 1D to 2D
- Assign a variable "y" to our second column
- Give another variable name "model" and save LinearRegression function into it
Our model is ready to go , let's fit the x & y variable into our model and then use it.
As our dataset contains 2 columns years of experience and the salary accordingly we can predict the salary based upon the experience of an employee
So we have successfully used machine learning inside our docker container, isn't it amazing do like and share your valuable comments
Software Engineer @ FinSpectra | Platform Developer-1 Certified Salesforce Developer | Salesforce QA Tester
3 年Great Mubin Brother