Integration of ML and DevOps

Integration of ML and DevOps

We make Model in ML so we can find a formula using experiences.Here,we also made some Model but The Accuracy of the Model really matters a lot because in today's world ,almost everything is dependent on Machine auto Intelligence(comes from the Model) and so the correctness of the Model matters alot.

But it becomes hectic to make a good model because of many hyperparamaters(parameters which we need to set by own) so as to acheive good Accuracy and takes Much Time.

But in today's world,we have became much dependent on machines that we can't wait much ,also can't do such manual things in machine;s world.

So,here I tried toautomate the process of changing hyperparameters.Although there are many hyperparameters we need to change to acheive Wished accuracy;

But here I tried to automate the setting of No. of neurons.

Less Neurons becomes insufficient for traning and making general formula ,in short, good model can't be acheived.

More Neurons do Overfiiting,means learn dataset or a same pattern so Model not expertise on different-different patterns.

Hereare steps for my task.

  1. Create container image that’s has Python3 and Keras or numpy installed using dockerfile.

When we launch this image, it should automatically starts train the model in the container.

2. Create a job chain of job1, job2, job3, job4 and job5 using build pipeline plugin in Jenkins.

  •  Job1 : Pull the Github repo automatically when some developers push repo to Github.
  • Job2 : By looking at the code or program file, Jenkins should automatically start the respective machine learning software installed interpreter install image container to deploy code and start training( eg. If code uses CNN, then Jenkins should start the container that has already installed all the softwares required for the cnn processing).
  • Job3 : Train your model and predict accuracy or metrics.
  • Job4 : if metrics accuracy is less than 80% , then tweak the machine learning model architecture.
  • Job5: Retrain the model or notify that the best model is being created.

3. Create One extra job job6 for monitor : If container where app is running. fails due to any reason then this job should automatically start the container again from where the last trained model left.

1. Create container image that’s has Python3 and Keras or numpy installed using the Dockerfile.

No alt text provided for this image

The Dockerfile for image t3:v1.

Code for Model is in this FinalModel.py ,this file will be pushed by the Developer.The code will be pushed to remote repository.

No alt text provided for this image

The Remote Repository is mlt3 github repo.

No alt text provided for this image

The github link for Reference is:

https://github.com/asthagoel01/mlt3.git

Now,code present on Remote repository https://github.com/asthagoel01/mlt3.git will be triggered using Poll SCM trigger so that,updates will be there in Every seconds.

No alt text provided for this image
No alt text provided for this image

Output for the program;

No alt text provided for this image

 Job2 : By looking at the code or program file, Jenkins should automatically start the respective machine learning software installed interpreter install image container to deploy code and start training( eg. If code uses CNN, then Jenkins should start the container that has already installed all the softwares required for the cnn processing).

Now,We run check.py file where we read the file in which code for model is written and if word convD is found anywhere then CNN will be printed which shows that it is CNN model.

So,now the Model will run in a docker container using image t3:v1, containing all the libraries for CNN model are present.

No alt text provided for this image


No alt text provided for this image

The file to check whether the code for the CNN Model is check.py.

The Reference for file is:https://github.com/asthagoel01/trying.git.

No alt text provided for this image


No alt text provided for this image


No alt text provided for this image


6. Job3 : Train your model and predict accuracy or metrics.

Now,the docker container will be restarted in which Model was trained using FinalModel.py in t3j2 so that accuracy of the Model can be seen.

No alt text provided for this image


No alt text provided for this image


No alt text provided for this image



Job4 : if metrics accuracy is less than 80% , then tweak the machine learning model architecture.

Job5: Retrain the model or notify that the best model is being created.

Here, I made a new folder pre.In this,I copied file pushed by developer present in T3Job1 workspace.Developer pushed FinalModel.py file.Also there's code to write a text file(contain accuracy of the model) is also written in FinalModel.py file.So, I am copying both files(python and text) into the pre folder.

So,I restarted docker container in which FinalModel.py was run in t3j2 so that,the text file stored in Docker Container can be accessed and accuracy of the Model can be shown.

Now I also have another tweak.py file in my RHEL8 to tweak the Model in order to increase the Accuracy of the Model.

If the Accuracy of model is not 0.99 or 99%,then we will run tweak.py file in a new docker container using image that has interpreter installed already,so that 99% Acurracy can be acheived.

No alt text provided for this image
No alt text provided for this image

The file tweak.py is used to improve the Accuracy Model if the Accuracy of Model isn't 99% or 0.99.

Reference for this file(tweak.py):https://github.com/asthagoel01/trying.git.I used this file direct by RHEL8.I uploaded it on Github just for Reference.

No alt text provided for this image

Now,After comparing Accuracy,the Accuracy was found 0.9746 so,now tweak.py file will run to improve the accuracy of Model by increasing No. of Neurons in every turn until 99% Accuracy acheived.

But,Sometimes ,more no. of neurons do overfitting(because more neurons,learn pattern of dataset and fails for the new images).So,inside the tweak.py file ,I compares last accuracy with current and If current Accuracy is less than Previous Accuracy so,further model will not train and loop will be exited so that Best Accuracy(Previous Accuracy) will be shown.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image


No alt text provided for this image


No alt text provided for this image


No alt text provided for this image


No alt text provided for this image

On Best Accuracy Acheived ,mail will be sent to the Developer.

No alt text provided for this image

NOTE:

For Successfully sending email,I used email-extension plugin.After installing the plugin,we need to do these things also in Manage Plugins-->Configure System-->E-mail Notification.


No alt text provided for this image

Now,Email will be sent for every build by the choosing Always in the Default Triggers.

No alt text provided for this image

9. Create One extra job job6 for monitor : If container where app is running. fails due to any reason then this job should automatically start the container again from where the last trained model left.

No alt text provided for this image
No alt text provided for this image


To view or add a comment, sign in

More articles by Astha Goel

Others also viewed

Explore content categories