<?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 Nandini Gundimeda on Medium]]></title>
        <description><![CDATA[Stories by Nandini Gundimeda on Medium]]></description>
        <link>https://medium.com/@nandinigundimeda2025?source=rss-2c5da1f37f9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6oVAyZCLTE6-JXNs</url>
            <title>Stories by Nandini Gundimeda on Medium</title>
            <link>https://medium.com/@nandinigundimeda2025?source=rss-2c5da1f37f9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:29:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nandinigundimeda2025/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[Activation Functions in Deep Learning]]></title>
            <link>https://medium.com/@nandinigundimeda2025/activation-functions-in-deep-learning-e2ab5fc541f5?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2ab5fc541f5</guid>
            <category><![CDATA[why-activation-function]]></category>
            <category><![CDATA[backpropagation]]></category>
            <category><![CDATA[activation-functions]]></category>
            <category><![CDATA[what-are-activations]]></category>
            <category><![CDATA[when-to-use-activations]]></category>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Thu, 05 Nov 2026 04:36:56 GMT</pubDate>
            <atom:updated>2026-11-05T04:36:56.466Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog is explaining the fundamental role of activation functions in Neural Networks. A <strong>Neural Network </strong>is a machine learning model inspired by the human brain that uses interconnected layers of artificial neurons to recognize patterns, process data, and make predictions</p><ol><li><strong>Core Architecture</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*I2RHwxsne_GDuprhB0TmKA.png" /></figure><p><strong>2. Mathematical Representation of Neural Network</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*M2MHNtLrn-hJqurkQ0fnSg.png" /></figure><p><strong>3. What is activation function?</strong></p><p>An activation function is a mathematical function used in an artificial neural network to decide the output of a neuron. It helps the neural network to learn complex patterns from data by introducing non-linearity into the network.</p><p>In simple words, an activation function decides how strongly a neuron should pass its signal to the next layer.</p><p><strong>4. Where is an activation function used in a neural network?</strong></p><p>An activation function is used inside each neuron of a neural network, usually after calculating the weighted sum of inputs and adding the bias.</p><p><strong>Workflow:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*Vi1tUXunV4_Kgk-vYJyJlA.png" /><figcaption>Process to calculate the output of neuron in hidden ,output layers</figcaption></figure><p><strong>5. What happens if we do not use an activation function?</strong></p><p>Activation function is required mainly because they introduce the non -linearity into the neural network.<br>Suppose :</p><pre>## Neural Network without activation function <br>h1 = w1x1 + w2x2+ b1 ## hidden layer1  weighted sum<br>h2 = w2h1 + b2 ## output layer weighted sum<br>y = w2h+b2<br>substitute h in y:<br>    <br>    y = w2(w1x1+ w2x2+ b1) + b2<br>    y = w2w1x1 + w2x2b1 + w2b1 + b2 ## final eqaution </pre><p>If a neuron simply uses a weighted sum to calculate the neuron output Even after adding many layers also , the entire equation is still linear. Without activation function the model is able to capture simple patterns but doesn’t learn complex patterns.</p><p>With Activation Fucntions :<br>Linear transformation + Non -linearity = Powerful Neural Network<br>This allows the network to learn relationships that cannot be represented by a simple straight line.</p><p>An artificial neuron takes input values, multiplies each input by a weight, adds the results together with a bias, and then applies an activation function to produce its output.</p><p>The process has two main steps:</p><ul><li>z = w1x1+w2x2+⋯+wnxn+b</li><li>a = f(z)</li></ul><p>Step 1: Calculate the weighted sum z.<br>Step 2: Apply the activation function f to get the output a.</p><pre>Term           Meaning                  Purpose<br><br>x1,x2,…,xn    Inputs       The information received by the neuron<br><br>w1,w2,…,wn​    Weights     Determine how strongly each input influences the result<br><br>b              Bias       Shifts the weighted sum up or down<br><br>z         Pre-activation value   The weighted sum before applying the activation function<br><br>f        Activation function     Transforms the weighted sum<br><br>a          Activation (output)    The final value produced by the neuron</pre><p><strong>6. Why activation function is applied after calculating the z?</strong><br>The neuron first calculates the weighted sum because it needs to combine all the input information into a single value. The activation function then transforms that combined value.The key reason is that activation functions introduce nonlinearity, which allows a neural network to learn more complex relationships.<br>Consider two possible inputs to a neuron:</p><ul><li>If the weighted sum is negative, ReLU produces zero.</li><li>If the weighted sum is positive, ReLU preserves it .<br>Without an activation function, a neuron simply calculates a linear weighted combination of its inputs (more precisely, an affine transformation when a bias is included).<br>This distinction becomes especially important when multiple neurons are connected in layers.</li></ul><p><strong>7. Why stacking only linear transformations still results in a linear transformation</strong></p><ol><li>Suppose a network has two layers, and neither layer uses an activation function.<br>For simplicity, let the first layer calculate:</li></ol><pre>h1=2x+3<br><br>Let the second layer calculate<br>y=4h1+5<br><br>Substitute the first equation into the second:<br>y=4(2x+3)+5<br><br>Expand and simplify:<br>y=8x+12+5<br>y = 8x +17​<br><br>The entire two-layer network is equivalent to the single transformation:<br>y = 8x +17​</pre><p>What if there is no Bias term</p><pre>h = 2x<br>y = 4h<br><br>substuting h gives :<br><br>Both layers together are equivalent to the single linear transformation<br>y = 8x <br><br>How does an activation function changes this<br><br>h=ReLU(2x)<br>y=4h<br><br><br>Remember:<br>ReLU(x)=max⁡(0,x)<br>y=4×ReLU(2x)<br>y=max⁡(0,8x)<br><br><br>example<br><br><br>Input​   activation(2x)        Relu          output<br>-2          2(-2) = -4       max(0,-4)      0<br>-1          2(-1) = -2       max(0,-2)      0<br> 0          2(0)  = 0        max(0,0)       0<br> 1          2(1)  = 2        max(0,2)       2<br> 2          2(2)  = 4        max(0,4)       4<br><br><br>Without activation: Multiple layers combine into one linear transformation.<br><br>With ReLU: The network can learn non-linear relationships.<br><br>Bias is not required for ReLU to introduce non-linearity. </pre><p>Mathematical Calculation :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5vBvHC3SHCxccwoi" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XtfOLIM2oJF4zJl0" /></figure><p>Here are the few mostly used activation functions :</p><ul><li>Sigmoid</li><li>Softmax</li><li>Tanh</li><li>ReLU</li><li>Leaky ReLU</li></ul><h4>1.Sigmoid Function:</h4><p>The Sigmoid activation function is a non-linear activation function used in Machine Learning and Deep Learning. that converts any input value into an output between 0 and 1.It is mainly used in the output layer of a neural network for binary classification problems, where the output can be interpreted as a probability.</p><p>formula:</p><pre>        1<br>σ(x) = --------<br>      1 + e^−x</pre><p>Working of Sigmoid Function</p><ol><li>The neural network receives an input value.</li><li>The input is passed through the sigmoid function.</li><li>Sigmoid converts the input into a value between 0 and 1.</li><li>This output is interpreted as a probability.</li><li>A threshold (usually 0.5) is used to classify the result into two classes.</li></ol><pre><strong>When to Use Sigmoid?</strong><br>Use sigmoid when:<br>Binary classification: Predicting two classes, such as Yes/No, Spam/Not Spam.<br>Probability prediction: When you need an output between 0 and 1.<br>Output layer of ANN: When predicting the probability of a single positive class.<br><br><strong>Advantages: </strong><br>1.Converts values into probabilities between 0 and 1.<br>2.Smooth and differentiable.<br>3.Useful for binary classification.<br><br><strong>Limitations</strong><br>1.Vanishing Gradient: For very large or very small inputs, gradients become close to zero, slowing learning.<br>2.Not zero-centered: Outputs are always positive.<br>3.Not preferred for hidden layers: ReLU is generally preferred in modern deep neural networks.</pre><h4>2.Softmax</h4><p>The Softmax Function is an activation function that converts multiple output values into probabilities between 0 and 1, where all probabilities add up to 1 (100%)</p><p>Working:</p><ul><li>The neural network produces multiple output values (scores).</li><li>Softmax takes care these scores as input</li><li>It converts each score into probability.</li><li>All probabilities add up to 1</li><li>The class with the highest probability is selected as the prediction.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*cpjCQ-lNNvkNQi9yCYweXw.png" /><figcaption>softmax formula</figcaption></figure><pre><strong>When to Use Softmax?</strong><br><br>Multi-class classification: Predicting one class among multiple classes.<br>Output layer of ANN: When choosing one category from several categories.<br>Probability prediction: When probabilities for all classes must add up to 1 .<br><br><strong>Advantages:</strong><br><br>1.Converts scores into probabilities (0 to 1).<br>2.All output probabilities add up to 1 (100%).<br>3.Useful for multi-class classification.<br>4.Helps identify the most likely class.<br>5.Easy to interpret the model&#39;s predictions.<br>6.Commonly used in the output layer of neural networks.<br><br><strong>Limitations:</strong><br>1.Not suitable for mutli-label classification where multiple classes can be true.<br>2.Sensitive to large differences in input scores.<br>3.Can produce very small probabilities for low-scoring classes.</pre><h4>3.Tanh Function:</h4><p>The Tanh (Hyperbolic Tangent) activation function is a non-linear activation function used in Artificial Neural Networks (ANN). It converts input values into an output ranging between -1 and +1. It is commonly used in hidden layers of neural networks and in Recurrent Neural Networks (RNNs).</p><pre>e^{−x} - e^{-x}<br>---------------<br>e^{-x} + e^{-x}</pre><p><strong>Working of Tanh Function</strong></p><ul><li>The neural network receives an input value.</li><li>The input is passed through the Tanh function.</li><li>Tanh converts the input into a value between -1 and +1.</li><li>Positive inputs produce positive outputs, negative inputs produce negative outputs, and zero produces zero.</li><li>The output is passed to the next layer.</li></ul><pre><strong>When to Use Tanh?</strong><br>Use Tanh when:<br>Hidden layers: To introduce non-linearity in neural networks.<br>Zero-centered output: When outputs need to be between -1 and +1.<br>RNNs: Commonly used in Recurrent Neural Networks.<br><br><strong>Advantages :</strong><br><br>1.Zero-centered output <br>2.Output ranges from -1 to +1 <br>3.Handles positive and negative values <br><strong><br>Limitations:<br></strong><br>1.Sufferes from vanishing gradient problem<br>2.Saturates at extreme inputs<br>3.Slower learning for deep networks in some cases</pre><h4><strong>4.ReLU (Rectified Linear Unit) Function</strong></h4><p>The ReLU is an activation function used in neural networks. It converts all negative input values into 0 and keeps positive values unchanged.</p><p>formula : Relu(x) = max(0.x)</p><p><strong>Working of ReLU Function</strong></p><ol><li>The neural network receives an input value.</li><li>The input is passed through the ReLU function.</li><li>If the input is negative, ReLU returns 0.</li><li>If the input is positive, ReLU returns the same value.</li><li>The output is passed to the next layer.</li></ol><pre><strong>When to Use ReLU?</strong><br><br>    Hidden layers: Commonly used in neural networks.<br><br>    Deep Learning: Helps models learn complex patterns.<br><br>    CNN: Widely used in Convolutional Neural Networks.<br><br>    Faster training: Simple computation makes it efficient.<br><br><strong>Advantages:</strong><br><br>    Faster computation and training.<br>    <br>    Helps reduce the vanishing gradient problem.<br>    <br>    Introduces non-linearity into neural networks.<br>    <br>    Improves learning in deep neural networks.<br>    <br><br><strong>Limitations:</strong><br><br>    Dying ReLU: Neurons can get stuck outputting zero.<br><br>    Not zero-centered: Outputs are never negative.<br><br>    Not differentiable at zero: Its derivative is undefined at exactly zero (a conventional value is chosen during training).<br><br><strong>Tricks</strong><br>    Negative input → 0<br><br>    Positive input → Same value<br><br>    Output range → 0 to +∞<br><br>    Commonly used in hidden layers.</pre><h4>5. Leaky ReLU (Leaky Rectified Linear Unit)</h4><p>The Leaky ReLU is an activation function that allows small negative values instead of converting all negative inputs into zero.</p><p>It is an improved version of the ReLU function</p><p>formula : f(x) = max(0.01*x , x)</p><ul><li>If input is positive → Output remains the same.</li><li>If input is negative → Output becomes a small negative value (0.01 × input).</li></ul><p><strong>Working of Leaky ReLU</strong></p><ol><li>The neural network receives an input value.</li><li>The input is passed through the Leaky ReLU function.</li><li>If the input is positive, it returns the same value.</li><li>If the input is negative, it returns a small negative value.</li><li>The output is passed to the next layer.</li></ol><pre><strong>When to Use Leaky ReLU?</strong><br><br>    Hidden layers: Used in neural networks.<br><br>    Deep Learning: Helps prevent dying ReLU problems.<br><br>    CNN: Can be used in convolutional neural networks.<br><br>    Negative inputs: Useful when we don&#39;t want to completely remove negative values.<br><br><strong>Limitations:</strong><br><br>    Small negative output: May still provide very small gradients.<br><br>    Slope selection: Choosing the negative slope can affect performance.<br><br>    Not zero-centered: Outputs are not balanced around zero.<br><br>Difference b/w leaky ReLU:<br><br><strong>ReLU  </strong>                                              <strong>Leaky ReLU</strong><br><br>Negative input → 0                    Negative input → Small negative value<br><br>Can cause dying ReLU                  Helps reduce dying ReLU<br><br>Positive input unchanged              Positive input unchanged</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2ab5fc541f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KNN Classification/Regression]]></title>
            <link>https://medium.com/@nandinigundimeda2025/knn-classification-regression-4b955eb22677?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b955eb22677</guid>
            <category><![CDATA[knn-implemention]]></category>
            <category><![CDATA[knn-classification]]></category>
            <category><![CDATA[knn-regression]]></category>
            <category><![CDATA[knn-working]]></category>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Thu, 24 Sep 2026 16:46:20 GMT</pubDate>
            <atom:updated>2026-09-24T17:18:53.428Z</atom:updated>
            <content:encoded><![CDATA[<p>Before jumping to the KNN algorithm, I would like to discuss about the types involved in machine learning and what are the algorithms , and the different types of tasks in ML</p><p>Types Machine Learning :</p><p>Mainly here i want to discuss about 2 types of Machine Learning</p><h4>1.Supervised Machine Learning</h4><p>Types of tasks : Classification &amp; Regression</p><p>Algorithms :</p><ol><li>Distance Based Approach</li></ol><ul><li>K — Nearest Neighbors (KNN)===&gt; used Classification &amp; Regression</li></ul><p>2. Probability Based Approach</p><ul><li>Naive Bayes (NB) ===&gt; used for Classification</li></ul><p>3. Rule Based Approach</p><ul><li>Decision Tree ===&gt;used for Classification &amp; Regression</li></ul><p>4. Boundary Based Approach</p><ul><li>Linear Regression ======&gt; used for Regression</li><li>Logistic Regression =====&gt; used for Classification</li><li>Support Vector Machine =&gt; used for Classification</li></ul><p>5.Ensembles</p><ul><li>Voting Ensembles — — — — →|</li><li>Stacking Ensembles — — — →| used for Regression &amp; Classification</li><li>Bagging Ensembles — — — → |</li><li>Boosting Ensembles — — — →|</li></ul><h4>K — Nearest Neighbors (KNN)</h4><h4>1. What is KNN?</h4><p>The easiest way to understand KNN is:</p><p><strong><em>“Tell me what the most similar data points around me are, and I’ll use them to make my prediction.” </em></strong>KNN does not try to build a complicated mathematical equation during training. Instead, it <strong>memorizes the training data</strong> and, when a new data point comes in, it looks for the <strong>K most similar points</strong>.</p><p>KNN is a Distance or Instance based approach. It is also called as a lazy learner. Doesn’t learn anything during training it simply memorizes the train data ,during prediction it calculate the distance from a query data point to the every datapoint present in training data. Supports for both classification , Regression with different approaches.</p><h4>Working of KNN Algorithm:</h4><ol><li>Choose the value of K(n_neighbors)</li><li>Create the distance between the new data point and all the training datapoints</li><li>Sort the distances in ascending/ descending order, find the least distance based on k value</li><li>Select the k closest neighbors</li><li>Assigns the class the appears most frequently among those neighbors</li></ol><p>Suppose the 5 most similar students are:</p><pre>Student 1 → Python<br>Student 2 → Python<br>Student 3 → Java<br>Student 4 → Python<br>Student 5 → Python</pre><p>Python has <strong>4 votes out of 5</strong>.</p><p>So KNN predicts:</p><pre>New Student → Python</pre><p>1. What does “K” mean?</p><p>The <strong>K</strong> represents the number of nearest neighbors we consider.</p><p>For example:</p><pre>K = 3<br>means: Look at the 3 closest data points.</pre><pre>K = 5<br>means: Look at the 5 closest data points.</pre><p>So if: k =5</p><pre>Neighbor 1 → A<br>Neighbor 2 → A<br>Neighbor 3 → B<br>Neighbor 4 → A<br>Neighbor 5 → B</pre><p>Then:</p><pre>A → 3 votes<br>B → 2 votes</pre><p>Prediction: class A</p><p>In simple</p><pre>                                Training Data<br>                                      ↓<br>                               Store the data<br>                                      ↓<br>                               New data point<br>                                      ↓<br>                            Calculate distances<br>                                      ↓<br>                            Find K nearest points<br>                                      ↓<br>                         ┌────────────┴────────────┐<br>                         ↓                         ↓<br>                   Classification              Regression<br>                         ↓                         ↓<br>                     Majority vote            Average value<br>                         ↓                         ↓<br>                      Prediction              Prediction</pre><p>There different ways to calculate the distance</p><ol><li>Euclidean Distance</li><li>Manhattan Distance</li><li>Minkowski</li></ol><p>Formula changes based on p - value</p><p>if p = 1 — — — — — — — — — — → Manhattan</p><p>if p = 2 — — — — — — — — — — → Euclidean</p><p>if p = 3 — — — — — — — — — — → Minkowski</p><p>Formula :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/0*TSPdJHS2VVU_cHm1" /></figure><p>D(x, y) ===&gt; calculating distance of training data point, test data point</p><p>Lets understand with small dataset</p><pre>Train data:<br>| Study Hours (X) | Marks (Y) |<br>| ----------------| --------- |<br>|               1 |        20 |<br>|               2 |        30 |<br>|               3 |        40 |<br>|               4 |        50 |<br>|               5 |        60 |<br>|               6 |        70 |<br>|               7 |        80 |<br><br>Test data : <br>| Study Hours | Actual Marks |<br>| ----------- | ------------ |<br>|           8 |           90 |<br>|           9 |          100 |<br>|          10 |          110 |</pre><p>k = 3</p><p>KNN Regression predicts a value by taking the <strong>average of the Y values of the K nearest neighbors</strong>.So formula ,</p><p>y_pred = y1+y2+y3 /3</p><pre>## test datapoint X = 8<br><br>| Training X |  Marks | Distance from 8 |<br>| ---------- | ------ | --------------- |<br>|          1 |     20 |               7 |<br>|          2 |     30 |               6 |<br>|          3 |     40 |               5 |<br>|          4 |     50 |               4 |<br>|          5 |     60 |               3 |---<br>|          6 |     70 |               2 |--- <br>|          7 |     80 |               1 |---<br><br>The 3 nearest neighbors<br>(7,80),(6,70),(5,60)<br>y_pred  = 80+70+60/3<br>Actual value = 90<br>So:<br>Error = 90−70=20<br><br>Similarly for calculate for x= 9 , x = 10<br><br>| Test X | Actual Y | 3 Nearest Y | Predicted Y |<br>| ------ | -------- | ----------- | ----------- |<br>|      8 |       90 | 80, 70, 60  |        70   |<br>|      9 |      100 | 80, 70, 60  |        70   |<br>|     10 |      110 | 80, 70, 60  |        70   |</pre><p>Classification:</p><pre>Train data<br>| Study Hours | Marks | Class |<br>| ----------: | ----: | ----- |<br>|           1 |    20 | Fail  |<br>|           2 |    30 | Fail  |<br>|           3 |    40 | Fail  |<br>|           4 |    50 | Pass  |<br>|           5 |    60 | Pass  |<br>|           6 |    70 | Pass  |<br>|           7 |    80 | Pass  |<br><br>Test data:<br>| Study Hours | Actual Marks | Actual Class |<br>| ----------: | -----------: | ------------ |<br>|           8 |           90 | Pass         |<br>|           9 |          100 | Pass         |<br>|          10 |          110 | Pass         |<br><br>For test datapoint x = 8<br>|  X | Class | Distance |<br>| -: | ----- | -------: |<br>|  7 | Pass  |        1 |<br>|  6 | Pass  |        2 |<br>|  5 | Pass  |        3 |<br>similarly calculate for x = 9 ,x = 10<br><br>Predictions:<br>| Test X | Actual Class | 3 Neighbors      | Prediction |<br>| ------ | ------------ | ---------------- | ---------- |<br>|      8 | Pass         | Pass, Pass, Pass |   Pass     |<br>|      9 | Pass         | Pass, Pass, Pass |   Pass     |<br>|     10 | Pass         | Pass, Pass, Pass |   Pass     |<br><br>Accuracy : Total Predictions/Correct Predictions​<br><br>Accuracy : 3/3 = 100%</pre><p><strong>KNN Limitations</strong></p><ul><li><strong>Sensitive to outliers</strong> → Outliers can affect nearest-neighbor selection and predictions.</li><li><strong>Scaling required</strong> → Features with larger ranges dominate distance.</li><li><strong>Choice of K matters</strong> → Small K = noisy; large K = less sensitive but may underfit.</li><li><strong>Slow for large datasets</strong> → Calculates distances to many points.</li><li><strong>Poor with high dimensions</strong> → Distance becomes less meaningful.</li><li><strong>Poor extrapolation</strong> → Cannot predict well outside the training-data range.</li><li><strong>Memory intensive</strong> → Stores the training dataset.</li></ul><p><strong>Outlier effect:</strong></p><ul><li><strong>Regression:</strong> High impact because it uses the <strong>average</strong>.</li><li><strong>Classification:</strong> Can affect the <strong>majority vote</strong>, especially with small K.</li></ul><p>Large K → Smoother model → Underfit<br> Small K → More sensitive model → Overfit</p><p>Goal is to find the best k -value by adjusting the parameters of the algorithm</p><p><strong>n_neighbors </strong>: tells the model how many nearest data points to consider when making prediction</p><p><strong>weights </strong>: uniform(default) (or) distance … it determines how much importance each neighbor gets</p><p>uniform → Each neighbor has equal chance</p><p>distance → Close neighbors get more importance</p><p><strong>p </strong>: it is the distance metric</p><p>(default)Euclidean , Manhattan ,Minkowski.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b955eb22677" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Text Data Preprocessing]]></title>
            <link>https://medium.com/@nandinigundimeda2025/text-data-preprocessing-ec99c2e9e868?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec99c2e9e868</guid>
            <category><![CDATA[steps-for-text-preprocess]]></category>
            <category><![CDATA[how-to-preprocess-text]]></category>
            <category><![CDATA[text-data-preprocessing]]></category>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 11:58:55 GMT</pubDate>
            <atom:updated>2026-08-20T11:58:55.242Z</atom:updated>
            <content:encoded><![CDATA[<p>Text preprocessing is the process of cleaning and transforming new text into a format(Numerical) that a computer and can understand and analyze. It is a fundamental step in Natural Language Processing.</p><p><strong>Flow of Text Preprocessing:</strong></p><p>One of the most complex data is <strong>text data</strong> . In text data the collection of unique words is called <strong>vocabulary , </strong>single row is called as <strong>document,</strong>the collection of documents or entire text data is called <strong>Corpus.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74S_qNx74Do0dCZ-1QnQlg.png" /></figure><h4>1. Lowering</h4><p>Convert all characters to lowercase</p><p><strong>Why it important?</strong></p><p>Ex : Machine, machine ,MACHINE<br>these three words says same thing but computer treats these as 3 different strings. Lowering reduces redundancy , dimensions. This reduces Vocabulary size .</p><p>But lowering is not always necessary</p><p>Example : US Vs us , Apple Vs apple</p><p>US → company , us →pronoun</p><p>Apple → Company , apple → fruit</p><p>Applications :simple sentiment analysis , Fraud Detection</p><h4>2. Punctuation Removal</h4><p>Many ML tasks don’t need punctuation as a separate feature.Punctuation creates unnecessary variations.</p><p>Example : hello, hello!, hello!!</p><p>If we don’t handle punctuation these might create different tokens. But don’t blindly remove punctuation</p><p>Punctuation can sometimes contain important information.</p><p>For example:</p><p><em>I&#39;m</em></p><p>If simply removing &#39;, you might get:</p><p><em>Im </em>Instead, you might want: <em>I am</em></p><p>Similarly:</p><p><em>can&#39;t </em>could be converted to:<em>cannot</em></p><p><strong>i) Handling Emoji’s :</strong></p><p>Modern text contains many emojis , there are 2 ways to handle</p><ol><li>Remove emoji from text</li><li>Extract the meaning of the emoji , useful for sentimental analysis</li></ol><p><strong>ii) Normalizing the text</strong></p><p>Ex: “pls send me the file asap” — — → “please send me the file as soon as possible”</p><h4><strong>3. Tokenization</strong></h4><p>Splitting text into smaller units are called tokens,the process is called tokenization.</p><p>Some of the types tokenization</p><p><em>Sentence Tokenization: Breaking down the paragraph/document into sentences , and each sentence is known as token. Eg :Text analysis</em></p><p><em>Word Tokenization : Breaking a sentence into individual words/tokens</em></p><p><em>Subword Tokenization: Breaking a word into smaller pieces.</em></p><p>Eg : “unhappiness” — →[“un”, “happiness] (or) it might be split into [“un”, “happy”, “ness”]</p><p><strong>Why do we tokenize?</strong></p><p>A computer doesn’t naturally understand an entire sentence as individual meaningful units. We need to break the sentence into pieces that can be processed.</p><h4>4.Stopwords Removal</h4><p>Removing stopwords are really important before converting the text data into numerical .Stopwords are very common words that often contribute relatively little to a particular NLP task.</p><p>Examples in English include:</p><pre>the,is,a,an,of,in,on,and,to,for</pre><p>If they don’t help your task, removing them can:</p><ul><li>Reduce the number of tokens</li><li>Reduce vocabulary size</li><li>Reduce computational requirements</li><li>Focus the model on potentially more informative words</li></ul><h4>5.Stemming</h4><p>Stemming is the process to remove the suffixes/prefixes from the word with the simple rules to get the root word.</p><p>Eg : playing → play (after stemming)</p><p>Stemming can produce words that aren’t actual English words.For example, a stemmer might produce:</p><pre>studies → studi</pre><h4>6.What is lemmatization?</h4><p>Lemmatization tries to convert a word to its proper <strong>base/dictionary form</strong>, called a <strong>lemma</strong>.</p><p>For example:</p><pre>running → run<br>ran → run<br>better → good<br>mice → mouse</pre><p>The exact result depends on the linguistic model/tool and context.</p><p><strong>Why use it?</strong></p><p>It produces more linguistically meaningful normalization than simple stemming.</p><p>Example:</p><pre>The children are running.</pre><p>could be reduced conceptually to:</p><pre>child run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*xZJQC0And05DF1e8yFnkyQ.png" /></figure><h4>7. Vectorization</h4><p>Vectorization is a process to converting text data into numerical format. Its very important because it machine cannot directly process the text.There are several methods to convert text to numbers, few of them are :</p><h4>i)Bag of Words (BoW):</h4><p>Bag of words is a simple preprocessing technique used in NLP.</p><p><em>Step 1: Identifies the unique words from the corpus.</em></p><p><em>Step 2: Sort them in alphabetical order</em></p><p><em>Step 3: Assigns numeric value</em></p><p>There 2 methods in BoW:</p><ol><li>Binary Bag of words</li><li>Frequency based Bag of Words</li></ol><p><strong>Binary Based Bag of Words :</strong></p><p>If the word present in the document assign ‘1’ , no matter how many times it occur, if the word is not present in the document then assign ‘0’.</p><p><strong>Frequency Based Bag of Words :</strong></p><p>Count the words appears in the document , if the word appear twice in a document → assign 2 to the word .Example :</p><p>Doc 1 — → learning machine learning is easy</p><p>Doc2 — → Python is easy to understand</p><p>Doc3 — → machine learning use python library</p><p>Now converting using both methods</p><p><strong>Binary Bag of Words</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WMe_NPlsUVMgL-rGo4735w.png" /><figcaption>Binary bag of words use only 1’s and 0’s</figcaption></figure><p><strong>Frequency Bag of Words</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*se8-VzEAhG1-F_7e8wdI2A.png" /></figure><p><strong>Limitations :</strong></p><ul><li><strong>Ignores word order</strong> — It does not consider the sequence of words.</li><li><strong>No context understanding</strong> — It cannot understand the meaning of a word based on its context.</li><li><strong>High dimensionality</strong> — A large vocabulary creates very large vectors.</li><li><strong>Sparse representation</strong> — Most values in the vector are 0.</li><li><strong>Does not capture semantics</strong> — It cannot understand relationships between words.</li><li><strong>Synonyms are treated differently</strong> — &quot;car&quot; and &quot;automobile&quot; are considered separate words.</li><li><strong>Polysemy problem</strong> — The same word with different meanings is treated as the same feature, e.g., &quot;bank&quot;.</li><li><strong>Out-of-vocabulary (OOV) problem</strong> — It cannot properly represent words that were not present in the training vocabulary.</li><li><strong>No long-term dependencies</strong> — It cannot capture relationships between words that are far apart.</li><li><strong>Sensitive to vocabulary size</strong> — More vocabulary means more memory and computation.</li></ul><h4>ii) TF — IDF</h4><p>Term Frequency — Inverse Document Frequency is a numerical technique used in NLP to convert text document into weighted numerical vectors. It is a measure how important a word in a document compared with a collection of documents.</p><p>If a word get:</p><p>High score: — important and specific to a document</p><p>Low score: — common word appearing every where</p><p>formula</p><pre>TF - IDF = TF *IDF<br><br>TF = no. of times word appear in document<br>     ____________________________________<br>     no. of words in  documents<br><br>IDF = log(total no.of documents/ no.of documents containing word)<br></pre><p>To apply this on text data:</p><p>Text document → Text Cleaning → Tokenization → stopword removal →TF-IDF</p><p><strong>Limitations :</strong></p><ul><li><strong>Still ignores word order and context.</strong></li><li>Produces a <strong>sparse, high-dimensional matrix</strong>.</li><li>Doesn’t understand synonyms: <em>car</em> and <em>automobile</em> are treated as different words.</li><li>Doesn’t understand deeper semantic meaning.</li><li>Can be less effective than modern embeddings such as <strong>Word2Vec, GloVe, or BERT</strong> for complex NLP tasks.</li></ul><p><strong>Advantages:</strong></p><ul><li>This is Normalization of Bag of Words</li><li>Reduces the importance of <strong>very common words</strong>.</li><li>Gives higher importance to words that are <strong>frequent in one document but rare across documents</strong>.</li><li>Often better than raw word counts for <strong>document similarity and information retrieval</strong>.</li><li>Still relatively simple and computationally efficient.</li><li>Produces interpretable features.</li></ul><p>Links to numerical , categorical Preprocessing Techniques:</p><ul><li><a href="https://medium.com/@nandinigundimeda2025/data-preprocessing-techniques-66e8736464df">Data Preprocessing Techniques</a></li><li><a href="https://medium.com/@nandinigundimeda2025/categorical-data-preprocessing-8ef7fde9be49">Categorical Data Preprocessing</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec99c2e9e868" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Categorical Data Preprocessing]]></title>
            <link>https://medium.com/@nandinigundimeda2025/categorical-data-preprocessing-8ef7fde9be49?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ef7fde9be49</guid>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 12:21:10 GMT</pubDate>
            <atom:updated>2026-08-06T12:21:10.733Z</atom:updated>
            <content:encoded><![CDATA[<p>It is a process of converting categorical values(words) to numerical values</p><p>Before going into the preprocessing techniques, must and should know the types of categorical data</p><h4>Types of Categorical Data :</h4><ol><li>Nominal data → categories doesn’t have any natural order. Examples : Gender , City , Color ,e.t.c</li><li>Ordinal data→ Categories have meaningful order. Examples : Sizes , Education , High Vs Low , e.t.c</li></ol><p><strong>Why we need to encode the categorical data:</strong></p><p>Because machine learning algorithms perform mathematical operations which requires numerical input.</p><p><strong>Technique — — — — — — — — — — — — — -→ Best for</strong></p><p>Label Encoding — — — — — — — — — — — → Binary or Target Labels</p><p>Ordinal Encoding — — — — — — — — — — → Ordered Categories</p><p>One-Hot Encoding— — — — — — — — — — → Nominal Categories</p><p>Dummy Encoding — — — — — — — — — — → Avoids Muilticollinearity</p><p>Frequency Encoding — — — — — — — — — → High Cardinality Categories</p><p><strong>Label Encoding :</strong></p><p>Assigns unique integer to each category. Example:</p><pre>Color --------------------&gt; Encoded<br>Red-----------------------&gt; 0<br>Blue----------------------&gt; 1<br>Green---------------------&gt; 2<br><br>Implemtation: <br>&gt;&gt; from sklearn.preprocessing import OrdinalEnoder <br>&gt;&gt; label_encoder = OrdinalEncoder()<br>&gt;&gt; X_train_trans =label_encoder.fit_transform(X_train)  <br>&gt;&gt; X_test_trans  = label_encoder.transform(X_test)</pre><h4>Ordinal Encoding :</h4><p>Used when categories have a natural order, applies when categories supports comparisons. Examples: high &gt;low ,small&lt;medium&lt;large etc</p><pre>Education ---------------&gt; Encoding <br>School-------------------&gt; 1<br>Graduation---------------&gt; 2<br>PostGraduation-----------&gt; 3<br>PHD ---------------------&gt; 4<br>Implementation:<br>from sklearn.preprocessing import OrdinalEncoder<br>oe  = OrdinalEncoder(categories = [[&#39;School&#39;, &#39;Graduation&#39;,&#39;PostGraduation&#39;, &#39;PHD&#39;]])<br>X_train_trans = oe.fit_transform(X_train)<br>X_test_trans = oe.transform(X_test)</pre><h4>One -Hot Encoding :</h4><p>Assigning numbers to nominal data , can create false ordering. So one-hot encoding creates separate binary columns for each category. Example</p><pre>      Red  Green  blue<br>Red    1      0    0<br>Green  0      1    0<br>Blue   0      0    1<br><br>Simple to understand this: assign 1 when the color matches , else assign 0<br>creates a pattern for each color:<br>red ----&gt;[1,0,0]<br>Green --&gt;[0,1,0]<br>Blue ---&gt;[0,0,1]<br><br>Implementation:<br>from sklearn.preprocessing import OneHotEncoder<br>ohe = OneHotEncoder()<br>X_train_trans = ohe.fit_transform(X_train)<br>X_test_trans  = ohe.transform(X_test)</pre><p>Disadvantages :</p><ul><li>Creates many columns</li><li>Memory problem with high cardinality feature.</li></ul><h4>Dummy Encoding :</h4><p>Similar to One-Hot Encoding , but removes one category to avoid the dummy variable trap. Avoids multi-collinearity</p><pre>      Blue    Green <br>Red    0        0<br>Blue   1        0<br>Green  0        1<br><br>red ---&gt; [0,0]<br>blue---&gt; [1,0]<br>Green--&gt; [0,1]</pre><p>Note:</p><ul><li>Never apply label Encoding to nominal data</li><li>One-Hot Encoding increases dimensionality</li><li>Encoding choice depends on:</li></ul><ol><li>Number of categories</li><li>Type of Variable</li><li>ML Algorithm</li><li>Dataset size</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ef7fde9be49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Preprocessing Techniques]]></title>
            <link>https://medium.com/@nandinigundimeda2025/data-preprocessing-techniques-66e8736464df?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/66e8736464df</guid>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 10:41:30 GMT</pubDate>
            <atom:updated>2026-08-06T10:41:30.811Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s dive deeper into the Machine Learning workflow ,In the Machine learning life cycle data preprocessing is one if the important step to build a model.</p><p><strong>Why data need to be preprocess?</strong></p><p>A machine Learning Model is a mathematical relationship between Input Variable (X), Target variable(y) , model excepts the data to be in structured , numerical format.</p><p>Data Collection →Data Cleaning →EDA →Identifying Target Variable →Splitting Data: Train, Test sets →Data Preprocessing.</p><p><strong>Data preprocessing is </strong>nothing but converting non - numerical, unstructured data into numerical data, structured data. Data preprocessing techniques are differ from data to data. Here are the types of data that I’m going to discuss about Numerical data, Categorical Data, Text Data.</p><h4>Numerical Data preprocessing</h4><p>Already data is in structured , numerical do still we need to perform preprocessing on this data ?Yes, its often require to preprocess the numerical data. The two techniques we have,</p><ol><li>Feature Scaling</li><li>Feature Transformation</li></ol><p>Because, the real world data be like …</p><p>Example : Employee experience ,salaries in company XYZ.</p><p>Experience— → 1,2,3,4,5,6,1,4,2</p><p>Salary— — — — → 24000,30000,54000,70000, 85000,90000,25000,70000, 33000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*_t8EZFk9OyPf8AAEjOJCHQ.png" /><figcaption>Not able to compare both Expericence, Salary on same scale</figcaption></figure><ul><li>Different numerical features have different units and ranges.</li><li>Features with larger magnitudes dominate smaller-valued features.</li><li>Smaller-valued features become difficult to visualize and may contribute less to many machine learning algorithms.</li></ul><p>To solve this problem we need to scale the data</p><p>Why scaling is important: The main reason for scaling data is to ensure that features with larger numerical values do not dominate features with smaller values during model training.</p><p><strong>Feature Scaling :</strong> It is a numerical preprocessing technique used to scale the data , this changes the representation of the data , but remains the distribution same. Here are the 3 types of Scaling Techniques :</p><h4>1. MinMaxScaler (or) Normalization :</h4><p>This is the scaler which translates the each feature individually so that features are with in the range between 0 to 1.</p><p>Formula :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*h8vjKAR0751Y8pEywedKEg.png" /></figure><p>Applying MinMaxScaler to the data we have using scikit-learn library:</p><p>&gt;&gt; from sklearn.preprocessing import MinMaxScaler<br>&gt;&gt; x_norm = MinMaxScaler()<br>&gt;&gt; x_trans = x_norm.fit_transform(df)</p><p>&gt;&gt; norm_data = pd.DataFrame(x_trans , columns = df.columns)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*6LWRb1fh1fIlu0q1O8dthQ.png" /><figcaption>Now we can able to compare the experience , salary on the same axis</figcaption></figure><p><strong>Use when data is free from outliers , and data is normally distributed.</strong></p><p>As we discuss the range of the scale to be in 0 — 1 but ,in this case the range is beyond the actual. Reason for this is , data contains outliers . Maximum or Minimum values might be the outlier, working with outliers may exceeds the actual range.</p><h4>Standard Scaler :</h4><p>It is a scaler which used to translate the data to center i.e mean of the feature = 0 ,scale the data to unit variance i .e standard deviation if the feature = 1 . Works better than MinMaxScaler when data contains outliers.</p><p>Formula :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*7f_2t9UxXgD2yXY9SxLKNA.png" /></figure><p>Applying StandardScaler on the data we have using scikit — learn:</p><p>&gt;&gt; from sklearn.preprocessing import StandardScaler<br>&gt;&gt; x_ss = StandardScaler()<br>&gt;&gt; x_trans = x_ss.fit_transform(df)</p><p>&gt;&gt; norm_data = pd.DataFrame(x_trans , columns = df.columns)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*_dE6W5y2f9vONqwC2mcO9g.png" /></figure><p>If we check the mean , std of the transformed data becomes mean = 0 , std = 1. Another name for StandardScaler is z- transformation (or)</p><p>Not applicable when data have extreme outliers.</p><h4><strong>Robust Scaler :</strong></h4><p>Unlike Standard Scaler, it uses median, IQR(Inter Quartile Range) to scale the data cause compared to mean , standard deviation median , IQR less effect with outliers .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*d2dL-n1fcke3V-sjMYTv6g.png" /></figure><p>Applying RobustScaler on the data we have using scikit — learn:</p><p>&gt;&gt; from sklearn.preprocessing import RobustScaler<br>&gt;&gt; x_rs = RobustScaler()<br>&gt;&gt; x_trans = x_rs.fit_transform(df)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*LUA3fXHlVinq2_vz-AcKHw.png" /></figure><h4>Data Transformations:</h4><p>Data transformations are the preprocessing techniques used to reduce the skewness and brings the data close to Gaussian Distribution.</p><p>In simple ,Data Transformation technique changes the representation of the data as well as shape of the distribution of the existing data , means it also changes the actual data. Some of the transformations are :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*HB-wQo25HKQ6Y2E4Yg9lPQ.png" /></figure><p>Implementation:</p><pre>log_tf = FunctionTransformer(np.log1p, validate=True)<br><br>X_train_log = log_tf.fit_transform(X_train)<br>X_test_log = log_tf.transform(X_test)<br></pre><pre>boxcox_tf = PowerTransformer(method=&#39;box-cox&#39;)<br><br>X_train_boxcox = boxcox_tf.fit_transform(X_train)<br>X_test_boxcox = boxcox_tf.transform(X_test)</pre><pre>yeojohnson_tf = PowerTransformer(method=&#39;yeo-johnson&#39;)<br><br>X_train_yj = yeojohnson_tf.fit_transform(X_train)<br>X_test_yj = yeojohnson_tf.transform(X_test)</pre><p>Note : Box- cox is the tranformation applies the transfomation without requirement , but yeo-johnson applies the transformation when its requires</p><h4>Quantile Transformer</h4><p>The <strong>Quantile Transformer</strong> maps the feature distribution to either a <strong>uniform</strong> or <strong>normal (Gaussian)</strong> distribution based on feature ranks. It is especially useful for handling highly skewed data and reducing the effect of outliers.</p><pre>from sklearn.preprocessing import QuantileTransformer<br><br>qt = QuantileTransformer(<br>    output_distribution=&#39;normal&#39;)  # or &#39;uniform&#39;<br><br>X_train_qt = qt.fit_transform(X_train)<br>X_test_qt = qt.transform(X_test)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66e8736464df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Splitting →Train, Test]]></title>
            <link>https://medium.com/@nandinigundimeda2025/data-splitting-train-test-sets-30110510deea?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/30110510deea</guid>
            <category><![CDATA[splitting-data-in-ml]]></category>
            <category><![CDATA[why-we-need-to-split-data]]></category>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 12:34:10 GMT</pubDate>
            <atom:updated>2026-08-03T03:03:44.133Z</atom:updated>
            <content:encoded><![CDATA[<p>And why do we assume that future data follows same distribution of training data</p><p>To build a machine learning model, we need two important things:</p><p><strong>Data + Algorithm</strong></p><p>A typical machine learning workflow follows:</p><p>Data Collection → Data Cleaning → Exploratory Data Analysis (EDA) → Identifying Target Variable → Splitting Data → Model Training → Evaluation</p><p>After cleaning the data and performing EDA, the next important step is <strong>splitting the data</strong> into different sets.</p><h3>Data Splitting</h3><p>A dataset is usually divided into:</p><p><strong>Training Dataset</strong> → Usually 70–80% of data<br><strong>Validation Dataset</strong> → Usually 10–15% of data<br><strong>Testing Dataset</strong> → Usually 10–20% of data</p><p>Common splits:</p><p>Training — → 80% , 70% , 70% , 60%</p><p>Validation → 10% , 15% , 10% , 20%</p><p>Testing -— → 10% , 15% , 15% , 20%</p><h3>Why do we split the data?</h3><p>We split data to make sure the model learns useful patterns and can <strong>generalize</strong> to new, unseen data.</p><p>If we train and evaluate the model using the same data, the model may simply memorize the examples instead of learning the actual relationship between input and output.</p><p>A model that performs well only on training data but fails on new data is not useful in real-world applications.</p><h3>Why is the training dataset larger than validation and testing datasets?</h3><p>The training dataset usually gets the largest portion because the model needs enough examples to learn the underlying patterns from the data. Because we assume that our future data will follow the same distribution as training data.</p><p>But here comes an important question:</p><p><strong>Why do we assume that future data will follow the same distribution as training data?</strong></p><h3>Reason behind this assumption</h3><p>A machine learning model is trained using historical data, which is only a sample of the real-world data.</p><p>In real-world scenarios, it is impossible to collect every possible data point, including future observations.</p><p>Therefore, we assume that:</p><p><em>Future unseen data is generated from the same underlying distribution as the training data.</em></p><p>This assumption allows the model to learn patterns from historical data and apply those patterns to new, unseen examples.</p><p>For example:</p><p>Suppose we train a house price prediction model.</p><p>The training data shows:</p><ul><li>Larger houses usually have higher prices.</li><li>Houses in better locations usually cost more.</li><li>Newer houses usually have higher values.</li></ul><p>The model learns these relationships from historical data.When a new house comes into the system, we expect similar relationships to exist.If future data follows the same underlying distribution, the learned patterns remain valid, and the model can <strong>generalize well</strong>.</p><p>Simple example: we learn and solve 100 math problems before going to examination, we don’t memorize each and every problem , we understand the pattern of every problem and applying those patterns to solve a new problem</p><p><strong>What happens if future data follows a different distribution?</strong></p><p>If the future data is generated by a different process, the patterns learned from training data may no longer be useful. This situation is called: <strong>Distribution Shift / Data Drift</strong></p><p>Example:</p><p>A model is trained using customer behavior from 2024.In 2026, customer behavior changes significantly due to new technology or market trends.The old patterns may no longer represent reality.</p><p>As a result:</p><ul><li>Model accuracy decreases.</li><li>Predictions become less reliable.</li><li>The model may need retraining.</li></ul><h4>Mathematical intuition</h4><p>Machine learning tries to approximate an unknown function:</p><p><strong>y = f(x)</strong></p><p>We do not know the true function <strong>f</strong>.</p><p>Using training data, we try to estimate this function.</p><p>The learned model will work well only if future data is generated by the same underlying process.</p><p>If the underlying process changes, the model is no longer a good approximation of reality.</p><p><strong>Why Validation Dataset?</strong></p><p>The validation dataset is used during model development.</p><p>It helps us:</p><ul><li>Compare different algorithms</li><li>Tune hyper parameters (learning rate, max depth, number of estimators, etc.)</li><li>Select the best model</li><li>Detect over-fitting and under-fitting</li></ul><p>Since the validation data is used multiple times during development, it should be large enough to provide reliable feedback.</p><p><strong>Why Test Dataset?</strong></p><p>The test dataset answers one important question:</p><p><em>“How well will my final model perform on completely new, unseen data?”</em></p><p>The test dataset is kept separate from training and validation.</p><p>It is used only after the final model is selected.</p><p>This gives an unbiased estimate of how the model will perform in the real world.</p><p><strong>Does splitting data solve any other problems? Yes.</strong></p><p>One of the major problems it helps prevent is:</p><h3>Data Leakage</h3><p>Data leakage happens when information from outside the training process accidentally gets used while building the model.</p><p>This makes the model look better during evaluation, but it performs poorly on real-world unseen data.</p><p>Example of Data Leakage : Imagine predicting house prices.</p><p>Dataset:</p><p>House Size → Price</p><p>1000 sq ft → $100,000</p><p>1500 sq ft → $150,000</p><p>2000 sq ft →$200,000</p><p>Suppose we calculate statistics like mean and standard deviation using the complete dataset before splitting.</p><p>The test data information has now entered the training process.The model has indirectly seen information from the test data.The result may look like:</p><p>Training Accuracy: 99%<br>Testing Accuracy: 98%</p><p>But this performance is misleading.</p><p>In real-world prediction, the model will not have access to future data statistics.</p><p><strong>Correct Approach</strong></p><p>First split the data:</p><p>Data → Train/Test Split</p><p>Then:</p><p>Training Data → fit() → Learn parameters</p><p>Training Data → transform()</p><p>Test Data → transform()</p><p>The test data only receives the parameters learned from training data.</p><h3>Scikit-learn Estimator Methods</h3><h3>1. fit()</h3><p>fit() learns parameters from the training data.</p><p>It does not transform the data.</p><p>Examples:</p><ul><li>StandardScaler.fit(X_train) learns mean and standard deviation.</li><li>SimpleImputer.fit(X_train) learns missing value replacement strategy.</li></ul><h3>2. fit_transform()</h3><p>fit_transform() performs two operations:</p><ol><li>Learns parameters from training data using fit()</li><li>Applies those parameters to transform the same training data</li></ol><p>It is equivalent to:</p><pre>estimator.fit(X_train)</pre><pre>X_train_transformed = estimator.transform(X_train)</pre><h3>3. transform()</h3><p>transform() applies the parameters learned during fit() to new data.</p><p>It does not learn anything new.</p><p>Used for:</p><ul><li>Validation data</li><li>Test data</li><li>New unseen data</li></ul><p>Example:</p><pre>scaler.fit(X_train)</pre><pre>X_train = scaler.transform(X_train)</pre><pre>X_test = scaler.transform(X_test)</pre><h4>Why don’t we call fit() on test data?</h4><p>Because it causes data leakage.</p><p>Wrong approach:</p><pre>scaler.fit(X_test)</pre><pre>X_test = scaler.transform(X_test)</pre><p>Here, the scaler learns information from the test dataset.</p><p>In real-world scenarios, future data statistics are not available during training.</p><p>Correct approach:</p><pre>scaler.fit(X_train)</pre><pre>X_train = scaler.transform(X_train)</pre><pre>X_test = scaler.transform(X_test)</pre><p>The test data only receives the transformation learned from training data.</p><h4>Final Takeaway</h4><p>Machine learning is not only about applying algorithms.</p><p>Understanding <strong>why</strong> we perform each step is more important than blindly following the workflow.</p><ul><li>Data splitting helps measure true model performance.</li><li>The distribution assumption allows generalization.</li><li>Validation helps improve the model.</li><li>Testing evaluates the final model honestly.</li><li>Proper use of fit and transform prevents data leakage.</li></ul><p>The goal is not just to build a model that works on known data, but to build a model that works on the real world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30110510deea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning workflow]]></title>
            <link>https://medium.com/@nandinigundimeda2025/machine-learning-and-life-cycle-f9e5f6e84a79?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9e5f6e84a79</guid>
            <category><![CDATA[machine-learning-workflow]]></category>
            <category><![CDATA[steps-to-build-a-ml-model]]></category>
            <category><![CDATA[what-is-machine-learning]]></category>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 17:52:46 GMT</pubDate>
            <atom:updated>2026-07-31T16:27:32.708Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning is a branch of Artificial Intelligence.Machine Learning is the process of training data to “learn” and identifying patterns from data ,using these patterns the machine makes predictions on new and unseen data,improve performance on task with experience rather than explicit programming.</p><p>Let’s dive into how a machine can learn:</p><p><strong>Traditional Method:</strong></p><p>Here, a machine doesn’t recognize or identify the patterns from data , decisions were based on the rules explicitly provided by the human. No learning is happens in this method so, this is the approach is also Known as Rule-Based approach. Writing 10- 50 rules/patterns may feels easy but when it comes to thousands of patterns might difficult to remember all the patterns for humans and time consuming.</p><p>Rule-Based Algorithms Fails: First we will see where it works,</p><p>Case1: Build an model where you have to decide whether person is eligible for vote or not.</p><p>Here simply 2 rules can decide whether a person is eligible or not, consider age is the feature /input for the model with the hard threshold we can build model with accurate predictions…. if age&lt;18 → not eligible , if age≥ 18 → eligible.</p><p>Case2: Build an model for gender classification based on voice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vlnER34j0xy8Nc8rfpMKcg.png" /><figcaption>Fig : Rule -Based algorithms fails ,blue →female, orange → male</figcaption></figure><p>Human voices naturally vary from person to person, and factors such as age, emotions, health conditions, speaking style, and recording quality can significantly affect voice characteristics. In addition, the pitch ranges of male and female voices often overlap, making it difficult to accurately classify every speaker using fixed thresholds. As a result, rule-based systems frequently make incorrect predictions and are not suitable for applications that require high accuracy. Make decisions on overlapping data requires to identify patterns ,rule based algorithm cannot handle every pattern ,this where Machine Learning comes into picture.</p><p><strong>ML works</strong> on mathematical logic, so the data must be converted into numerical form. Once represented as numbers, the algorithm applies mathematical operations to discover patterns and learn the relationship between inputs and outputs. ML models can build with 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*rkVTvwiFM4s9lJmls5mE6g.png" /></figure><p>Types of Machine Learning :</p><p><strong>Supervised Learning : </strong>The model learns from <strong>labeled data</strong>, where the correct output is already known. Dataset is with target variable</p><p>Tasks of Supervised Learning : Regression ,Classification</p><ul><li><strong>Input:</strong> Data + correct answers (labels)</li><li><strong>Goal:</strong> Predict the correct output for new data.</li><li>Examples : Email Spam detection, Image classification</li></ul><p><strong>Unsupervised Learning :</strong> The model learns from <strong>unlabeled data</strong> and finds hidden patterns or structures.</p><p>Tasks of Unsupervised Learning : Clustering , Dimensionality Reduction</p><ul><li><strong>Input:</strong> Data without labels</li><li><strong>Goal:</strong> Discover relationships or group similar data.</li><li>Examples : Customer basket analysis, Anomaly Detection.</li></ul><p><strong>Reinforcement Learning : </strong>The model learns by <strong>interacting with an environment</strong> and receiving <strong>rewards or penalties</strong> for its actions.</p><ul><li><strong>Input:</strong> Feedback in the form of rewards</li><li><strong>Goal:</strong> Learn the best sequence of actions to maximize reward.</li><li>Examples : Self driving Cars, Robot Navigation</li></ul><h4><strong>What Deep Learning ?</strong></h4><p>Deep Learning is a subset of Machine Learning , that uses Artificial Neural Networks (ANN) with multiple Layers called ‘deep’ Neural Networks automatically identify the patterns from large amounts of data.Unlike Machine Learning ,deep learning can learn important features from the data , it reduces the work of manual feature Engineering.</p><p><strong>Why Deep Learning is a subset of Machine Learning : </strong>Machine Learning</p><ul><li><strong>Machine Learning</strong> is the broad field of algorithms that learn from data.</li><li><strong>Neural Networks</strong> are one type of machine learning algorithm.</li><li><strong>Deep Learning</strong> is the name given to <strong>deep (multi-layer) neural networks</strong>.</li><li>It is considered a <strong>subset of Machine Learning</strong> because it still learns from data using the same ML principles; it simply uses a particular architecture (deep neural networks) rather than algorithms like decision trees, SVMs, or linear regression.</li><li>Real-world Applications :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*C-aFA4eYD4qmf9H852w9yQ.png" /></figure><ul><li><strong>Machine Learning (ML):</strong> Learns from historical data to identify patterns and make predictions or decisions. It usually requires humans to select the important features from the data.</li><li><strong>Deep Learning (DL):</strong> A subset of Machine Learning that uses deep neural networks to automatically learn complex patterns from large amounts of data, resulting in more accurate predictions for tasks like image and speech recognition.</li><li><strong>Generative AI (GenAI):</strong> A type of AI built mainly on Deep Learning that learns patterns from existing data and generates new content such as text, images, audio, videos, and computer code.</li></ul><h4>Machine Learning Life Cycle :</h4><p><strong>Step1: </strong>Problem Definition</p><p>Its very important to know on what problem we are working on , we are able to identify target variable , using the target variable we can state the type of Machine Learning (i.e Supervised , Unsupervised etc ).</p><p>If the target variable is present in the dataset →Supervised , the datatype of the target variable describes the type of algorithm will suits .</p><p>Numerical datatype : 1. Continuous →Regression model , 2. Discrete → Classification Model</p><p>If we not found the target variable in the dataset →Unsupervised Learning</p><p><strong>Step 2: </strong>Data Collection</p><p>Collect the data according to the problem statement.</p><p><strong>Step 3: </strong>Exploratory Data Analysis(EDA)</p><p>Understand the data , handle all the inconsistencies i.e. Null values , duplicates, Outliers ,data types, perform univariate , bivariate , multi-variate analysis on the data to know the relationship b/w input columns &amp; the target column (which features effecting the target column )</p><p><strong>Step 4:</strong> Splitting Data</p><p>Split the data into Training , Test sets to overcome the data leakage issue.</p><p><strong>Step 5:</strong> Data Preprocessing</p><p>Data Preprocessing is not a data cleaning , preprocessing is nothing but converting non-numerical data(text, image , audio, video) to numerical data, cause machine(mathematical function ) expects data is in numerical format .Apply preprocessing steps only on input columns of train, test set.</p><p><strong>Numerical Data Preprocessing: </strong>Feature Scaling , Feature Transformation</p><p><strong>Categorical Data Preprocessing : </strong>One-Hot Encoder, Label Encoding, Ordinal Encoding.</p><p><strong>Text Data Preprocessing :</strong> Bag of Words , TF -IDF etc</p><p><strong>Image Data :</strong> Image Flattening</p><p><strong>Step 6:</strong> Training Model</p><p>Train the model on preprocessed training data X_train_trans , y_train, by choosing the correct algorithm</p><p><strong>Step 7 : </strong>Making Predictions</p><p>input →model →output(prediction)</p><p><strong>Step 8 : </strong>Model Evaluation</p><p>Evaluating model means checking how correctly our model make predictions on unseen data.</p><p>Evaluation Metrics for different model:</p><p><strong>Regression :</strong> Mean Absolute Error(MAE), Mean Squared Error(MSE) , Root Mean Squared Error(RMSE),R² -Error, Adjusted R² error</p><p><strong>Classification : </strong>Accuracy Score , Confusion Matrix → Precision,Recall , F1-Score, AUC/ROC</p><p><strong>Clustering : </strong>Silhouette Score, Davies-Bouldin Index (DBI),Calinski-Harabasz Index (CH Score)</p><p><strong>Step 9: </strong>Model Tuning</p><p>Increasing the performance of the model , to make accurate predictions</p><p><strong>Step 10 :</strong> Model Deployment</p><p>To use the application we need to deploy the model using → streamlit, FastAPI , Hugging Face Space</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9e5f6e84a79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Numpy Broadcasting]]></title>
            <link>https://medium.com/@nandinigundimeda2025/numpy-broadcasting-77f3c17e5b3b?source=rss-2c5da1f37f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/77f3c17e5b3b</guid>
            <dc:creator><![CDATA[Nandini Gundimeda]]></dc:creator>
            <pubDate>Sun, 21 Dec 2025 14:46:50 GMT</pubDate>
            <atom:updated>2025-12-22T14:32:55.942Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog breaks down broadcasting step-by-step:<br> <strong>Introduction → What it is → Why we need it → How it works internally → Examples → Failure cases → Conclusion.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/0*IahlnafW8oqqE-LC" /></figure><blockquote>1. Introduction</blockquote><p>In traditional programming, performing arithmetic on arrays with different shapes often requires loops or manual resizing. NumPy eliminates this by introducing <strong>Broadcasting</strong> — an automatic method to make array operations work even when their shapes don’t match perfectly.</p><p>Broadcasting is one of the main reasons NumPy is used in <strong>Machine Learning</strong>, <strong>Deep Learning</strong>, <strong>Data Science</strong>, <strong>Image Processing</strong>, and <strong>Scientific Computing</strong>.</p><h3>2. What is Broadcasting?</h3><p><strong>Broadcasting</strong> is NumPy’s ability to <strong>automatically stretch or expand arrays</strong> during arithmetic operations so their shapes become compatible.</p><p>In simple words:<br> 👉 <strong>Broadcasting is a technique used by numpy to bring two arrays of different shapes to a common shape, where it is possible to perform any operation on the array.</strong><br> Example: If you add a 1D array to each row of a 2D matrix, NumPy automatically “broadcasts” the 1D array across all rows.</p><pre>A = [[1, 2],<br>     [3,4]]<br><br>b = [10]<br><br>A + b<br></pre><p>NumPy internally transforms b into:<br> [[10,10], [10,10]] <br> …without actually creating this copy! This is why broadcasting is efficient.</p><h3>3. Why Do We Need Broadcasting?</h3><p>Broadcasting solves <strong>three major problems</strong> in data operations:</p><p>✔ <strong>1. Performance</strong></p><p>Avoids Python loops → uses fast C-optimized operations.</p><p>✔ <strong>2. Memory Efficiency</strong></p><p>Does not create unnecessary copies(NumPy simulates the expansion virtually).</p><p>✔ <strong>3. Cleaner Code</strong></p><p>You write simple mathematical operations like, A+b</p><p>Instead of writing explict looping</p><pre>l=[[1,2],[3,4]]<br>a=[10]<br>result=[]<br><br>for row in l:<br>    new_row=[]<br>    for ele in range(len(row)):<br>        print(row[ele])<br>        new_row.append(row[ele]+ a[0])<br>    result.append(new_row)<br>print(result)</pre><h3>4. Internal Working of Broadcasting (The Rules)</h3><p>To understand broadcasting deeply, remember the <strong>Golden Rules</strong>.</p><p><strong>Rule 1: Compared shapes from right to left</strong></p><p>Example:<br> Shape A = (2,2)<br> Shape B = (1,)</p><p><strong>Rule 2: Dimensions are compatible when:</strong></p><ul><li>They are <strong>equal</strong>, OR</li><li>One of them is <strong>1</strong></li><li>Numpy adds a new dimension from the left side of the shape, then the shape becomes…(1,1)</li></ul><p><strong>Rule 3: Bring the shape to a common shape</strong></p><ul><li>Always broadcast lower shape to higher shape (or) less no.of elements to higher no.of elements.</li><li>Multiples the shape with a number to get the higher shape, this repeat the elements as many times to bring to same shape.</li></ul><p><strong>Rule 4: If none of the rules match → Broadcasting fails</strong></p><h4>Examples of Broadcasting</h4><ul><li>scalar + Array</li></ul><pre>arr = np.array([1,2,3])<br>arr + 5<br>print(arr)<br><br>output:<br>array([6,7,8])</pre><ul><li>1D array to 2D Matrix</li></ul><pre>A = np.array([[1,2,3],<br>              [4,5,6]])<br>b = np.array([10,20,30])<br>A + b<br><br>output:<br>array([[11, 22, 33],<br>       [14, 25, 36]])</pre><ul><li>Column Vector + Row Vector</li></ul><pre>col = np.array([[1],[2],[3]])<br>row = np.array([10,20,30])<br>col + row<br><br>output:<br>array([[11, 21, 31],<br>       [12, 22, 32],<br>       [13, 23, 33]])</pre><h3>6. Where Broadcasting Fails</h3><p>Broadcasting fails when dimensions are <strong>incompatible</strong>.</p><p>Example1:</p><p>A shape: (3, 4)<br>B shape: (3, 3)</p><p>Compare from right:<br> 4 ≠ 3 → ❌ Cannot broadcast</p><p>If no dimension is 1 or equal → broadcasting is impossible.</p><h3>7. Conclusion</h3><p>Numpy Broadcasting is not just a convenience — it’s a performance-boosting, memory-efficient technique that every data professional must understand. It allows you to:</p><p>✔ Write cleaner code<br> ✔ Avoid loops<br> ✔ Run operations faster<br> ✔ Work efficiently with ML/DL numerical data</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77f3c17e5b3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>