Machine Learning Model Inside Docker Container..

Machine Learning Model top of CentOS Container..

Hello All …!!

Here I am come with new concept and task and that is launch our basic Machine Learning Model inside the Docker Container.Here for launching the model we use CentOS Image. But before processed further we have to know about basic concept of ML and docker.

Machine Learning :

Machine learning (ML) is the study of computer algorithms that improve automatically through experience and by the use of data. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as “training data”, in order to make predictions or decisions without being explicitly programmed to do so. Machine learning algorithms are used in a wide variety of applications, such as in medicine, email filtering, and computer vision, where it is difficult or unfeasible to develop conventional algorithms to perform the needed tasks.

Docker :

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.

Now we have first install the docker service and for that we have to configure the repo for docker installation. This all are basic concept ,for your understanding refer the below article in that I already give all the process of docker installation.

From above article you can take the part which is important for docker installation. Docker installation is must because with out that we can’t do any further activity.

Now our actual task start. Our docker is installed , for confirmation run the below commands …

command:
docker --version
docker info

Now you can see our command run successfully that means docker is installed properly. So we are ready to do further things..

Now after installing docker we have to start the docker service to use. for that use below command ..

systemctl start docker

After start ,if you want to check the status of that service that either it is running or not then for that run below command ..

systemctl status docker

Here we can see our docker is in running mode it means our service started successfully.

Now our next step is pulling the image which we want to launch the container. Here I am using CentOS : latest image.

Now using that image , we can launch the container for that we use below command ..

docker run -it --name (give name to container) (Image name:(version)

Now we have successfully launched the container and we are inside the docker container named “mlmodel”.

we can also check our container is launched successfully or not using “docker ps” command.

See our “mlmodel” OS is running great.

Now to run Machine Learning code we need python software. So first install python using yum command..

yum install python3

Now we also required some more python libraries like pandas & scikit-learn which we are using for model creation.

pip3 install pandas
pip3 install scikit-learn

Now lets create some separate folder inside container to deploy our Machine Learning code.

Now before using Machine-learning model we need our dataset to be ready. so let’s copy our Salary dataset from host to docker container.

Now let’s write Machine-learning code to train the model based on given dataset. Here I am create one file giving .py extension for writing code.

Now run the above code and our model created ..

python3 Task1

Here we can see our code run successfully and our model trained & also saved successfully.

Now we have to test our trained model so let’s write code to test our model. For that also we have to create the new file.

Now we have to run that code and predict the salary by giving the experience. So let’s check..

Here we can see our model is working properly and it also predicting the salary for given experience.

So that set our model created , train and predict the values successfully. I hope this article help you and you also created your own model..

Thank you so much for reading this . If you like it then please clap. And also want to connect me then below is my LinkedIn profile link …

Thank you so much…Keep Learning..

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store