Skip to main content

MLOps - Tweaking Hyperparameters Automatically

 A time consuming task while training the Machine Learning models is to continuously tweak the Hyper-Parameters to reach our desired Accuracy. It is one of the reasons why most of the ML related projects fail. 

This can be resolved upto an extent with  MLOPs = ML+ DevOps

In this blog, I'm explaining my MLOPs project which trains and tweaks a CNN model for Cat and Dog prediction from the dataset. My project uses "Jenkins" as an automation-tool and "GitHub" where the developer pushes the code.

Requirements for setting up the project :

1. Git
2. Jenkins
3. Redhat 8 VM
4. Docker

Project :

Creating Environments :

I've created 3 environments (images) in Docker using Dockerfile for running my programs -
1) env1 - This environment is for running any basic program which uses numpy and pandas.
To run the container of env1 -
docker run -it --name con_Basic env1


2) env2 - This environment is for running Old ML programs which use sklearn.
To run the container of env2 -
docker run -it --name con_ML env2

3) env3 -  This environment is for runnig DL programs which use keras.
To run the container of env3 -
docker run -it --name con_DL env3


Build Pipeline : This is the build pipeline for my chain of jobs. 




Making the model :

I've made a Cat and Dog prediction CNN model which uses the concept of Deep Learning.  This is a Binary Classification model.

Layers which I've used are-

-> Convolutional Layer
-> Max Pooling Layer
-> Flattering Layer
-> Dense Layers

I've uploaded the code on my GitHub.
Here's the link of my GitHub repository :

https://github.com/aayushi1908/Task-3-MLOPs.git

JENKINS JOBS :

I've made 8 jobs for this project-

JOB1 -- Pulling the code from GitHub whenever developer pushes or makes changes in the code.

This job pulls the code from GitHub and copies it to a folder named /Aayushi in Redhat.



JOB2 -- By looking at the program file, Jenkins automatically starts the respective container ( Eg - For CNN code, it should start a container of my "env3")



JOB3 -- Train the model and predict accuracy or metrics.



JOB4 -- This job finds if  the accuracy is > 80 % or not.

In this job, we check whether our obtained accuracy matches our desired accuracy and if  it matches, an email is sent. If doesn't, the code is tweaked.

JOB5 -- Notifies the user about the accuracy obtained by sending an Email.





For EMAIL CONFIGURATION -

For email configuration, set-
1. Set IMAP enable in your gmail account settings.
2. Set Permissions as ON for Less Secure apps.

JOB 6 -- For accuracy < 80 %,  tweak code runs.



JOB 7 -- After the tweak accuracy is obtained, an Email is sent to the Developer.




JOB 8 -- This is an extra job for Monitoring. If the container where code is running fails, this job starts it again automatically.


      

Tweak Code Console Output - 

This is the Console Output of my tweak code. Have a look.












Comments

Popular posts from this blog

SIH 2020 : A kick-start from my not-so techie life

How Smart India Hackathon (SIH) participation has helped me to strengthen my competency and enhance my skill-sets? Hello everyone! In this blog, I'm going to talk about how SIH played an important role in building my passion towards acquiring technical skills. Do read till the end to know about all of my experiences. Do you believe in the concept of “IDEA”? Do you follow the principle of “Smart Work”? Well, my SIH experience directed me towards these!  I’m writing this blog to enlighten these topics and I’ll try to elaborate the importance of the above 2 questions in every engineering student’s life! SIH kick-started my non-technical life to a much focused one.   The concept of “Smart work beats hard work” suits my story! So, I decided to participate in SIH 2020 under the Software Problems domain. This domain asked for a Web app/ Mobile app to be made. I was eager to make a Web app as I knew Web development from basic level. Now a team needed to be made! So I communicated w

Testing and Production System environments - Jenkins-Docker

In real-world use cases,  it's a standard practice to treat development , test , and production systems differently because they have differing security, data, and privacy controls. No code is deployed directly to be presented before the user, firstly it is tested in a testing environment and if it works fine, only then it is deployed in the production system.  About the project - In this project, I have made 2 environments- one for testing and other for the production system . The code is pushed by the Developer to GitHub. The code is pulled into our system by a job of Jenkins and then it is tested in a Docker environment for its efficiency and working. If any changes or updates are needed to be done in the code, we do it in the testing environment. After successful testing, the code is deployed for the user. Setup - 1) Jenkins 2) GitHub 3) Git Bash 4) REDHAT8 Linux - Docker Jenkins Jobs - Job 1 - The developer pushes the code to GitHub. This job pull