<?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 Arpita Jshenoy on Medium]]></title>
        <description><![CDATA[Stories by Arpita Jshenoy on Medium]]></description>
        <link>https://medium.com/@arpita.jshenoy?source=rss-89eb300cc74f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Vkuhlj-SEXYI-SI_</url>
            <title>Stories by Arpita Jshenoy on Medium</title>
            <link>https://medium.com/@arpita.jshenoy?source=rss-89eb300cc74f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:51:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arpita.jshenoy/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[Beyond the Calculation: A Beginner’s Guide to Eigenvectors.]]></title>
            <link>https://medium.com/@arpita.jshenoy/beyond-the-calculation-a-beginners-guide-to-eigenvectors-5972262c72c6?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5972262c72c6</guid>
            <category><![CDATA[eigenvectors]]></category>
            <category><![CDATA[eigen]]></category>
            <category><![CDATA[eigenvalue]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Fri, 16 Jan 2026 12:49:06 GMT</pubDate>
            <atom:updated>2026-01-22T14:12:49.998Z</atom:updated>
            <content:encoded><![CDATA[<p>Most people learn how to calculate eigenvectors, but few learn why we <em>purposely</em> force a dimension to collapse to find them. This is the logic of the Eigenvector, explained simply.</p><p>In a world where vectors are constantly being rotated, stretched, and moved around, there are a few special directions that stay put. These are Eigenvectors — the unchanging axes that really define what a matrix is all about.</p><p>Now that we know what eigenvectors are, let’s explore what they do and how they reveal the essence of a matrix. When a transformation is applied to a regular vector, along with some scaling, it might change direction and lose its main feature. But these Eigenvectors don’t change direction; they only get scaled by a factor called an Eigenvalue. This eigenvalue tells us how important that vector is, and an eigenvector tells us which direction it points to, helping us discover its fundamental characteristics.</p><p>To help you grasp this concept, imagine we order a strawberry cake. How do we know we’ve received what we asked for? If we only looked at the color, it might be a raspberry cake or even a vanilla cake with a hint of pink. We recognize it as strawberry because of its taste. This taste is like an eigenvector. Even though the strawberries are mixed in completely (transformed), the flavor (eigenvector) remains the same. It’s the main ingredient, and the strength of the strawberry flavor (eigenvalue) tells us how much we taste it in the cake.</p><h3><strong>Application in the real world:</strong></h3><p>Eigenvectors are more than just a mathematical concept; they’re the foundation of linear algebra, helping us understand how features behave and what makes them special. They’re not just for machine learning, but they’re used in many fields, and let’s dive into how they’re used in ML. I think visualizing this will really help you grasp it better.</p><p><strong>PCA (Principal Component Analysis):</strong>PCA is a tool for simplifying data. Imagine you have a training set with lots of features, all laid out in a matrix. But not every feature is helpful! Some might be super important, while others might not add much to figuring out the outcome. Keeping all those features can be a lot for the computer to handle, so we want to focus on the ones that really matter.</p><p>Now, how do eigenvectors come into play? When you transform a vector of a feature, its direction changes. So, we can’t easily tell how much that vector has been scaled. But an eigenvector tells us exactly how much a feature has been scaled by looking at its eigenvalue. This helps us understand how much a feature contributes to the final outcome. By doing this, we can decide which features don’t add much value and remove them thus reducing the dimensions.</p><p><strong>Face/Speech Recognition:</strong>Here, we’re using eigenvectors in a unique way. Computers generate an eigen face or eigen speech dataset to identify the various features and how much they vary. So, what does this mean? Each eigenvector of a feature reveals its core characteristic. By keeping track of these eigenvectors and understanding how much they differ across all features, we can uncover the distinctive traits of a person’s face or speech pattern. This helps computers tell apart different faces or speech patterns, which is then used for inference.</p><p><strong>Word Embeddings:</strong>Word embeddings are a crucial component of natural language processing, and all transformers rely on them to grasp a word more effectively, ensuring accurate usage. Eigenvectors play a vital role in this process. Word embeddings are essentially matrices that represent a word as having numerous features or qualities, like different characteristics. When we think of a word as a multidimensional matrix, we apply transformations to it to learn its meaning. To do this, we identify the eigenvectors of each feature, which reveal the fundamental essence. The distance between the eigenvectors of different words indicates how similar or different the words are, aiding computers in understanding their semantic connections.</p><p>That’s why eigenvectors are so important in linear algebra — they help us identify the key feature that makes a vector stand out! Now, let’s explore the math and the reasoning behind it, as well as how to find the eigenvectors.</p><h3><strong>The Math:</strong></h3><p>After looking at the explanation above, we can say that: “any transformation(A) applied to an eigenvector(v) is a scaled(λ) version of itself(v)”. This can be mathematically written as : Av = λv.</p><p>Since eigenvectors only scales, the result of transformed v — scaled v must be 0. This gives us the equation: Av-λv = 0. This when further simplified gives us (A−λI)v=0.</p><p>We find eigenvectors(v) by first finding the scaling factor(λ). To do this, we use the fact, that for every A, there exists a λ that collapses a dimension of A.</p><p>To figure out that dimension, we use the idea of determinants. A determinant is like the area or volume of a matrix. When we’re talking about a transformation that just rotates a matrix, the determinant is 1 because the area or volume stays the same. But if the transformation scales up the matrix, the space gets bigger, so the determinant is greater than 1. And when the space shrinks because of the scaling down, the determinant is between 0 and 1.</p><p>We are using the fact that a transformation matrix A is collapsible (0 determinant) to a lower dimension space to figure out the scaling. det(A-λI)=0 tells us if the A, after removing the scaling is collapsible or not. To understand how this collapse happens in a specific direction, see the diagram below. I tried to show you a cube(3D) collapsing to a square(2D) because you made all the points in a given direction or dimension 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNjFkiqjqR8b02x_H6FbQg.png" /><figcaption>(I am bad at drawing, but hope you get the idea.)</figcaption></figure><p>Here, you see when this cube is squished along this line, becomes a square, thus losing a dimension(depth). A transformation matrix may scale a matrix by stretching width by a factor of $\lambda_1$ height by a factor of $\lambda_2$ and depth by a factor of $\lambda_3$. By doing (A−λI) for a height $\lambda_2$, we are making those points zero, collapsing that dimension, so solving for det(A-λI)=0, allows us to find the scaling factor(λ) which makes a dimension zero. Once, we have the lambda, solving for v, using the formula: (A−λI)v=0 allows us to find the axis that gets squashed(eigenvectors).</p><p>Let’s take a closer look: we begin by recognizing that eigenvectors reside in the null space of matrix A. To prove that A is collapsible and indeed has a null space filled with eigenvectors, we solve for lambda using the equation: determinant of A minus lambda times I equals 0. Wherever this equation holds, we’ve identified a dimension that’s collapsible and has a strength of lambda. Now, when we apply this A to an eigenvector v and then remove v along with its strength, we effectively remove or collapse those v values in A, which nullifies that dimension and, therefore, truly collapses it to the lower dimension. So, in essence, the strength factor lambda is what really matters when determining a feature’s strength, rather than the eigenvectors themselves, which are simply the features themselves.</p><h3><strong>The Bridge To Intelligence:</strong></h3><p>To wrap things up, we start by figuring out the lambda value that can collapse a dimension, which helps us find the null space of the matrix (A−λI). We know that the non-zero values in the null spaces are the eigenvectors, to find them, we use the RREF (reduced row echelon form), which helps us clean up the matrix by setting all the values outside the diagonals to zero, making it easier to spot the eigenvectors and shows the initial path that had fallen apart. Since (A−λI) collapses a dimension, we often find a free variable (the last row is always all zeros, showing that there are infinitely many solutions). This means we can represent all vectors along that direction, which is called the eigenspace.</p><p>So, why does this matter for AI systems? Well, every time a neural network spots a face or a Large Language Model guesses the next word, it’s essentially working through these very “skeletons.”</p><p>Eigenvectors help us squeeze huge datasets into smaller sizes by pointing out the most important “directions” of information — the ones that have the biggest impact on how things change. They’re also super important for understanding how stable algorithms are, which is crucial for creating AI that’s both efficient and easy to understand.</p><p>We started by looking at a scary characteristic equation: det(A−λI)=0. We came to see that it’s really about seeking the truth — finding the path where things stop being a mess and start to be straightforward. In the AI world, complexity is like the noise, but Eigenvectors are the clear signal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5972262c72c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cracking L1 & L2: The Simple Guide to Loss Functions and Regularization]]></title>
            <link>https://medium.com/@arpita.jshenoy/all-about-the-l-family-bb8c108e53cf?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb8c108e53cf</guid>
            <category><![CDATA[lasso-regression]]></category>
            <category><![CDATA[elastic-net-regression]]></category>
            <category><![CDATA[l1-and-l2-regularization]]></category>
            <category><![CDATA[loss-function]]></category>
            <category><![CDATA[weight-decay]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 11:39:13 GMT</pubDate>
            <atom:updated>2025-03-21T14:57:44.875Z</atom:updated>
            <content:encoded><![CDATA[<p>Hola!! Today I am explaining about the most common terms heard in Machine Learning “The L1s and L2s”. In this post, I will be explaining L1 loss, L2 loss, L1 regularization, L2 regularization and elastic net regularization as this is just a combination of L1 and L2 regularization. So brace yourself, for the journey is about to begin!!</p><h3><strong>A look at the L1 Loss and L2 Loss</strong></h3><p>When dealing with any ML problem, the model outputs the predicted value based on the pattern it has found in the data, now to see how well our model is doing, it looks at the loss value, which is a metric our model must minimize to make accurate predictions. The difference between metric and loss function is that the metric is a value which tells humans how accurate our model is getting, but loss function is a metric/value for machine, it is just a number that tells the model how much it has to improve.</p><p>In case of classification, the common loss functions are <a href="https://medium.com/@arpita.jshenoy/cross-entropy-explained-9a4de423901c">cross-entropy loss</a> for multi-class classification and <a href="https://medium.com/@arpita.jshenoy/binary-cross-entropy-loss-a-brother-to-cross-entropy-21612b8165b0">binary cross-entropy loss</a> for binary and multi-label classification. For regression, you use L1 and L2 loss function with L2 being more common. You’ll know why in a short while, so stay put.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*8NJPctdMWKe2ukD1hWyWcw.jpeg" /></figure><p>In the above image, you can see that there is a line of regression, that is supposed to best fit the data points(samples/examples/simply data) to predict as close to the true label as possible. How do we tell the model if it is fitting well, or it needs to be improved? well, one way to do that would be to measure the error each data point is making and average it over to know the average error. Now before reading further pause and think, how do we do that?</p><p>One way, would be to just take the difference between the predicted value and the actual value like,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*g1DOv15Tj0T34FUrHmxDtQ.png" /></figure><p>the first term is read as y-hat which refers to the predicted value, y being the actual value and m, number of data points.</p><p>Now think, what is the issue with simply using this formula for measuring the error.</p><p>If you guessed that the error made by data points that are above the line cancels out with the error made by the data points below the line, then you are right. This will make our mean error close to zero which is not true. As long as the data points, doesn’t fit the line well, the error should not be close to 0. So how do we fix it? The answer is simple, we can take the absolute of the difference like,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*d3BvgQ_Zs47I07THILHe9A.png" /></figure><p>This will make all the values positive and when you add them you get the correct error. This is L1 loss. It is nothing but taking the absolute value of the differences between predicted and actual values, sum it up and divide by number of data points. Simple isn’t it. This is also called Mean Absolute Error(MAE).</p><p>Now that you have understood MAE/L1 loss, let’s move on towards a very similar concept called L2 loss a.k.a., Mean Squared Error(MSE). Yes, if you have guessed what it is, then great, let’s look at the formula.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*eq9FD9Il_ZAocaOu9CMTUw.png" /></figure><p>Taking the square of the error, summing it up and taking the mean, gives you MSE and if you take the square root of it, you get the RMSE or Root Mean Squared Error which is commonly used as a metric to evaluate the regression model.</p><p>You may wonder why one would pick L2 over L1? Here’s the simple answer to that, we want to minimize the loss faster and what better way to do that than squaring the error which penalizes the data point with greater error. When you take the absolute, you take the exact error or distance between the target and the prediction. But when you square it up, the ones that are close to the line are spared and ones that are farther, are highlighted more so the model can focus on improving those targets.</p><p>This was all about the L1 and L2 loss function, these functions are used to update the weights accordingly to find the best fitting line. Let’s move on to Regularization, to see what it is used for.</p><h3>Understanding Regularization</h3><p>Before moving on to L1, L2 and elastic regularization technique, let us first understand what regularization is, and why do we need it. When there are too many features, some features might not be so important at all, but if we keep it, and try to fit our model to it perfectly, then it might overfit, trying to capture noisy(irrelevant) data. To reduce this overfitting so the model generalizes well and remove noisy data we use a technique called Regularization technique. There are many regularization methods, but here we will be discussing only the ones related to L1 and L2.</p><h3>L1 Regularization</h3><p>L1 regularization technique is typically used in regression models. This regularization is also called as Lasso Regression, used to address the issue of overfitting and reduce the complexity of the model. How? do you ask, let’s dig deeper about the mechanism of this technique.</p><p>L1 regularization works by adding penalty term to the loss function of the model. This penalty is based on the L1 norm(absolute value) of all the weights(model’s coefficients).</p><p>Total Loss= Original Loss Function + L1 penalty</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*XEIsnVl6dKWkRuM1Pxhrxg.png" /></figure><p>lambda is a hyperparameter(a non trainable value that is explicitly set, to help adjust the model’s coefficients to increase the accuracy of the model), that controls the strength of the regularization. The higher the value, the aggressive will be the regularization.</p><p>Now coming to our question about how this regularization helps reduce overfitting or simplify the model. The answer is, a more accurate model makes less error, which is measured by loss function and adding this penalty value to it only makes it higher, which means the model has to work extra hard to lower the loss.</p><p>Let’s say you have a feature that is not contributing to the model’s training enough, and the weights for it is high. This will only be a noise and results in higher loss and the model overfits the data trying to capture this noise. To reduce this loss the, the model takes penalty term into account and pushes those weights towards zero to reduce the loss. This reduction means that, that particular feature isn’t being considered for the prediction anymore, thus reducing overfitting and simplifying the model by eliminating that feature.</p><p>These effects can be categorized as:</p><p><strong>Generalizing effect:</strong> By shrinking the coefficients, the model becomes less sensitive to minor changes in the data, thus reducing overfitting and improving generalization.</p><p><strong>Feature Selection(Sparsity):</strong> L1 regularization can drive coefficients of less important features all the way down to zero. This removes those features from the model, performing a form of automatic feature selection. This can be particularly beneficial when dealing with a large number of features, as it helps identify the most relevant ones for prediction.</p><p>The model don’t shrink every weight with high absolute value, If the weight is a good fit, and reduces the loss, then even if the penalty term is high, it sort of balances it out, and the regularization will keep it from shrinking too much.</p><p><strong>Advantages of L1 regularization:</strong></p><ul><li><strong>Effective in Overfitting Control:</strong> L1 regularization is often more effective than L2 regularization (which uses the squared value of coefficients in the penalty term) in preventing overfitting, especially when dealing with correlated features.</li><li><strong>Feature Selection:</strong> The ability to automatically select features through coefficient shrinkage simplifies the model and improves interpretability, as you can see which features have the most significant impact on the prediction.</li><li><strong>Robustness to Outliers:</strong> L1 regularization is less sensitive to outliers in the training data compared to L2, as absolute values are less affected by extreme values.</li></ul><p><strong>Disadvantages of L1 regularization:</strong></p><ul><li><strong>Computational Cost:</strong> Finding the optimal solution with L1 regularization can be computationally more expensive than L2 regularization.</li><li><strong>Not Guaranteed for All Features to be Non-Zero:</strong> Unlike a perfect scenario where some coefficients become exactly zero, this might not always happen due to optimization algorithms.</li></ul><p><strong>Key points:</strong></p><ul><li>The L1 penalty term discourages large coefficients by directly penalizing their absolute values.</li><li>Minimizing the total cost function leads the model to shrink coefficients that contribute less to the fit while keeping the penalty term small.</li><li>This shrinkage can lead to feature selection (sparsity) when coefficients become zero, effectively removing less important features from the model.</li></ul><p>This is all about the L1 Regularization. Let us now move on to L2 Regularization.</p><h3>L2 Regularization</h3><p>This regularization is similar to L1 in terms that it helps in reducing overfitting and maintaining balanced distribution of model coefficients(weights). This is also called as Ridge Regression/ Weight Decay. Unlike L1, L2 regularization doesn’t push the model coefficients towards zero(we’ll see why later). Let’s now understand the mechanism of L2.</p><p>L2 adds a penalty term to the original loss function, just like L1, but the term is based on L2 norm of all the weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Ccx9WucVmS9oUfXzuYW9wA.png" /></figure><p>lambda is same as you have seen in L1 regularization.</p><p>This regularization, helps in reducing overfitting by penalizing the large weights. Weights, that have high values becomes exponentially higher, this will make loss value way higher. Which means the model will aggressively shrink the larger weights that doesn’t contribute to the loss function, but doesn’t necessarily push it to zero, why? because while the large weights becomes larger, smaller one becomes smaller(0.05² = 0.0025), this will balance the overall loss values and keeps the larger weights from shrinking too much.</p><p><strong>Impact on Coefficients:</strong></p><p>L2 regularization discourages the model from assigning very large positive or negative weights to features. Here’s how it affects the coefficients:</p><ul><li><strong>Reduces Overfitting:</strong> Large coefficients can make the model overly sensitive to specific features in the training data. L2 regularization penalizes these large values, encouraging the model to distribute its weights more evenly and become less reliant on any single feature. This helps the model generalize better to unseen data.</li></ul><p><strong>Advantages of L2 Regularization:</strong></p><ul><li><strong>Effective in Overfitting Control:</strong> L2 regularization is a simple and efficient way to reduce overfitting, making it a widely used technique.</li><li><strong>Improves Model Stability:</strong> By preventing extreme coefficient values, L2 regularization can improve the stability of the model, making it less prone to fluctuations in the training data.</li><li><strong>Computationally Efficient:</strong> Finding the optimal solution with L2 regularization is generally faster than with L1 regularization.</li></ul><p><strong>Disadvantages of L2 Regularization:</strong></p><ul><li><strong>No Feature Selection:</strong> Unlike L1, which can drive coefficients to zero, L2 regularization typically shrinks all coefficients but doesn’t eliminate them entirely. This means it doesn’t perform automatic feature selection.</li><li><strong>Less Robust to Outliers:</strong> L2 regularization can be sensitive to outliers in the training data, as squared terms can magnify their influence.</li></ul><p><strong>Key Points:</strong></p><ul><li>L2 regularization discourages large weights due to the squared term in the penalty, but it doesn’t eliminate them entirely.</li><li>The diminishing penalty for small weights in L2 makes it less effective for feature selection compared to L1.</li><li>L2 focuses on weight shrinkage, promoting a more balanced distribution and reducing overfitting.</li></ul><h3><strong>Choosing L1 vs. L2 Regularization</strong></h3><p>The choice between L1 and L2 regularization depends on the specific problem and data:</p><ul><li>Use L1 if feature selection and interpretability are important, or if you suspect outliers in the data.</li><li>Use L2 if computational efficiency is a concern, or if you don’t necessarily need feature selection but want to control overfitting.</li></ul><h3>Elastic Net Regularization</h3><p>This regularization technique brings the best of both worlds. It combines both L1 and L2 regularization by adding both penalty term to the loss function like,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pAkg2l-3KJLnYBMdn38s3w.png" /></figure><p>lambda_1 controls L1 regularization and lambda_2 controls L2 regularization.</p><p><strong>Advantages of Elastic Net:</strong></p><ul><li><strong>Effective Feature Selection:</strong> Borrowing from L1, the elastic net can drive coefficients of unimportant features to zero, leading to feature selection and a more interpretable model.</li><li><strong>Improved Stability:</strong> The L2 component from Ridge regularization promotes stability and reduces overfitting by shrinking coefficients towards zero, even if they aren’t driven all the way to zero by the L1 penalty.</li><li><strong>Handles Correlated Features:</strong> Unlike L1, which might arbitrarily choose one feature from a group of correlated features, the elastic net can handle correlated features better by allowing some shrinkage while potentially selecting some of them.</li></ul><p><strong>Tuning the Elastic Net:</strong></p><p>There are two hyperparameters to tune in the elastic net: λ₁ and λ₂. The ideal combination depends on the specific data and problem.</p><ul><li><strong>Higher lambda_1:</strong> Encourages more feature selection.</li><li><strong>Higher lambda_2:</strong> Increases coefficient shrinkage and reduces overfitting.</li><li>Often, a small value for Lamda_1 and a larger value for Lamda_2 is a good starting point.</li></ul><p>Use elastic net if you want to leverage feature selection, improve stability, and potentially handle correlated features better.</p><p>This is it for the detailed explanation of L1, L2 and ElasticNet regularizations and L1/L2 loss functions. Hopefully, I was able to explain the whole thing in an easy to understand way. Please leave a comment below if you need more explanation on something or if you want to add/correct certain info.</p><p>Happy Reading!!!</p><p>image credit:</p><p><a href="https://images.spiceworks.com/wp-content/uploads/2022/04/07040339/25-4.png">https://images.spiceworks.com/wp-content/uploads/2022/04/07040339/25-4.png</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb8c108e53cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring the depths of Explainable Artificial Intelligence(XAI)]]></title>
            <link>https://medium.com/@arpita.jshenoy/exploring-the-depths-of-explainable-artificial-intelligence-xai-acc4e3681f4e?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/acc4e3681f4e</guid>
            <category><![CDATA[xai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[explainable-ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Mon, 15 Apr 2024 08:14:54 GMT</pubDate>
            <atom:updated>2024-04-15T08:14:54.579Z</atom:updated>
            <content:encoded><![CDATA[<p>As we all know, that Artificial Intelligence, today has evolved so much that every organisation, every nation is talking about using AI to showcase their development. Why is this so? we know that it has been used for solving a lot of complex problems and surprisingly or not, it does so with great accuracy. But a lot has been unanswered, we know that a lot of matrix multiplication, partial derivatives and other mathy stuff is behind it, but many call it a blackbox as it doesn’t provide a reasoning behind the prediction it made. As AI algorithms are getting complex, being used in various aspects of our lives and so many things rely on it’s predictions, wouldn’t it be crucial for us to understand how these predictions are being made? This reasoning will help us develop trust towards the program and helps for broader adoption. This is where XAI steps in, offering transparency and insight into the decision-making processes of AI systems.</p><h3>Understanding the Black Box</h3><p>Many AI models today, do fairly well with solving problems, but their internal working is a mystery to humans as you can’t see what’s going on, you can’t understand the hidden reasoning it is using to arrive at the specific solution. This is the Black Box. The lack of transparency here poses significant challenges in many risky applications such as healthcare, finance, criminal justice etc., as any mistake here could have greater impact on people’s lives and could AI could lose the trust and might be shunned again as it was all those years ago(well that was for different reason) but the effect would be the same nonetheless.</p><p>Consider a scenario where a healthcare system, recommends that a patient should undergo a surgery or any medical procedure, without explaining why it arrived at that particular conclusion. This doctor might feel a bit queasy to trust the system and to put the patient in a risky situation due to lack of explainability. Similarly, Everyone knows that AI is only as good as the data, so let’s think of legal justice scenario one could argue that a person got arrested just because of his ethnicity due to bias in the data and to prove otherwise, we need a system that is transparent to human understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*myp6CkyortY8fPb_gwxrTA.png" /></figure><h3>Rise of Explainable AI</h3><p>Explainable AI or XAI for short, aims to address the black box issue by providing us with understandable explanations of AI decisions. It seeks to bridge the gap between the inner workings of AI models and human comprehension, enabling stakeholders to trust, validate and interpret AI driven outcomes.</p><p>There are several approaches to achieving explainability in AI systems, each with its own strengths and limitations:</p><p><strong>1. Interpretable Models: </strong>Some AI techniques like decision trees and linear regression, inherently produce interpretable models. These models are easier to understand because of they represent the decision-making process in a human-readable format.</p><p><strong>2. Post-hoc explanation methods:</strong> Post-hoc simply means after some event, so for complex models like neural network, post-hoc explanation methods are used to analyse after they have been made (see why it’s called post-hoc, because they are used after the models are made). Techniques such as feature importance, attention mechanisms and saliency maps highlight the factors influencing the model’s output.</p><p><strong>3. Local and Global Explanations:</strong> XAI can not only provide explanations regarding why a particular decision/prediction was made(local explanation) but also provide an explanation on a different granularity like the overview of the models behaviour across it’s entire decision space(global explanation).</p><h3>Applications of XAI</h3><p>XAI can be used in various domains:</p><p><strong>1. Finance:</strong> In the financial sector, XAI can enhance the transparency of credit scoring models, fraud detection system etc., enabling better risk management and regulatory compliance.</p><p><strong>2. Autonomous Vehicle: </strong>Here, XAI can explain the decisions made by onboard AI systems, in critical situation where human safety is at risk.</p><p><strong>3. Healthcare:</strong> Here it can provide the reasoning behind the diagnoses and medical treatment recommended, improving patient care and trust in AI driven healthcare systems.</p><p><strong>4. Legal and Ethical Compliance:</strong> XAI plays a crucial role in ensuring that AI systems comply with legal and ethical standards. By providing transparent explanations of AI decisions, XAI helps address concerns related to bias, fairness and accountability.</p><p>The above listed, are just 4 among many domains where XAI could be helpful in catering the needs of those dependent on it while also developing the confidence to use AI systems more often.</p><h3>Challenges in XAI</h3><p>Now that you know what XAI is, let us take a look at some of the challenges that remain:</p><p><strong>1. Performance and Explainability Trade-off:</strong> As models become more complex to achieve higher accuracy, they become less interpretable.</p><p><strong>2. Domain Specificity:</strong> Different domains may require tailored approaches to explainability. What constitutes a meaningful explanation in healthcare may differ from what is meaningful in finance sectors.</p><p><strong>3. Regulatory Frameworks: </strong>The development and adoption of XAI is closely linked to the regulatory frameworks governing AI systems. Policymakers must strike balance between fostering innovation and ensuring transparency, fairness and accountability.</p><p>Despite these challenges, the field of XAI continues to advance rapidly. Researchers exploring novel techniques and interdisciplinary approaches to enhance the explainability of AI systems while maintaining high levels of performance. As XAI develops further, it will revolutionise the way we interact with the AI systems and improves the trust in them enabling the broader adoptions of the same.</p><h3>Conclusion</h3><p>In conclusion, Explainability Artificial Intelligence(XAI) represents a pivotal step forward in the quests for transparent and trustworthy Artificial Intelligence systems. By providing understandable explanations of AI decisions, XAI not only enhances trust accountability but also fosters broader adoption across various domains. While challenges such as the trade offs between performance and explainability, domain specificity, regulatory frameworks etc., exists, the rapid advancements in XAI offer promising solutions. As researchers, policymakers, and industry stakeholders continue to collaborate and innovate, the future of XAI holds the potential to reshape our relationship with artificial intelligence, ushering in a new era of transparency, fairness and accountability.</p><p>Image credit: <a href="https://lh6.googleusercontent.com/0EM4D-ovDpPnwieMp8uCh1p2Lqzr6KGLbkuN072j7wFCeARHJvqmdEmsS3tBAyTgdKHQWKyi0IbfUCzf864eXXGZOxBwTfZTWDS1fq8pCoM4llrh2LPaEjCTI3j3iZLcVCN5r8s46TlPQ5FPali9bNZtStYNpBTtDEIgODPVqJrtlAvNmTSaI5TdsJ47">https://lh6.googleusercontent.com/0EM4D-ovDpPnwieMp8uCh1p2Lqzr6KGLbkuN072j7wFCeARHJvqmdEmsS3tBAyTgdKHQWKyi0IbfUCzf864eXXGZOxBwTfZTWDS1fq8pCoM4llrh2LPaEjCTI3j3iZLcVCN5r8s46TlPQ5FPali9bNZtStYNpBTtDEIgODPVqJrtlAvNmTSaI5TdsJ47</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acc4e3681f4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Binary Cross Entropy Loss — A brother to cross entropy]]></title>
            <link>https://medium.com/@arpita.jshenoy/binary-cross-entropy-loss-a-brother-to-cross-entropy-21612b8165b0?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/21612b8165b0</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[binary-cross-entropy]]></category>
            <category><![CDATA[loss-function]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Sun, 24 Mar 2024 17:23:38 GMT</pubDate>
            <atom:updated>2024-03-24T17:23:38.563Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81uUPItMEVlts4oXadOy3A.png" /><figcaption>s</figcaption></figure><h3>Binary Cross Entropy Loss — A brother to cross entropy</h3><p>Hello guys!! I am back with another article relating to <a href="https://medium.com/@arpita.jshenoy/cross-entropy-explained-9a4de423901c">Cross Entropy</a>(click to read) which I had previously written about, called Binary Cross Entropy. If you haven’t read about it, I suggest you do as these are very similar. This is a common loss function that can be used for both binary classification and multi-label classification. How can “Binary” cross entropy be used for “multi” label classification you ask? Well don’t worry. I will explain it to you step by step.</p><p>In Cross Entropy loss I had mentioned that, the entropy refers to information theory, the higher the likeliness of the event occurring, the less informative(surprising) it is, as this is anticipated and vice versa (I am not delving deeper into this as this has already been explained in the cross entropy article).</p><p>The Shannon entropy is calculated as below:</p><p>information = -log(p(x))</p><ul><li>p(x) -&gt; probability of x</li><li>negative sign, because log(p(x)) will be negative and to make the final result positive, we use the negative sign.</li></ul><p>Now, you might wonder, why choose one over the other if they are similar. The answer is simple, it’s not the cross entropy function that is different here, they are almost similar(only difference is in the way the calculation happens for multi-label classification, but the concept is same), but the activation function used to calculate the probabilities is different. Cross Entropy loss expects outputs from softmax layer while Binary Cross Entropy loss expects outputs from sigmoid layer. Why? Keep reading to know the difference. Let me first explain to you what is sigmoid layer and why it is used.</p><h4><strong>What is Sigmoid?</strong></h4><p>Sigmoid is an activation function often used as the final layer in binary or multi-label classification problems in neural networks. This function takes in the raw logits and converts them to the probabilities by squeezing each value between 0 and 1. The formula for sigmoid is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*gBOY2UuQG8EIqfpYLp-_yg.png" /></figure><p>This equation squeezes any value between 0 and 1 same as softmax. The difference is that softmax does that with respect to other values in the list, that is if there 5 values in the list, it squeezes each value between 0 and 1 such that the sum of all 5 values will be equal to 1. Sigmoid doesn’t do that it doesn’t care about other values, just focuses on individual value.</p><p>This makes it perfect for multi-label classification, as there are multiple labels in an image and so we don’t want the probabilities to sum upto 1. While softmax pushes one class above others sigmoid just pushes those it identifies to 1.</p><p>In case of binary classification we can just have 1 output unit, which outputs either 1 or 0, in this case we use binary cross entropy as there is only 1 number coming out of the output unit. If we have 2 output units each for a class( 1 for 0 and another for 1) we will have to use cross entropy instead, as we now have a list of 2 probabilities as output, out of which we need to identify 1 class, so we need to push one class towards 1.0(probability).</p><p>Now that we have understood the similarities and differences between sigmoid and softmax. Let’s work with an example to understand how binary cross entropy loss works with binary classification and multi-label classification.</p><h4>Binary classification Example</h4><p>Let’s assume we have a binary classification model which predicts 2 classes, and we have targets = [1,0,0] and the model after the first pass has the following output at the final layer before sigmoid = [0.9,0.01,1.34].</p><p>The cross entropy formula is as below for binary classification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oxP6uvQDBe5p1Bxlx5A_pw.png" /></figure><p>After this passes through the sigmoid layer, we get = [0.71, 0.51, 0.20], after log(natural log) this would become = [-0.34,-0.71,-0.22] and after taking negative this becomes [0.34,0.71,0.22] you see, how the loss is too high where the model is least confident? This is just the result of random numbers we have chosen for demonstration purpose.</p><h4><strong>Multi-label Classification Example</strong></h4><p>Since we have completed demonstrating how binary classification works, we can now move on to demonstrate how multi-label classification works. Multi-label, as you can see in the above picture, is a classification where you have multiple objects to identify in an image. See why we can’t use softmax here? as explained above it pushes for one class to get close to 1. But we want more than one class to be close to 1.</p><p>Let’s go through an example assuming that we have a target of = [[1,0,1],[1,1,0],[0,1,1]]. After the first pass it gives out, [[1.5, 0.3, 0.89],[0.92,0.1,0.7],[0.8, 0.95,0.69]].</p><p>After sigmoid, we get [[0.82,0.43,0.30],[0.28,0.48,0.33],[0.31,0.28,0.33]], now let’s take the log for these values = [[-0.20,-0.57,-1.20],[-1.27,-0.73,-0.4],[-0.37,-1.27,-1.11]], after taking negative = [[0.20,0.57,1.20],[1.27,0.73,0.4],[0.37,1.27,1.11]]. See how the loss is higher where the prediction is far from the truth.</p><h4>Conclusion</h4><p>To conclude, we can say that BCELoss is useful for not just single class binary classification but also for multi-label classification. The cross entropy loss formula remains same whether it’s regular cross entropy used for multi-class classification, or binary cross entropy loss. The only difference is the activation function used along with it. If you are using PyTorch you may find BCELoss() and BCEWithLogitsLoss() for Binary cross entropy but they are both same although pytorch recommends that you use the latter as that is more stable. The difference is BCELoss, when used, you have to add sigmoid layer as the final layer manually. But BCEWithLogitsLoss() includes sigmoid layer.</p><p>That’s It!! Now you can see why they are brothers. They are similar functions for different purposes. Hope you understood the topic, if you want to add on to this, feel free to leave it in the comment.</p><p>Thank you for reading. Have a great day!!</p><p>Title image credit — <a href="https://gombru.github.io/2018/05/23/cross_entropy_loss/">https://gombru.github.io/2018/05/23/cross_entropy_loss/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21612b8165b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paper Summary — How transferable are deep learning features.]]></title>
            <link>https://medium.com/@arpita.jshenoy/paper-summary-how-transferable-are-deep-learning-features-967c33bb2a3e?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/967c33bb2a3e</guid>
            <category><![CDATA[transfer-learning]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 07:21:34 GMT</pubDate>
            <atom:updated>2024-03-06T07:44:07.849Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFBRYplDLuIz6eUrx8-gIg.jpeg" /></figure><h3>Paper Summary — How transferable are deep learning features.</h3><p>Hey folks!! I am back with another article about one of my favorite papers by Jason Yosinski, Jeff Clune, Yoshua Bengio and Hod Lipson called How transferable are deep learning features. In this article, I am writing a short summary about the paper which covers everything that it contains in a brief way.</p><p>So moving on to what this paper explains, is how the layer transitions from generality to specificity. What I mean by this is, initially all the layers learn some general features like gabor filters and color blobs in the first layer and this is so common that if your model outputs anything apart from them, you could think that your model is inefficient or incorrect. This is general to many tasks and datasets. The last layer learns features that are specific to your dataset. So there must be some transition happening somewhere in the middle as it moves towards last layer.</p><p>Transferability is negatively affected by two issues:</p><ol><li>Specialization of higher layer neurons to the original task at the expanse of the performance on the target task.</li><li>Optimization difficulty due to splitting of the networks between co-adapted neurons.</li></ol><p>Basically what this means is,</p><ol><li>Since the higher layer neurons are more specific to the task they were trained on originally, using them on different dataset causes the performance to drop as it has to adapt to the task that is being trained on and relearn the specific features related to the target task.</li><li>A model while training adapts to the neighboring layers so there is a clear flow/interaction between them. This is affected as the model when using for transfer learning, isn’t used as a whole but some layers are chopped off and new layers are added to suit the target dataset. Due to this, the performance suffers as the co-adapted layers are chopped off and the model has to learn to adapt to the newly added layers.</li></ol><p>Either of these issues dominate based on the layers chosen(bottom, up to middle or up to top).</p><p>In this paper, we see that the transferability of the features decreases, as the distance between the target task and the base task increases(as the base task gets more and more different from the target task). But even if it’s so, it is still better than using totally random features.</p><p>The usual learning approach is that a network of n layers is trained on original database, and only the first n layers of the original network is used to train the target network with remaining layers being trained on random weights. When the target dataset is significantly small, then transfer learning can be a powerful tool to train the network. When the target network is very small and the hyperparameters are too large then there is a risk of overfitting the model, so in such case, you can leave the first n layer frozen meaning that they do not change during the training. If the target dataset is large or if the hyperparameters are small enough so as to not overfit the model, in such case one can choose to backpropagate the errors and “fine-tune” the network to fit the target dataset. If the target dataset is very very large, then there is no need to transfer the features, as the model can learn the lower level features from the scratch.</p><p>In case of selffer(transfer learning on same dataset) network with frozen layers, Near the top or bottom the co-adaptation is less, as near the top there is less to relearn, and near the bottom the features are more general. The fragile co-adaptation occurs in the middle layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2hIdgefRxyFFMZtRGt6FwQ.png" /></figure><p>In the above picture, you can see how the network is split.</p><p><em>base A:</em> is a network trained on 500 of randomly split classes of ImageNet 1000 classes dataset(about 645000)(A dataset).</p><p><em>base B</em>: is a network trained on other 500 classes(B dataset).</p><p>There are 8 convolutional layers in both base networks.</p><p><em>BnB</em> : is a network where both base and target dataset are B dataset and first n layers of base network is frozen while the rest of the layers(4–8) is trained with the B dataset. for example, in the above image we see B3B where first 3 layers of base B is frozen and rest of the layers are initialized randomly and trained on B dataset.</p><p><em>BnB+</em> : is a network where first n layers of the base B is copied and rest of the layers (4–8) is initialized randomly, the only difference here is that unlike BnB, the entire network is trained which we call fine-tuning + transfer learning. Here, we are not just training the upper layers but are also making minute changes called fine-tuning to adjust to our target dataset.</p><p><em>AnB</em> : is a network where first n layers of the base A is copied and is frozen. The rest of the newly added layers are trained for dataset B.</p><p><em>AnB+</em> : is a network where first n layers of the base A is copies but not frozen and is trained along with randomly initialized layers towards dataset B.</p><p>This experiment is conducted in both ways AnB and BnA.</p><p>One thing we must keep in mind, is that ImageNet has many similar classes, classes that may be similar in features like different families of cats, they are still cats so the features must be similar. Since the dataset is randomly split some of the classes of cat families might have fallen under dataset A while others under B. This might be the case for other classes as well. So we can conclude that, though we have 2 different dataset, they are similar.</p><p><strong>Results of similar datasets(random split)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnItOEtQiU34CIvXGfD6-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fGmX1FH0d9bWaS4IRibew.png" /></figure><p>In case of transfer network with frozen layers, We can see that it does well for first two layers, as not just the first layer but even the second layer is pretty general. But the performance starts to drop from layer 3 through 7. We know exactly why this is happening and which effect is dominating when. From layers 3–5, the performance drops because of fragile co-adaptation as in the above case, but after that the performance drops because of specificity. So we can clearly say that this network has seen both distinct issues as mentioned above (see Transferability is negatively affected by two issues), but the second issue dominates near the middle layers and the first issue dominates at the top layers.</p><p>One surprising result is that transferring features(finetuning) helps generalization faster and improves the model performance. Even after finetuning the dataset for a very large number of iterations, the effect of having seen the base dataset lingers. This causes better generalization of the features and the performance improves for any number of layers the authors decide to keep. In fact, it gets better and better as we keep more and more layers.</p><p>For the next experiment what the authors did was, they split the ImageNet classes based on man-made entities and natural entities. This dataset it is imbalanced as there are only 551 man-made classes whereas there are 449 classes of natural entities. Here, A consists of man-made classes and B consists of natural classes.</p><p><strong>Results of dissimilar datasets(man-made/natural split)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*1tY-DMeh1O__WLZDgGITow.png" /></figure><p>This is obvious that the performance drops as the data is dissimilar.</p><p>Let’s look at each of the plots carefully:</p><ol><li>The first subplot(upper left) shows the results for the accuracy of both base A and base B(white circles) then the accuracies for BnA and AnB networks(orange hexagons). The upper line shows the results for base B and AnB. The second line shows base A and BnA. The first task may have better accuracy due to the fact that there are lesser classes in base B than base A or may be because the features are a bit easy to detect. But one thing we can observe is that the accuracy drops as more and more layers are frozen. This is obviously due to the reason stated above.</li><li>Second subplot shows us that, it is still better to use a pretrained weights than completely using random weights as you can see that the performance drops lower and lower with more and more layers.</li><li>The third and final plot puts the above two plots together by subtracting the performances of their individual base cases. So, the white circle here is a reference point and you can see that the transferability is better for similar datasets with n layers frozen as compared to the dissimilar datasets. But using learned features is still better compared to the random weights.</li></ol><h4><strong>Conclusion</strong></h4><p>To sum up everything, transfer learning is good compared to completely random model, but we must still assess the number of parameters of base network and the size of target dataset to avoid overfitting as you might overfit it if the base network is too complex for the target dataset, if you have a simple base network and a complex or a large dataset, then you better finetune it to avoid underfitting and let the lower layers adapt to the complexity and if your dataset is too large, then it’s better to train it from scratch as transfer learning won’t provide you with any benefit. Along with the size of parameters you can also consider looking into how similar the target task is to the base class for better generalization and that finetuning + transfer learning generalizes better than simply keeping the layers frozen. Train the top layers for a while by keeping the lower layers frozen and then finetune the entire network for co-adaptation of neurons or use different learning rates to train the top layers and lower layers(smaller for lower layers and bigger for top layers) as we don’t want the weights of the lower layer change much.</p><p>That’s it!!!</p><p>Happy Reading!!</p><p>Paper — <a href="https://arxiv.org/abs/1411.1792">https://arxiv.org/abs/1411.1792</a></p><p>Title image —<a href="https://indiaai.gov.in/article/how-do-neural-networks-work-a-non-technical-explanation"> </a><a href="https://indiaai.gov.in/article/how-do-neural-networks-work-a-non-technical-explanation">https://indiaai.gov.in/article/how-do-neural-networks-work-a-non-technical-explanation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=967c33bb2a3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A look at the Bias and Variance through my lens]]></title>
            <link>https://medium.com/@arpita.jshenoy/a-look-at-the-bias-and-variance-through-my-lens-8e4b7557f70b?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e4b7557f70b</guid>
            <category><![CDATA[bias-and-variance]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 13:45:39 GMT</pubDate>
            <atom:updated>2024-02-27T13:45:39.889Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="https://www.javatpoint.com/bias-and-variance-in-machine-learning" src="https://cdn-images-1.medium.com/max/400/1*eSMiVM9y9IYJ5l4Go_o-GQ.png" /></figure><p>Hello peeps!! not sure if people still say that but oh well! I have come today with another interesting topic, can you guess what it is??? Yes, that’s correct!! you got it right, we will be understanding Bias and Variance of the model. You guys are so smart!!</p><p>Yea, yea, i know we have seen a lot of Bull’s eye diagram and no, I won’t be explaining it to you in the same way. I will explain it to you as I understood it and try to make it as simple as possible. With that, let’s begin, shall we?</p><p><strong>What is a Bias?</strong></p><p>Jargons in machine learning can be quite confusing sometimes, don’t you agree? We have a ‘bias’ in linear models (y=mx+<em>b</em>), we have a bias in statistics(data), and we have a bias of the model. Here, the Bias refers to the model’s bias in understanding the pattern which simply means that the model fail to understand the underlying pattern as it should and make it’s own assumption.</p><p>Let me give you an example here,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*-9FjIMB_E79gl7nxOfdgYw.png" /></figure><p>Do you see the middle dataset, in the above image? while the other two are linear, the middle one is not. The model has “assumed” this dataset to be linear, and tried to fit a straight line due to which it is doing the bad job in predicting the datapoints.</p><p>This can happen due to number of reasons, most common ones are listed below:</p><ol><li>We have picked a linear model to fit a non linear data.</li><li><em>Underfitting</em>. The model hasn’t had the chance to understand the pattern.</li><li>Representation bias. The dataset is not representative of all the scenarios/classes.</li><li>Too less data/outdated data which doesn’t consider the latest trend.(a.k.a., domain shift).</li><li>Too less features.</li></ol><p>So, when your model makes such assumptions, it’s predictions are almost always wrong or rather random. Let’s now move on to our next question as to what is Variance.</p><p><strong>What is Variance?</strong></p><p>Variance of the model is how well it’s predictions are on different validation set/test set. The average predictions of different test set should not vary much, if it does then it simply means your model hasn’t “generalized” well (meaning, it isn’t predicting properly on the unseen data). This could be due to overtraining. You have trained the model too much that it has memorized every datapoint, and now it isn’t able to predict the unseen combination. It’s like you memorize a questionnaire thinking you will get those questions for your exam and suddenly there is a different question and you don’t know how to answer that.</p><p>Variance in your models is caused by some of the reasons mentioned below:</p><ol><li><em>Overfitting</em>. Training your model too much makes it memorize every pattern seen in the training set.</li><li>Using complex models. Like overtraining, this also forces the model to fit to every data point by finding the overly complex pattern in it.</li><li>Too many features.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*dydB0M4bR-I6sDrLswLwzA.png" /></figure><p>In the above image you can see that the model has overly fit the data, that it failed to understand a general pattern. So this represents, high variance in the model.</p><p>Also, you might have now noticed that bias and variance are kind of inversely related to each other. Let’s get more into that now.</p><p><strong>Bias and Variance relationship</strong></p><ol><li>Bias occurs due to undertraining of the model and variance due to overtraining.</li><li>When the model makes too much assumptions about the model, the model will be highly biased and variance is low. To explain this in simpler terms, let’s say your data has 2 classes 0 and 1, and your highly biased model predicts 1 every time, and if your dataset has 50% of class 1, then your accuracy is always 50% so your model predictions doesn’t vary much hence low variance.</li><li>When the model fits the data too much there is low bias and your model is memorizing every combination which means it doesn’t know what to predict for the unseen data and every prediction will be wrong, giving variable predictions thus increasing the variance of the model.</li></ol><p><strong>Conclusion</strong></p><p>It is very important to strike a balance between high variance and high bias as if you try to make the bias too low, the variance will increase and vice-versa. One point to note that is not to just look at the loss values, but also to keep an eye on the metric(accuracy, RMSE, Roc etc.) we choose. Because initially validation loss will increase, but as long as our metrics are decreasing, understand that the model is training and the high validation loss is due to undertraining (high bias) of the model. When you see the validation loss and our metrics are both increasing after decreasing to a point then know that we are overfitting the data. Always plot the loss curves to find the point where the training losses and validation losses are converging and then start to diverge, you can select the epoch slightly before that point to achieve optimum result. Also Ensure that you have enough feature, not too many or too less. Use PCA and other methods that reduces dimensions while also retaining the important dimensions.</p><p>Above are some of the things, among many to avoid overfitting and underfitting of your data. Hope this helped clear some of your doubts regarding the topic. If you have any queries, please leave it in the comment section so I can help you however I can. If you like the blog, please clap, it will mean a lot to me.</p><p>Thank you very much :)</p><p>Credits:</p><p>Image 1 — <a href="https://www.javatpoint.com/bias-and-variance-in-machine-learning">https://www.javatpoint.com/bias-and-variance-in-machine-learning</a></p><p>Image 2 — <a href="https://www.freecodecamp.org/news/how-machines-make-predictions-finding-correlations-in-complex-data-dfd9f0d87889/">https://www.freecodecamp.org/news/how-machines-make-predictions-finding-correlations-in-complex-data-dfd9f0d87889/</a></p><p>Image 3 — <a href="http://statistics4u.com/">http://statistics4u.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e4b7557f70b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross Entropy - Explained]]></title>
            <link>https://medium.com/@arpita.jshenoy/cross-entropy-explained-9a4de423901c?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a4de423901c</guid>
            <category><![CDATA[loss-function]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 07:25:55 GMT</pubDate>
            <atom:updated>2024-02-23T07:25:55.040Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*nWj-WuYB1yt3TiR__y0jTg.png" /></figure><p>One of the most common loss functions in deep learning is cross entropy loss. Well the cross entropy might sound intimidating to some, fear not, for I will explain it to you in a simple manner, that by the end of this blog you’d become an expert in this topic and say “Really!! that’s it???”.</p><p>So let’s start with what is entropy?</p><h4><strong>What is Entropy?</strong></h4><p>The Entropy here refers to information entropy. This comes from Information theory, and the basic intuition behind information theory is that learning that an unlikely event has occurred is more informative (surprising), than learning that a likely event has occurred.</p><p>The calculation for the amount of information(certainty) in an event can be done using the probability of the event. This is called “Shannon Information(Shannon entropy)” and can be calculated as:</p><p>information = -log(p(x))</p><ul><li>p(x) -&gt; probability of x</li><li>negative sign, because log(p(x)) will be negative and to make the final result positive, we use the negative sign.</li></ul><p>Now, coming to the Fastai’s explanation of cross entropy loss, it is said that the entropy is the combination of negative log likelihood and softmax. Which applied above can be written as:</p><p>information = -log(softmax(x))</p><p>This brings us to next our next question,</p><h4><strong>What is Softmax?</strong></h4><p>Like sigmoid(which we used in chapter 4), which squeezes the values of our final layer between 0 and 1, softmax does it in a bit of a different way. While sigmoid calculates the values independently, a softmax calculates the values with respect to other values, which makes the total probability of a row equal to 1. That’s why we use it for the multiclass classification, where we have different classes to predict, and there is only one class per image. For example, if we have 5 different classes and we have one class per image, our final layer outputs predictions for all the 5 classes and softmax applied to this layer, forces one class to approach 1 and all others close to zero, when we add the probabilities of all the classes it equals 1. We can use cross entropy even for binary classification, by getting the final layer to output predictions for 2 classes. The formula for softmax is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*nWj-WuYB1yt3TiR__y0jTg.png" /></figure><p><strong>Explanation with example:</strong></p><p>Now, let’s say we have a binary classification model which predicts 2 classes, and we have targets = [[0,1],[1,0],[1,0]]</p><p>and the model after the first pass has the following output at the final layer before softmax = [[0.1,0.5],[0.209,0.923],[1.34,0.4]].</p><p>After applying the softmax activation at the final layer, our predictions become = [[0.4,0.6],[0.3,0.7],[0.7,0.3]]. See how the values are squeezed between 0 and 1 and they always add up to 1?</p><p>For the next step, since we already know that all values add up to 1, we can only consider the values where our target equals 1 as we want to make these values closer to 1, the rest are just (1-this value). So, we consider only [0.6, 0.3, 0.7], let’s now take the negative log likelihood( which just means take the log of these numbers and then multiply them with -1) why do we take negative log likelihood? because, log of these numbers results in negative values and we reverse these like below:</p><p>log(natural log) of the above numbers are = [-0.2218, -0.5229, -0.1549]</p><p>Now after taking negatives of these numbers we get = [0.2218, 0.5229, 0.1549]</p><p>Here you can see that the loss is lower where the model is more confident and higher otherwise. when we take the mean of these values, we get the average cross entropy loss.</p><p>This is all the cross entropy loss is about. It is nothing but a combination of softmax and negative log likelihood. Now, ofcourse you won’t be calculating this manually, but it’s good to know the intuition behind it and how it is calculated as it would help you in debugging. In PyTorch, we use nn.CrossEntropyLoss(). This is good for multiclass classification where you have to predict one class out of a bunch of them.</p><p>So that’s it folks!! Hopefully you understood the topic clearly. If you think this could be improved in any way or you have more to add to the above provided information, please comment. Also, if you are happy with the content and think it helped you, then please give it a like.</p><p>Thank you :)</p><p>Credits:</p><ol><li><strong>Sources</strong> : <a href="https://machinelearningmastery.com/what-is-information-entropy/">https://machinelearningmastery.com/what-is-information-entropy/</a></li><li>Fastai book</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a4de423901c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Linear Model]]></title>
            <link>https://medium.com/@arpita.jshenoy/the-linear-model-86ea6cee3d38?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/86ea6cee3d38</guid>
            <category><![CDATA[linear-models]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 09:55:38 GMT</pubDate>
            <atom:updated>2022-07-18T09:55:38.392Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*iycu7qKS045TwN3YGhGMng.png" /><figcaption>Linear Model — Image taken from Wikipedia</figcaption></figure><p>We have heard a lot about Linear Regression Model, but is it the only linear model or is it just one example of a linear model? let us find out. Shall we?</p><h3>Linear Model</h3><h3><strong><em>what is a Linear Model?</em></strong></h3><p>A model is a representation of what a machine learning system has learnt. It defines the relationship between features and labels. e.g., A spam detection model might associate certain features strongly with “spam”. Let’s highlight 2 phases of model life:</p><ul><li><strong><em>Training</em></strong> means creating or learning the model. i.e., you show the model labeled examples and enable the model to gradually learn the relationship between the feature and labels.</li><li><strong><em>Inference</em></strong> means applying the trained model to unlabeled examples, i.e., you use the trained model to make useful predictions (y’).</li></ul><p>A <em>linear model</em> is a model that assigns one weight per feature to make a prediction. Linear model also incorporate a bias (y-intercept). By contrast, the relationship of weights to feature in deep models is not one-to-one.</p><p>A linear model uses the following formula:</p><p>y’ = b+w1x1+w2x2+…..+wnxn</p><ul><li>where y’ is the raw prediction aka yhat.</li><li>b is the y-intercept.</li><li>w is a weight, so w1 is the weight of the first feature and so on.</li><li>x is a feature, so x1 is the first feature and so on.</li></ul><p>ex: Suppose a linear model for 2 features learns the following bias and weights:</p><p>b=7; w1=-2.5; w2=-1.2.</p><p>Therefore, given 2 features, the linear model uses the following eqn to generate each prediction:</p><p>y’ = 7+(-2.5)x1+(-1.2)x2</p><p>suppose a particular example contains the following values;</p><p>x1=4; x2=5.</p><p>Plugging these values in the eqn gives us,</p><p>y‘ = -9</p><p>Linear Models tend to be easier to analyze and train than deep models. However deep models can model complex relationships between features.</p><p>Linear Regression and Logistic Regression are 2 types of linear models. Linear models not only include the models that use the above eqn but also includes a broader set of models that use this eqn as part of the formula. For example, logistic regression post processes the raw prediction to calculate the final prediction.</p><p>Now there are two types of models based on the kind of outputs that is required, they are:</p><ul><li>Regression Model: A type of model that outputs continuous values(real numbers).</li><li>Classification Model: A type of model that outputs a discrete value(yes or no) i.e., it outputs 0 or 1 which is then mapped to yes or no. There is also multi class classification where there are more than one class in which the output is an integer referring to each class.</li></ul><p>So, we can conclude that there are many linear models out there, even a perceptron can be considered as a linear model. It is a name given to any model that uses “y=mx+b” in it’s formula.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86ea6cee3d38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI/ML Concepts]]></title>
            <link>https://medium.com/@arpita.jshenoy/ai-ml-concepts-9694d10ac4b8?source=rss-89eb300cc74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9694d10ac4b8</guid>
            <category><![CDATA[introductory-blog]]></category>
            <dc:creator><![CDATA[Arpita Jshenoy]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 09:05:39 GMT</pubDate>
            <atom:updated>2022-07-18T09:05:39.284Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*PwiDP4Z0Uu7yEXp7t7UDog.png" /></figure><h3>Introduction</h3><p>Hey guys!!!</p><p>I am Arpita, an aspiring AI/ML Researcher. This is my very first blog and I am too excited to be writing about my favorite topics here. This is an introductory blog to let you guys know why I am writing this blog and what you can expect out of it.</p><h3>Why did I start a blog?</h3><p>Well, when I started studying about AI/ML, I was lost as to where to begin and what to study as it is very vast and there is soooo much on the internet that can intimidate just anyone. So, I thought of writing this blog where I can put in everything I learnt so I can refer back to it whenever required. It’s like a notes to me and could be used by others who are interested in learning about AI/ML without hassle. Also, I hope this would improve my writing skills.</p><h3>What you can expect from this blog.</h3><p>Like I mentioned above, that this blog is like a notes to me, and consists of information that I learnt, I can’t guarantee that the information is complete, but can assure you that it’s sufficient for a novice who’s hoping to start their journey in AI/ML. The information is surely taken from different sources which I went through to understand the topic and the same would be mentioned at the end of every topic. I would be writing this blog topic-wise and should not be considered as a learning path.</p><p>After my struggle with understanding each topic, I thought there should be one space where you could find all the information and in the layman language. For this, I thought instead of writing down stuffs I learnt in a notebook, I should start writing a blog that could help others who are struggling like me. I thought of making a learning path blog which could help people to understand where to begin, but then I thought everyone has their own style of learning stuffs right? Something that suited me would not necessarily suit you guys. But let me know on your thoughts about this??? With that said, I am ending this post.</p><p>Hope you enjoy!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9694d10ac4b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>