<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shashank Pulijala on Medium]]></title>
        <description><![CDATA[Stories by Shashank Pulijala on Medium]]></description>
        <link>https://medium.com/@shashankpulijala?source=rss-167aa6cad9b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2nWjoSdkajVXoCPO.jpg</url>
            <title>Stories by Shashank Pulijala on Medium</title>
            <link>https://medium.com/@shashankpulijala?source=rss-167aa6cad9b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 05:09:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shashankpulijala/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Attention is all you need]]></title>
            <link>https://medium.com/@shashankpulijala/why-attention-is-all-you-need-7b11e891bd88?source=rss-167aa6cad9b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b11e891bd88</guid>
            <dc:creator><![CDATA[Shashank Pulijala]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 18:53:19 GMT</pubDate>
            <atom:updated>2025-03-11T18:53:19.884Z</atom:updated>
            <content:encoded><![CDATA[<p>Attention is the foundation of Transformers, and Transformers form the core of all language models. Why is attention such a big deal?</p><p>Attention is a relatively new model. When the paper, “<a href="https://arxiv.org/abs/1706.03762">Attention Is All You Need</a>” was introduced, the authors didn’t know at the time that it would revolutionize NLP, AI, and, as you know, the entire world</p><p>From a broad perspective, attention is simply a series of dot products. A simple dot product used in a very smart way has disrupted the AI space.</p><p>RNNs and LSTMs</p><p>Attention came into picture when they replaced advanced LSTMs in NLP problems, particularly Machine Translation or Sequence to Sequence tasks</p><p>The Sequence to Sequence tasks had an Encoder-Decoder model. For example, in machine translation from English to French, the encoder processes the English tokens, while the decoder processes the French tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*6oXN51oA2025Tr1qHDHu9w.png" /></figure><p><a href="https://medium.com/one-minute-machine-learning/sequence-to-sequence-learning-with-neural-networks-2014-one-minute-summary-bce5e24c5e0c">https://medium.com/one-minute-machine-learning/sequence-to-sequence-learning-with-neural-networks-2014-one-minute-summary-bce5e24c5e0c</a></p><p>As you can see above, LSTMs Encoders and LSTMs Decoders. Here each token t1 goes into the network and goes through a non-linear transformation like RELU or tanh. (I won’t explain RNNs or LSTMs here) But intuitively speaking the information gathered is squished into a context vector (A single layer with all the vectors concatenated). And that information is passed to decoder. Here the problem is that</p><ol><li>They go through sequences, and Large vectors often take up lot of time. We cannot parallelize this process.</li><li>Another problem with LSTMs is Linear Interaction Distance, the difficulty with which distant tokens in a sequence can interact with each other. In other words, in long sentences, we might lose the interaction between a current word and a distant word that significantly affects its meaning.</li></ol><p>Ex : “<em>Ram Son of Dhasharadh, brother of Lakshman and Sita’s Husband is also a great warrior who killed Ravana</em>”</p><p>In the above sentence the interaction between Ram and ‘killed Ravana’ is very hard to capture with LSTMs. It is the same problem with Machine Translation. There is no direct interaction between words in Encoder to words in Decoder.</p><p>This is where attention comes into play.</p><p>Attention mechanism solves this problem. In a simple Self-Attention mechanism we can interpret that as a soft “key-value-query” lookup table. For your context what is a lookup table ?</p><p>Look-up table is simple. You have a query (For example it is d). You go through each key and when it matches with the query you pick the values of that key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*hBEXPztG1eTG_SyFggNvWQ.png" /><figcaption><a href="https://web.stanford.edu/class/cs224n/">https://web.stanford.edu/class/cs224n/</a></figcaption></figure><p>The above picture is a simple look up table where query d is checked in the keys and matched and corresponding value is the output.</p><p>Exactly like above, Attention is a soft-lookup table. Soft here means we are not matching the exact the token to token but we are trying to get the similarity between the two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*Dez07iDzQhxGi9gginUMNQ.png" /><figcaption>Attention mechanism as query-key-value mechanism (<a href="https://web.stanford.edu/class/cs224n/">https://web.stanford.edu/class/cs224n/</a>)</figcaption></figure><p>In the above image you query is the word you want to see the interaction with, and keys are the vector representation of the each word. You just take the product of q and all the keys and take A sum of them and get the output.</p><p>In Mathematical terms :</p><p>Consider a token x_i in the sequence x1:n. From it, we define a query qi = Qx_i , for matrix Q ∈ Rd×d . Then, for each token in the sequence x_j ∈ {x1 . . . , xn}, we define both a key and a value similarly, with two other weight matrices: kj = Kx_j , and vj = Vx_j for K ∈ Rd×d and V ∈ Rd×d</p><p>Here x_i represents the word which we are trying to search for and x_j is the word with which we want to check the association of x_i.</p><p>We take a contextual representation h_i as</p><p>https://latex.codecogs.com/svg.image?\sum_{j=1}^{n}\alpha_{ij}v_j&amp;space;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/0*von6vjoU7Bu0Faes" /></figure><p>where where the weights, these αij control the strength of contribution of each vj . Going back to our key-value store analogy, the αij softly selects what data to look up</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/0*S2B2MH_CdXeQjZKO" /></figure><p>Intuitively, we take xi and look in its own sequence x1:n to figure out what information from what other tokens, should be used in representing xi in context. The use of matrices K, Q, V intuitively allow us to use different views of the xi for the different roles of key, query, and value.</p><p>In the below image you can see how Attention can be used in Machine Translation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LRXgCAgtYaYs3MjV9G-osg.png" /><figcaption>Attention in Neural Machine Translation (<a href="https://web.stanford.edu/class/cs224n/">https://web.stanford.edu/class/cs224n/</a>)</figcaption></figure><p>Now you can see that it solves the above two problems :</p><ol><li>It can be parallelized</li><li>It can solve the dependency of tokens on distant tokens.</li><li>It also solves the vanishing gradient problem in LSTMs</li><li>Not only that, it gives explainability in various other use-cases <br>By inspecting attention distribution, we see what the decoder was focusing on. Even in Language models we can see which word query has the closest similarity with respect to the words (keys)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-qpldtCOq5yIxdzOg4SEUg.png" /><figcaption>The query word learned and its attention weights with some other words in the sentence. (Taken from the slides of <a href="https://web.stanford.edu/class/cs224n/">https://web.stanford.edu/class/cs224n/</a>). You can clearly see that apart from learned it forms good weights with CS and Stanford.</figcaption></figure><p>Attention is the core part of the Transformer models and they form the heart of Language models like GPT, Gemini and LLama</p><h4>References</h4><ol><li><a href="https://web.stanford.edu/class/cs224n/">https://web.stanford.edu/class/cs224n/</a></li><li>Neural Machine Translation <a href="https://arxiv.org/abs/1409.0473">https://arxiv.org/abs/1409.0473</a></li><li>Attention is All you need <a href="https://arxiv.org/abs/1706.03762">https://arxiv.org/abs/1706.03762</a></li><li><a href="https://web.stanford.edu/class/cs224n/readings/cs224n-self-attention-transformers-2023_draft.pdf">https://web.stanford.edu/class/cs224n/readings/cs224n-self-attention-transformers-2023_draft.pdf</a></li><li><a href="https://medium.com/one-minute-machine-learning/sequence-to-sequence-learning-with-neural-networks-2014-one-minute-summary-bce5e24c5e0c">https://medium.com/one-minute-machine-learning/sequence-to-sequence-learning-with-neural-networks-2014-one-minute-summary-bce5e24c5e0c</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b11e891bd88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ML Security — Adversarial attacks]]></title>
            <link>https://medium.com/@shashankpulijala/ml-security-adversarial-attacks-68da1c758136?source=rss-167aa6cad9b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/68da1c758136</guid>
            <category><![CDATA[ml-security]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[adversarial-attack]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Shashank Pulijala]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 20:00:40 GMT</pubDate>
            <atom:updated>2024-02-13T20:00:40.103Z</atom:updated>
            <content:encoded><![CDATA[<h3>ML Security — Adversarial attacks</h3><p>While doing a master&#39;s course, I luckily found a good Mentor as a guide to delve deep into Adversarial Attacks in AI (Hacking in AI for starters). I wish to delve deeper and post my findings, learnings, and projects here. Also, as an AI Engineer working for a Research company I got involved in a Network Intrusion Detection Project which was predicting or detecting if there is any attack in the network data. I plan to work on a similar project, which will be uploaded on GitHub, and share a tutorial soon.</p><h4>What is Adversarial AI / Adversarial Attacks</h4><p>As we see ML and AI systems everywhere, from our smartphone applications, Face Recognition systems, Self-driving cars, and whatnot, it is important to develop enough security in the systems. This is where it is important to understand what are these attacks/ what are these Adversaries.</p><p>Imagine a self-driving car/an autonomous car where you have activated auto-pilot. There is a stop sign that the ML system detects as a stop and stops the car.</p><p>But there is a way that the same stop sign, with a small change undetected by a human eye, can fool the ML system into believing that it is not a stop sign. Here the attacker simply introduces a small change in the image which can&#39;t be seen by a human eye, to fool the ML system. This kind of attack is called FGSM attack i.e. Fast Gradient Sign Method (will explain in upcoming posts). If the human eye can’t see the picture, what can we do anything about it? This is the key problem that is to be solved by ML security. This is still a niche area, and there aren’t many techniques that are effective in stopping these attacks from happening.</p><p>There are different ways these attacks can be manifested.</p><p>Typically, an attack could be</p><ol><li>An evasion attack</li><li>A Poisoning attack</li></ol><p>An <strong>Evasion attack</strong> is when the attack is introduced as manipulation in data to confuse the model into making a wrong prediction. During an evasion attack, the attacker crafts adversarial examples by perturbing legitimate input data to induce misclassifications or incorrect predictions from the model. These perturbations are often imperceptible to humans but can cause the model to make erroneous decisions.</p><p>A <strong>Poisoning attack</strong> is to attack the model itself during the training process. The perturbation is introduced during the training process. The primary goal of a poisoning attack is to manipulate the training data to compromise the model’s performance, introduce biases, or cause the model to make incorrect predictions about future data. Poisoning attacks can lead to various security and privacy risks, including model degradation, unauthorized access, information leakage, or exploitation of vulnerabilities.</p><p>The main difference is Evasion attack is introduced during the testing process and the Poisoning attack is introduced during the training data. While Evasion attacks are easy to introduce they are harder to detect.</p><p>It is also important to note two types of attacks that can occur during the Testing phase. These are <strong>White Box and Black Box attacks</strong>.</p><p>Simply speaking <strong>white box </strong>attacks are those when the attacker has complete access or some access to the model and model weights.<strong> Black Box</strong> attacks are those when the attacker has very limited access to the model or model weights but can somehow query it to get outputs based on the inputs.</p><h4>Some of the real-world examples of the attacks</h4><ol><li>Tesla&#39;s autopilot system goes weird when salt is poured on the ground. It might drive into the traffic when salt appears on the ground. Also, Tencent labs showed that Tesla autopilot behaves weirdly when stickers are placed on the ground.</li></ol><p><a href="https://spectrum.ieee.org/three-small-stickers-on-road-can-steer-tesla-autopilot-into-oncoming-lane">Three Small Stickers in Intersection Can Cause Tesla Autopilot to Swerve Into Wrong Lane</a></p><p>2. Malware classifiers were attacked after carefully reverse-engineering what kind of featurizer was used. This is an example of a white box attack, as here the attacker has the knowledge of the model and was able to figure out some details about the model and the feature vectors used.</p><p>3. An Email Phishing mechanism where a bunch of carefully selected strings are added can fool the spam detection that the mail is non-spam. This is a text attack use-case, where added text can cause the model to interpret wrong. This is an example of an Evasion attack.</p><p><a href="https://arxiv.org/pdf/1810.08280.pdf">https://arxiv.org/pdf/1810.08280.pdf</a></p><p>4. A German artist used a lot of phones in one truck, to fool the Google Maps algorithm into believing that there was a huge traffic congestion in the area.</p><p><a href="https://www.wired.com/story/99-phones-fake-google-maps-traffic-jam/">An Artist Used 99 Phones to Fake a Google Maps Traffic Jam</a></p><p>5. Recommendation Engines: Use different tools to manipulate the Search algorithm to boost your rankings. A classic example of Search Engine Optimization.</p><p>6. Trading bots on Twitter: Some people used a lot of Hashtags and other characters to fool the Sentiment Analysis Classifier into pumping the price of the cryptocurrency with a lot of positive reviews.</p><p>In the next post, I am going to explain few attacks like FGSM attacks and in an other post will be talking about some defence techniques. I will make a separate post sharing my dissertation thesis, the idea and the code. Thats all folks!! Please share with interested people out there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68da1c758136" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MLOPs — 1. Model Tracking]]></title>
            <link>https://medium.com/@shashankpulijala/mlops-1-model-tracking-681aeed57dd3?source=rss-167aa6cad9b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/681aeed57dd3</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[mlflow]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Shashank Pulijala]]></dc:creator>
            <pubDate>Mon, 17 Apr 2023 15:30:26 GMT</pubDate>
            <atom:updated>2023-04-17T15:30:26.755Z</atom:updated>
            <content:encoded><![CDATA[<h3>MLOPs — 1. Model Tracking</h3><h3>WHY MLOPS?</h3><p>Let us start with how a Machine Learning project starts with.</p><p>There is some problem our stakeholder or a client has. They come to the data scientist to solve. Now as a Data Scientist,</p><ol><li>One has to study the domain and understand what data the organization has, and what kind of features can be used.</li><li>Then comes the experiments, Statistical Analysis, eliminating the features, a lot of data processing, and which might take months.</li><li>Then comes the experiments with the models and choose the best models. This all looks fine, but this is where the actual problem begins.</li></ol><p>Now, as a Data Scientist, you can’t go to your manager or stakeholder and give them the Accuracy or Precision results and expect them to be happy. You can’t just save the code and Model as a pickle file and make them do the rest. The following are expected at the least :</p><ol><li>The model has to be useful(To be put into production).</li><li>The whole data processing process has to be built as a pipeline. (From Database to CSV, to the required format that goes into the model).</li><li>An application to be built which can take the new data and predict the results (Or sometimes much more than that).</li><li>The application is to be contained in Docker (So that the end user doesn’t have to install all the packages again and again), and deployed into the cloud environment. It doesn’t end here.</li></ol><p>What about the changes in data? Data sampling and distribution change as time changes. What about the addition of new features or variables? The data gets added day by day or month on month or even by minutes if it is sensor data.</p><ol><li>The model has to be retrained every time the data changes or gets added up. And you are not always there to retrain, so it should be automated.</li><li>What about the result changes? What if the accuracy or precision dips after a while? The performance of the model might dip.</li></ol><p>There are a lot of additional challenges faced, to be handled — Like Production, Versioning shifts, etc.</p><p><em>This whole discipline starting from getting data to putting models into production with all challenges handled is termed MLOPS — Machine Learning Ops (like in DevOps).</em></p><h3>1.2 Maturity Model:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYG4tAuTwrdURUvipLALcg.png" /><figcaption>MLOPS — Different stages from Analysis and experimentation to putting everything in Production and automating it —( Content Image is taken from Ruf, P.; Madan, M.; Reich, C.; Ould-Abdeslam, D. Demystifying MLOps and Presenting a Recipe for the Selection of Open-Source Tools. <em>Appl. Sci.</em> <strong>2021</strong>, <em>11</em>, 8861. <a href="https://doi.org/10.3390/app11198861">https://doi.org/10.3390/app11198861</a>)</figcaption></figure><p>The maturity model is designed as a few stages where ML models are utilized. It starts from the basic stage to deployed stage.</p><ol><li>All the models and code are in Jupyter Notebook, still in the POC stage</li></ol><p>2. DevOps model is followed, but there is no MLOps. There is some automation, and good practices are followed. CI/CD pipelines and deployments have been done including unit testing etc. But there is no experiment tracking and no reproducibility.</p><p>3. Training and testing are automated, Data Scientists work with Engineers, also pipelines, tracking, model registry, etc are established. Multiple models are running in production at this stage.</p><p>4. Deployment is automated, easy to deploy model, ML platform is built, A/B testing done, ML with versions and monitoring exists.</p><p>5. Full MLOPs automation is done, everything is automated</p><p><a href="https://learn.microsoft.com/en-us/azure/architecture/example-scenario/mlops/mlops-maturity-model">Machine Learning operations maturity model - Azure Architecture Center</a></p><p>Follow this link to read about the Maturity model.</p><p>In this article, Tracking is explained clearly. I plan to make separate articles to explain the upcoming processes, but that is for later.</p><h4>Model Tracking</h4><p>Assume sitting and experimenting with different models on different samples of data on a jupyter notebook. You got the best accuracy on say, Random Forrest. You went to sleep and the next day opened the notebook and there were a hundred blocks of code and you were unable to find the Model.</p><p>In my experience, it happened to me a lot. It is very frustrating to find the model. Sometimes you rerun things and get minor errors that are very trivial but because of mismanagement, they get days to solve.</p><p>And it is very hard to track each model with each parameter with their accuracy scores in Excel. So we need a tool which automatically does this for us. The tool already exists, which is called ML Flow.</p><p>Enter pip install mlflow!</p><p>Lets us first see what MLFlow is on a brief level</p><h3>2. MLFlow :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wX24MHrY3mwTIdbbXrdflQ.png" /><figcaption>MLFLOW End-to-End Architecture (Image taken from DataBricks session, <a href="https://www.youtube.com/c/Databricks">https://www.youtube.com/c/Databricks</a>). Here the models are tracked and deployed.</figcaption></figure><p>MLFlow is a library made for Python exclusively to track and register the models and the data. Using MLFlow we can track any model, its metrics, loss, etc. It is very easy to use and the documentation is pretty good. To start with MLflow, go to Anaconda or the command prompt and execute the following command</p><blockquote>pip install mlflow</blockquote><p>Now MLFlow is installed and it is ready to be used.</p><p>According to their documentation, they define MLFlow as follows :</p><p>“<em>MLflow is an open-source platform for managing the end-to-end machine learning lifecycle. It tackles four primary functions:</em></p><p><em>Tracking experiments to record and compare parameters and results (MLflow Tracking).</em></p><p><em>Packaging ML code in a reusable, reproducible form in order to share with other data scientists or transfer to production (MLflow Projects).</em></p><p><em>Managing and deploying models from a variety of ML libraries to a variety of model serving and inference platforms (MLflow Models).</em></p><p><em>Providing a central model store to collaboratively manage the full lifecycle of an MLflow Model, including model versioning, stage transitions, and annotations (MLflow Model Registry).</em>”</p><p>Not only Python, mlflow can be used with R as well. MLFlow has a UI as well, where you can launch it on the browser and check out different stuff like how the model behaved, how the loss behaved etc.</p><h3>2.1 Model Tracking — MLFlow</h3><p>Let us see how it works with an example.</p><p>I have taken an example dataset and ran a few models and tracked them in MLFLOW. Just to demonstrate what MLFLOW looks like, see below</p><p>First, check if MLFLOW is working in your terminal. It should look like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZKv8SV1CrB_OyilXot-Yw.png" /></figure><p>I have used AWS instance to run the whole thing. The code I have used and modified is from <a href="https://github.com/DataTalksClub/mlops-zoomcamp">Datatalks club community</a>. For a complete Notebook, follow this <a href="https://github.com/shashankpulijala/MLOPS">link</a> for a simple Tracking implementation on a different data set.</p><p>Open Jupyter Notebook, and import dependencies.</p><p>Go to your directory in your terminal and run the following command to run MLFlow UI.</p><blockquote>mlflow ui — backend-store-uri sqlite:///mlflow.db</blockquote><p>Here we are asking MLFlow to load UI and we are asking to take the backend as SQLite with a new db as mlflow.db.</p><p>And view it at <a href="http://localhost:5000/">http://localhost:5000</a>.</p><p>By default, wherever you run your program, the tracking API writes data into files on a local ./mlruns directory.</p><p>Now to run MLFLOW in Python,</p><pre>import mlflow<br><br><br>mlflow.set_tracking_uri(&quot;sqlite:///mlflow.db&quot;)<br>mlflow.set_experiment(&quot;nyc-taxi-experiment&quot;)</pre><p>Here we are setting the tracking URI to be sqlite:///mlflow.db as we already used in the UI command.</p><p>For more explanation, please go through the Quickstart tutorial from MLFlow <a href="https://mlflow.org/docs/latest/quickstart.html">https://mlflow.org/docs/latest/quickstart.html</a></p><p>To run a model and track parameters in MLFlow, I have provided an example of code block, where I trained LR model on NYC taxi data to predict the duration of the trip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*77cwxpOr08iqrOCSdW2i7A.png" /></figure><p>The above code is straightforward. with mlflow.start_run() method is how you start MLFlow code. So, put everything under it. To briefly explain the code step by step :</p><ol><li><em>set_tag</em> sets the tag. I am setting a tag called “developer” and “shashank-pulijala” is my name — easy to search the models in UI.</li><li><em>log_param </em>logs the parameters. Here I am setting the path and tagging it with a parameter name.</li><li><em>log_metric </em>logs the metrics. It would become easy to separate these out from parameters. These metrics can be visualized on the UI.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2EZiW2ZMb1D0DyDIYETFQ.png" /></figure><p>To get the maximum benefit of MLflow tracking, we can use Hyperopt and get the best model. We can track all the models and see the results and metrics in the UI very easily.</p><p>Follow this in depth post from MLFlow for understanding more about Tracking.</p><p><a href="https://mlflow.org/docs/latest/tracking.html">https://mlflow.org/docs/latest/tracking.html</a></p><pre>from hyperopt import fmin, tpe, hp, STATUS_OK, Trials<br>from hyperopt.pyll import scope</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02f_n2_B-xfhr-c-YEBD6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*e1DBummc6kSwLfrM0fTplA.png" /></figure><p>The objective function above gives the objective for the hyperopt to optimize. In the function, XGBoost is taken as the key model, to train and the metric to look at is the RMSE score, that is to minimize the RMSE score. The search space defined in the next block will go in as the parameters to the XGBoost and train with each set and the best result is taken.</p><p>Now, you can simply go to the UI and check which is the best parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGy0DiIHSvoeI0JM3Qn3QA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b3CUKYvdqOm_JUZb0tM2xA.png" /></figure><p>Now I took the best parameters and trained the model. We can use the auto_logging feature in MLFlow to log parameters and metrics. It is very easy and useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*lR3xhYq9_kYTtd-0aydhYw.png" /></figure><p>I am also saving the models as artifacts using Pickle. I am logging the model at the end. UI understands the purpose of the model and gives us the option to register. Registering the models is out of the scope of this post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OCSDESIBixcCcRky4U6LFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mkrop2WsgkMs-gTZNtLU-A.png" /></figure><p>Autologin action. I have used multiple models here and in each run, the models are tagged along with their params, metrics, and the models are saved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h497DUZzMRCkP4ATuXEo6w.png" /></figure><p>The models can be registered and easily deployed and put into production. I will post the next tutorials in the coming days.</p><h4>References</h4><ul><li><a href="https://mlflow.org/docs/latest/tutorials-and-examples/index.html">Tutorials and Examples</a></li><li><a href="https://learn.microsoft.com/en-us/azure/machine-learning/concept-model-management-and-deployment?view=azureml-api-2">MLOps: Machine learning model management - Azure Machine Learning</a></li><li><a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/manage/mlops-machine-learning">MLOps with Azure Machine Learning - Cloud Adoption Framework</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=681aeed57dd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>