<?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 Manojkumar on Medium]]></title>
        <description><![CDATA[Stories by Manojkumar on Medium]]></description>
        <link>https://medium.com/@manojkumar8106875781?source=rss-d935260857ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HlYLWh7AE0FNb1sM</url>
            <title>Stories by Manojkumar on Medium</title>
            <link>https://medium.com/@manojkumar8106875781?source=rss-d935260857ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:05:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manojkumar8106875781/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[Evolution of Architectures for Sequence-Based Text Processing]]></title>
            <link>https://medium.com/@manojkumar8106875781/evolution-of-architectures-for-sequence-based-text-processing-2d78eb117e7b?source=rss-d935260857ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d78eb117e7b</guid>
            <dc:creator><![CDATA[Manojkumar]]></dc:creator>
            <pubDate>Sun, 29 Nov 2026 07:23:12 GMT</pubDate>
            <atom:updated>2026-11-29T07:23:12.052Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction :</strong></h3><p>Sequence-based text processing is an important area of Natural Language Processing (NLP) that enables machines to understand and process human language. Since text consists of words arranged in a specific order, models must understand both individual words and their relationships with other words in a sentence.</p><p>Over time, several Deep Learning architectures have been developed to improve sequence processing. The major evolution includes <strong>Recurrent Neural Networks (RNNs), Long Short-Term Memory (LSTMs), Gated Recurrent Units (GRUs), and Transformers.</strong></p><h3>1. RNNs (Recurrent Neural Networks):</h3><h4><strong>what is RNNs?</strong></h4><p>Recurrent Neural Networks are neural network architectures designed to process sequential data, such as text, speech, and time-series data.</p><p>Unlike traditional neural networks, RNNs maintain a hidden state (memory) that carries information from previous time steps.</p><h4>How does RNN works?</h4><ol><li>The model takes one word at a time as input.</li><li>It processes the current word along with information from the previous hidden state.</li><li>It updates its hidden state to remember relevant information.</li><li>This process continues until the entire sequence is processed.</li></ol><h4>Key components:</h4><ul><li>Input Layer: Receives words in the sequence.</li><li>Hidden State: Stores information from previous time steps.</li><li>Recurrent Connection: Transfers information from one time step to the next.</li><li>Output Layer: Produces predictions or results.</li></ul><h4>Limitations of RNNs:</h4><ul><li>Vanishing Gradient Problem: Makes learning long-term dependencies difficult.</li><li>Exploding Gradient Problem: Can cause unstable training.</li><li>Sequential Processing: Processes words one after another, making parallelization difficult.</li><li>Short-Term Memory: Often struggles to remember information from distant words.</li></ul><p><strong>Example:</strong> In the sentence “The movie was interesting because it had an excellent storyline,” a traditional RNN may struggle to connect distant words effectively.</p><p>These limitations led to the development of LSTMs and GRUs.</p><h3>2.LSTMs and GRUs:</h3><p>LSTMs and GRUs are improved versions of RNNs designed to overcome the difficulty of remembering long-term information.</p><h4>A. LSTM (Long Short-Term Memory):</h4><p>LSTM is a special type of RNN that uses a memory cell and gates to control what information should be remembered, updated, or forgotten.</p><h4>Key components:</h4><ol><li>Forget Gate: Decides which unnecessary information should be removed from memory.</li><li>Input Gate: Determines what new information should be stored.</li><li>Cell State: Maintains long-term information throughout the sequence.</li><li>Output Gate: Decides what information should be passed to the next time step.</li></ol><h4><strong>How does LSTM work?</strong></h4><ul><li>First, the Forget Gate removes irrelevant information.</li><li>Next, the Input Gate selects important new information.</li><li>The Cell State updates the stored memory.</li><li>Finally, the Output Gate generates the hidden state for the next step.</li></ul><h4>Advantages:</h4><ol><li>Captures long-term dependencies more effectively.</li></ol><p>2. Reduces the vanishing gradient problem.</p><p>3. Maintains important information across longer sequences.</p><h4>B. GRU (Gated Recurrent Unit):</h4><p>GRU is another improved RNN architecture that provides a simpler alternative to LSTM.</p><p>Unlike LSTM, GRU combines the cell state and hidden state into a single hidden state and uses only two gates.</p><h4>Key Components:</h4><ol><li>Update Gate: Determines how much previous information should be retained and how much new information should be added.</li><li>Reset Gate: Controls how much previous information should be ignored when processing new information.</li></ol><h4><strong>How does GRU work?</strong></h4><ul><li>The Reset Gate decides how much past information is relevant.</li><li>The Update Gate controls how the previous memory and new information are combined.</li><li>The updated hidden state is passed to the next time step.</li></ul><ol><li>Update Gate: Determines how much previous information should be retained and how much new information should be added.</li><li>Reset Gate: Controls how much previous information should be ignored when processing new information.</li></ol><h4><strong>How does GRU work?</strong></h4><ul><li>The Reset Gate decides how much past information is relevant.</li><li>The Update Gate controls how the previous memory and new information are combined.</li><li>The updated hidden state is passed to the next time step.</li></ul><h4><strong>Advantages:</strong></h4><ul><li>Simpler architecture than LSTM.</li><li>Requires fewer parameters.</li><li>Often trains faster than LSTM.</li><li>Handles sequential dependencies effectively.</li></ul><h4><strong>LSTM vs GRU:</strong></h4><ul><li>LSTM uses three gates and a separate cell state.</li><li>GRU uses two gates and a single hidden state.</li><li>LSTM offers more control over memory, while GRU provides a simpler and computationally efficient alternative.</li></ul><p>Although LSTMs and GRUs improve memory handling, they still process sequences sequentially. This limitation led to the development of Transformers.</p><h3>3. Transformers</h3><p>What are Transformers?</p><p>Transformers are advanced Deep Learning architectures introduced in the 2017 research paper <em>Attention Is All You Need</em>.</p><p>Unlike RNNs and LSTMs, Transformers process sequence information using an attention mechanism rather than recurrent connections.</p><p>Their main advantage is the ability to understand relationships between words across an entire sequence while allowing parallel processing during training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*N7QdfinTvvagFDUKxg57vQ.png" /></figure><h3>Architecture of Transformers</h3><p>The original Transformer architecture consists of two major parts:</p><ol><li>Encoder</li><li>Decoder</li></ol><h4>A. Input Embeddings</h4><p>Before processing text, words are converted into numerical representations called embeddings.</p><p>These embeddings represent the meaning and features of words in a numerical format that the model can understand.</p><h4>B. Positional Encoding</h4><p>Since Transformers do not process words sequentially like RNNs, they need additional information about word positions.</p><p>Positional Encoding adds positional information to word embeddings so that the model understands the order of words in a sentence.</p><h4>C. Encoder</h4><p>The Encoder reads the input sequence and generates meaningful contextual representations.</p><p>Each encoder layer contains the following components:</p><h4><strong>1. Multi-Head Self-Attention</strong></h4><p>Self-Attention helps the model understand relationships between different words in a sentence.</p><p>For example, in the sentence “The animal didn’t cross the road because it was tired,” attention helps the model understand that “it” refers to “animal.”</p><p>Multi-Head Attention uses multiple attention heads to learn different relationships between words simultaneously.</p><p>It works using three important elements:</p><ul><li>Query (Q): What information is the model looking for?</li><li>Key (K): What information does each word contain?</li><li>Value (V): What information should be collected?</li></ul><p>The attention mechanism calculates how much importance each word should give to other words.</p><h4><strong>2. Add &amp; Norm</strong></h4><p>This component contains:</p><ul><li>Residual Connection (Add): Adds the original input to the output of the attention or feed-forward layer, helping information flow through the network.</li><li>Layer Normalization (Norm): Normalizes activations to make training more stable.</li></ul><h4><strong>3. Feed-Forward Neural Network (FFN)</strong></h4><p>After attention processing, each position passes through a fully connected neural network.</p><p>It transforms the information and helps the model learn more complex patterns and relationships.</p><h4><strong>4. Final Encoder Output</strong></h4><p>The encoder produces contextual representations that capture information about the input sequence.</p><h3>D. Decoder</h3><p>The Decoder uses the encoder’s output (in the original encoder-decoder architecture) and previously generated tokens to produce the output sequence.</p><p>Each decoder layer contains:</p><ol><li>Masked Multi-Head Self-Attention: Prevents the model from looking at future tokens during generation.</li><li>Encoder-Decoder Cross-Attention: Allows the decoder to focus on relevant information from the encoder’s output.</li><li>Add &amp; Norm: Uses residual connections and layer normalization.</li><li>Feed-Forward Network: Processes the attended information and improves feature representations.</li></ol><p>Finally, the output layer and Softmax function generate probabilities for the next token.</p><p>The decoder selects the next token and continues generating until the output sequence is complete.</p><h4>How Transformers Work</h4><ol><li>Input text is converted into embeddings.</li><li>Positional Encoding adds word-order information.</li><li>The Encoder processes the sequence using self-attention and feed-forward networks.</li><li>The Decoder uses masked self-attention and cross-attention to generate output tokens.</li><li>The final output layer predicts the next token.</li></ol><h4>Advantages of Transformers</h4><ul><li>Parallel Processing: Processes input tokens simultaneously during training.</li><li>Long-Range Dependencies: Captures relationships between distant words effectively.</li><li>Better Context Understanding: Understands the meaning of words based on their surrounding context.</li><li>Scalability: Supports training on large datasets and powerful computing systems.</li><li>Foundation for Modern AI: Powers advanced language models and NLP applications.</li></ul><h4>Real-World Applications:</h4><ul><li>RNNs: Basic language modeling and sequence prediction.</li><li>LSTMs: Text generation, speech recognition, and sentiment analysis.</li><li>GRUs: Language modeling and time-series prediction.</li><li>Transformers: Chatbots, machine translation, text summarization, question answering, and generative AI.</li></ul><p>Popular Transformer-based models include BERT, GPT, T5, and other modern language models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d78eb117e7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activation Functions in ANN]]></title>
            <link>https://medium.com/@manojkumar8106875781/activation-functions-in-ann-4b147a2fa4de?source=rss-d935260857ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b147a2fa4de</guid>
            <dc:creator><![CDATA[Manojkumar]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 08:07:41 GMT</pubDate>
            <atom:updated>2026-10-13T08:07:41.274Z</atom:updated>
            <content:encoded><![CDATA[<h3>1.Introduction to Activation Functions</h3><p><strong>1.1) what is an Activation Function:</strong></p><p>An activation function is a mathematical function applied to a neuron’s weighted sum to determine its output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*AhZzxcCq9YrXusBWVzYB_w.png" /></figure><p>An activation function is a mathematical function that determines the output of a neuron after it calculates the weighted sum of its inputs.</p><p><strong>1.2) where is an activation function used in a neural networks:</strong></p><p>Activation functions are used after the weighted sum in neurons, typically in hidden layers and output layers.</p><ul><li>Hidden layers: Learn patterns and relationships in the data.</li><li>Output layer: Produces a result appropriate for the task, such as a probability, class distribution, or continuous value.</li></ul><p>The input layer generally receives the features; activation functions are applied in the neurons that process those inputs.</p><p><strong>1.3 What happens if we do not use an activation function?</strong></p><p>Without activation functions, a neural network made entirely of linear layers behaves like a single linear transformation.</p><p>Even if we stack 10 linear layers, the network cannot represent arbitrary non-linear relationships.</p><p>For example, it may struggle to model patterns such as curved decision boundaries or complex image features. This limits its ability to solve many real-world problems.</p><p><strong>1.4 Why can’t a neural network simply use the weighted sum as its output?</strong></p><p>A weighted sum is a linear or affine calculation:</p><p>z = wx+b</p><p>It can model simple relationships, but many real-world problems are non-linear.</p><p>For example, a model identifying whether an image contains a cat must learn combinations of edges, shapes, ears, eyes, and other visual patterns. Using activation functions allows successive layers to combine these features into more complex representations.</p><p><strong>1.5 What is non-linearity, and why is it essential?</strong></p><p>Non-linearity means that a relationship cannot be fully represented by a single straight-line transformation.</p><p>A single linear classifier cannot correctly separate all these cases. A neural network with hidden layers and non-linear activation functions can learn this pattern.</p><p><strong>1.6 How do activation functions help neural networks learn complex patterns?</strong></p><p>Activation functions transform neuron outputs in different ways. These transformed outputs become inputs to the next layer.</p><p>For example:</p><ol><li>The first hidden layer may detect simple image edges.</li><li>The next layer may combine edges into shapes.</li><li>Deeper layers may combine shapes into meaningful objects.</li></ol><p>Without non-linear activations, stacking linear layers would not create this additional expressive power.</p><h3>2. Mathematical Foundation</h3><p><strong>2.1 How does an individual neuron calculate its output?</strong></p><p>A neuron performs two main operations:</p><p>Step 1: Calculate the weighted sum</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*-Am6LUDVdzk8NL3GWsEIQQ.png" /></figure><p>Step 2: Apply the activation function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*I3akinPirIGutNhppXcv1A.png" /></figure><p>The weights control the contribution of each input, and the bias shifts the weighted sum.</p><p><strong>2.2 What does each term represent?</strong></p><ul><li>(x_i): Input feature, such as age, height, or a pixel value.</li><li>(w_i): Weight indicating the influence of an input.</li><li>(b): Bias that shifts the neuron’s response.</li><li>(z): Pre-activation value, calculated before applying the activation function.</li><li>(f): Activation function, such as ReLU or Sigmoid.</li><li>(a): Activation value, which is passed to the next layer or output.</li></ul><p><strong>2.3 What does the weighted sum (z) mean?</strong></p><p>The weighted sum combines all input values according to their weights and adds the bias.</p><p>Suppose:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*KZnSyxCtBYNYIfcndv9o7w.png" /></figure><p>then:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*puDzgOqWp-puv8UTgtt8nQ.png" /></figure><p>The value (5) is the pre-activation output. It has not yet been transformed by the activation function.</p><p><strong>2.4 What does activation (a) mean?</strong></p><p>Activation (a) is the result obtained after applying the activation function to (z).</p><p>Using the previous example with ReLU:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*MHd1ux95PVNVVecOrsJo2Q.png" /></figure><p>If (z=-3), ReLU gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*nQtMahEYzP0gkeTNWfv8JQ.png" /></figure><p>Therefore, the activation function controls how the weighted sum becomes the neuron’s output.</p><p><strong>2.5 Why is the activation function applied after calculating (z)?</strong></p><p>The neuron must first combine the inputs into a single pre-activation value. The activation function then transforms that value according to the required behavior.</p><p>For example, ReLU determines whether the weighted sum is positive or negative. Sigmoid converts it into a value between zero and one.</p><p>This separation makes the neuron’s calculation easy to understand and implement.</p><p><strong>2.6 Why do stacked linear transformations remain linear?</strong></p><p>Suppose the first layer calculates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/157/1*y1bfatXyqTU2m9HTHu5aJA.png" /></figure><p>The second layer calculates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/167/1*XE3kp7eIdNrmcojr7WvvMA.png" /></figure><p>Substitute (h):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*fnRUqNJfpqxqz7ilCX788g.png" /></figure><p>The result is still an affine transformation of (x). More generally, composing affine layers produces another affine transformation. A non-linear activation between layers allows the overall network to learn non-linear mappings.</p><h3>3. Important Activation Functions</h3><h4><strong>3.1 Sigmoid Activation Function</strong></h4><p><strong>A. What is Sigmoid?</strong></p><p>Sigmoid is an activation function that converts any real-valued input into a value strictly between 0 and 1. It is especially useful for binary classification output layers.</p><p><strong>B. Mathematical definition</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*OvCZJzmE4MomhBKCxqmH3A.png" /></figure><p>Here, (x) is the input and (e) is Euler’s mathematical constant.</p><p><strong>C. How does Sigmoid behave?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*ohvZpeFka-glXgRKWR4owg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*cpk4cioZC43gavWzE_HZMw.png" /></figure><ul><li>When (x=0), the output is (0.5).</li><li>When (x) is very positive, the output approaches (1).</li><li>When (x) is very negative, the output approaches (0).</li></ul><p><strong>D. What is its output range?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*mj_Zn-FJDji-gF_RFrdL4A.png" /></figure><p>The derivative is largest at (x=0), where it equals (0.25). At extreme positive or negative inputs, it approaches zero.</p><p><strong>F. Why is Sigmoid useful?</strong></p><p>Sigmoid produces a number that can represent the estimated probability of a positive class.</p><p>For example, in an email spam classifier:</p><ul><li>Output 0.90: estimated 90% probability of spam.</li><li>Output 0.15: estimated 15% probability of spam.</li></ul><p>A threshold such as 0.5 can be used to classify the result, although the best threshold depends on the application.</p><p><strong>G. Advantages of Sigmoid</strong></p><ol><li>Produces bounded outputs between zero and one.</li><li>Has a smooth and differentiable curve.</li><li>Is useful for binary classification probabilities.</li><li>Is compatible with binary cross-entropy loss.</li></ol><p><strong>H. Limitations of Sigmoid</strong></p><ul><li>It can suffer from vanishing gradients.</li><li>Its outputs are not zero-centered.</li><li>Its exponential calculation is more expensive than ReLU.</li><li>It is generally less effective than ReLU in many deep hidden layers.</li></ul><p><strong>I. Where is Sigmoid commonly used?</strong></p><ul><li>Binary classification output layers.</li><li>Multi-label classification, where each class has an independent probability.</li><li>Gating mechanisms in certain neural architectures.</li></ul><h4>3.2 Tanh Activation Function</h4><p><strong>A. What is Tanh?</strong></p><p>Tanh, or hyperbolic tangent, is an activation function that maps real-valued inputs into the range from −1 to 1.</p><p><strong>B. Mathematical definition</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*2O9mjxMUTh4qLqX62hHKMg.png" /></figure><p><strong>C. How does Tanh behave?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*G3b0cggActAD3PQ-7WpfRg.png" /></figure><ul><li>Positive inputs approach (1).</li><li>Negative inputs approach (-1).</li><li>At (x=0), the output is (0).</li></ul><p><strong>D. What is its output range?</strong></p><p>-1&lt;tanh(x)&lt;1</p><p>Unlike Sigmoid, Tanh allows both positive and negative outputs.</p><p><strong>E. What is the derivative of Tanh?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*mYUIIgXIiSBGuS3jLlcDOg.png" /></figure><p>The derivative is largest at zero, where it equals \(1\). It approaches zero when the output saturates near −1 or 1.</p><p><strong>F. Why is Tanh zero-centered?</strong></p><p>Tanh is an odd function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*3u8pTHzfWG0b64O9jWm44Q.png" /></figure><p>Its graph is symmetric around the origin. This means its output can be negative, zero, or positive, which can be beneficial for learning.</p><p><strong>G. Advantages of Tanh</strong></p><ul><li>Produces zero-centered outputs.</li><li>Represents positive and negative values.</li><li>Has a smooth curve.</li><li>Can be useful in certain recurrent neural network components.</li></ul><p><strong>H. Limitations of Tanh</strong></p><ul><li>Saturates for large positive and negative inputs.</li><li>Saturation causes small gradients.</li><li>Can suffer from vanishing gradients in deep networks.</li><li>Usually requires more computation than ReLU.</li></ul><p><strong>I. Where is Tanh commonly used?</strong></p><p>Tanh has been used in hidden states and candidate-state calculations in recurrent neural networks, including LSTM and GRU architectures. It can also be used in hidden layers when bounded, zero-centered outputs are desirable.</p><h4>3.3 ReLU Activation Function</h4><p><strong>A. What is ReLU?</strong></p><p>ReLU stands for Rectified Linear Unit. It returns zero for negative inputs and returns the input unchanged for positive inputs.</p><p><strong>B. Mathematical definition</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*niKK0LQdrmjFYjNg1ETsGw.png" /></figure><p>Equivalently:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*_bDlcWybFqYaBu6lT9HjHA.png" /></figure><p><strong>C. How does ReLU behave?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*QfSO4IxwUN80Ki6ZzM2ivw.png" /></figure><p><strong>D. What is its output range?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/1*w8vH7xziHeDKosuHEEHcuQ.png" /></figure><p>ReLU can produce zero or any positive value.</p><p><strong>E. What is the derivative of ReLU?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*BFLNg9JM-V0SWNof3D4NZQ.png" /></figure><p>The derivative is undefined in the classical sense at zero; common implementations choose a derivative convention there, usually zero.</p><p><strong>F. Why did ReLU become widely used?</strong></p><p>ReLU is simple to compute and does not saturate on the positive side. For positive inputs, its derivative is one, which helps gradients pass through hidden layers without shrinking due to the activation derivative itself.</p><p>ReLU also produces zero outputs for negative inputs, creating sparse activations that can be useful in practice.</p><p><strong>G. Advantages of ReLU</strong></p><ul><li>Simple and computationally efficient.</li><li>Introduces non-linearity.</li><li>Does not saturate for positive inputs.</li><li>Often works well in deep neural networks.</li><li>Frequently trains faster than traditional Sigmoid-based hidden layers.</li></ul><p><strong>H. Limitations of ReLU</strong></p><ul><li>Negative inputs have zero gradients.</li><li>Neurons can become permanently inactive.</li><li>Outputs are not zero-centered.</li><li>It is not generally suitable as the output activation for probability prediction.</li></ul><p><strong>I. Where is ReLU commonly used?</strong></p><ul><li>Hidden layers of feedforward neural networks.</li><li>Convolutional neural networks.</li><li>Many image classification architectures.</li><li>General-purpose deep learning models.</li></ul><h4>3.4 Leaky ReLU Activation Function</h4><p><strong>A. What is Leaky ReLU?</strong></p><p>Leaky ReLU is a variation of ReLU that allows a small negative output when the input is negative. This helps prevent the zero-gradient behavior of ordinary ReLU on its negative side.</p><p><strong>B. Mathematical definition</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*uwVVfIW93Kv8BO2KaHTo5A.png" /></figure><p>Here, (alpha) is a small positive constant, often chosen as (0.01).</p><p><strong>C. How does Leaky ReLU behave?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*bZlIu79qHwHMpnSsaYRAfg.png" /></figure><p><strong>D. What is its output range?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/117/1*4aBhFMA8Ua3M219kJP6c_A.png" /></figure><p>It can produce both negative and positive values.</p><p><strong>E. What is the derivative of Leaky ReLU?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*pgXcjVXtBrYUIJ1O_LDMvw.png" /></figure><p>At zero, the two slopes differ when alpha not equals to 1, so the classical derivative is undefined there.</p><p><strong>F. How does Leaky ReLU solve a limitation of ReLU?</strong></p><p>For negative inputs, ReLU has a derivative of zero. Consequently, a neuron may stop learning if it consistently receives negative pre-activation values.</p><p>Leaky ReLU has a small positive derivative \(\alpha\) on the negative side. Therefore, gradients can still flow and help update the weights.</p><p><strong>G. Advantages of Leaky ReLU</strong></p><ul><li>Reduces the risk of dying neurons.</li><li>Allows gradients for negative inputs.</li><li>Retains ReLU’s simple computation.</li><li>Supports both negative and positive activations.</li></ul><p><strong>H. Limitations of Leaky ReLU</strong></p><ul><li>The negative slope must be chosen.</li><li>Its performance depends on the model and dataset.</li><li>It does not guarantee that every neuron will remain active.</li></ul><p><strong>I. Where is Leaky ReLU commonly used?</strong></p><p>It can be used in hidden layers of feedforward networks and convolutional networks when ordinary ReLU causes too many inactive neurons.</p><h4>3.5 Softmax Activation Function</h4><p><strong>A. What is Softmax?</strong></p><p>Softmax transforms a vector of raw model scores into a probability distribution across multiple classes.</p><p>It is different from the other functions in this assignment because it operates on a vector of logits rather than independently transforming one scalar input.</p><p><strong>B. Mathematical definition</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*QtF-e1aRAo5x9Z8hHspCfw.png" /></figure><p><strong>C. What are logits?</strong></p><p>Logits are the raw scores produced by a neural network’s output layer before converting them into probabilities.</p><p>For example, a three-class classifier may produce logits:</p><p>[ z=[2,1,0] ]</p><p>These are scores, not probabilities. They can be negative, positive, or larger than one.</p><p><strong>D. Why is exponentiation used?</strong></p><p>Exponentiation converts each finite logit into a positive value. Larger logits produce larger exponentials, giving their corresponding classes higher relative probabilities.</p><p>For numerical stability, implementations often subtract the largest logit before exponentiating. This does not change the resulting probabilities.</p><p><strong>E. Why do Softmax outputs sum to one?</strong></p><p>Each probability is divided by the sum of all exponentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*SUSANBA7jPCR1nh0MyK-VQ.png" /></figure><p>This creates a normalized probability distribution.</p><p><strong>F. What is the derivative of Softmax?</strong></p><p>The derivative is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/1*O-cO0FpH013wVZAGy0ZLUA.png" /></figure><p><strong>G. Advantages of Softmax</strong></p><ul><li>Converts logits into normalized probabilities.</li><li>Supports multi-class classification.</li><li>Makes it easy to select the class with the highest probability.</li><li>Works naturally with categorical cross-entropy loss</li></ul><p><strong>H. Limitations of Softmax</strong></p><ul><li>The probabilities depend on all class scores.</li><li>It is inappropriate when multiple labels can independently be true.</li><li>Predicted probabilities may be poorly calibrated.</li><li>It can saturate when one class dominates the others.</li></ul><h4>4. The Vanishing Gradient Problem</h4><p><strong>4.1 What is a gradient?</strong></p><p>A gradient measures how a quantity, such as the loss, changes with respect to model parameters.</p><p>For a weight (w):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/50/1*8vhwcqa3-NE8UlfB9kxoAw.png" /></figure><p>This derivative tells us how sensitive the loss (L) is to changes in the weight (w).</p><p><strong>4.2 Why are gradients required during training?</strong></p><p>Gradients help an optimizer determine how to change weights to reduce the loss.</p><p>A basic gradient-descent update is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*cAtOm7RPqhgvvoYc5TuKMA.png" /></figure><p>Here, (eta) is the learning rate.</p><p>If the gradient is informative, the optimizer can adjust the weight in a direction that reduces the loss.</p><p><strong>4.3 How are gradients propagated backward?</strong></p><p>During the forward pass, the network produces a prediction and calculates the loss. During backpropagation, the chain rule is used to calculate gradients from the output layer back through the hidden layers.</p><p>The gradient at each layer depends on gradients from later layers, the layer’s weights, and its activation derivatives.</p><p><strong>4.4 Why can Sigmoid and Tanh produce very small gradients?</strong></p><p>Their derivatives become small when their outputs approach their extreme values.</p><p>For Sigmoid:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*YeY1FI6g0fM0_GMs6jf8DQ.png" /></figure><p>When (sigma(x)) is close to zero or one, the derivative approaches zero.</p><p>For Tanh:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*c4gJCClAIJhdEncAiXlBUQ.png" /></figure><p>When (tanh(x)) approaches −1 or 1, the derivative approaches zero.</p><p><strong>4.5 How does multiplying small gradients cause the problem?</strong></p><p>In a deep network, backpropagation repeatedly multiplies gradients through successive layers.</p><p>For a simplified example, if each layer contributes a factor of (0.1), then after five such layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/1*OrTBR8SK5nO2ulZd4Xb1EA.png" /></figure><p>The gradient becomes extremely small. This is an illustrative example; actual gradients also depend on weights and other factors.</p><p><strong>4.6 How does it affect earlier layers?</strong></p><p>When gradients become extremely small, the weights in earlier layers receive very small updates. These layers may learn slowly or fail to learn useful features within the available training time.</p><p><strong>4.7 Why can ReLU help?</strong></p><p>For positive inputs, ReLU’s derivative is one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*z--ldGLXjaejQRCJvP4fRw.png" /></figure><p>This avoids the small activation derivative that Sigmoid and Tanh produce in saturated regions.</p><p>However, ReLU has zero derivative for negative inputs, so it can cause dying neurons. ReLU reduces some vanishing-gradient problems but does not eliminate all causes of them.</p><p><strong>4.8 What are the solutions to vanishing gradients?</strong></p><ul><li>Use ReLU or appropriate activation variants.</li><li>Use suitable weight initialization, such as He initialization for ReLU networks.</li><li>Use batch normalization or other appropriate normalization techniques.</li><li>Use residual connections in deep architectures.</li><li>Consider gated architectures for sequential data where appropriate.</li></ul><p>These methods address different causes of optimization difficulty and may be combined.</p><h4><strong>5. The Dying ReLU Problem</strong></h4><p><strong>5.1 What is a dead neuron?</strong></p><p>A dead neuron is a ReLU neuron that consistently produces zero output for the inputs it receives.</p><p>ReLU is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*YpaU19pNWIWgWK1hCr9D8A.png" /></figure><p>If a neuron’s pre-activation value is always negative, its output is always zero.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*X0gHNtsoTUBZ74Yfl0RIJQ.png" /></figure><p><strong>5.2 How can a ReLU neuron become inactive?</strong></p><p>During training, weights and biases are updated. Sometimes these updates cause the neuron’s pre-activation values to become negative for most or all training examples.</p><p>If the neuron continues receiving negative pre-activation values, it keeps producing zero.</p><p><strong>5.3 Why does a neuron that consistently produces zero stop learning?</strong></p><p>For negative inputs, the ReLU derivative is zero:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/207/1*cJWLnWF9zH4YaTDyAHSJBg.png" /></figure><p>Consequently, the gradient passing through that activation is zero. Under ordinary gradient-based training, the neuron may receive no useful gradient to update its own weights and bias.</p><p>A neuron is not necessarily permanently dead merely because it produces zero for one example; the issue occurs when it remains inactive across the relevant inputs.</p><p><strong>5.4 What happens to its gradient?</strong></p><p>The gradient is blocked at the ReLU activation for negative pre-activation values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*uR2jlhD6eRf56EoaaU1dTA.png" /></figure><p>This prevents the loss gradient from updating that neuron’s parameters through that path.</p><p><strong>5.5 How does Leaky ReLU help?</strong></p><p>Leaky ReLU uses a small positive slope for negative inputs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*6574mPibxRr7PdrCDWnWTQ.png" /></figure><p>For example, if (x=-5):</p><ul><li>ReLU output: (0)</li><li>Leaky ReLU output: (-0.05)</li></ul><p>Leaky ReLU also has a derivative of \(0.01\) for negative inputs. Therefore, it allows some gradient to flow and reduces the risk of dead neurons.</p><p>Key difference: ReLU blocks gradients on its negative side, whereas Leaky ReLU retains a small gradient.</p><h4>6. Activation Functions and Backpropagation</h4><p><strong>6.1 What is backpropagation?</strong></p><p>Backpropagation is the process used to calculate how each network parameter contributes to the prediction error.</p><p>It uses the chain rule to propagate gradients backward through the network.</p><p><strong>6.2 What is the role of activation functions during backpropagation?</strong></p><p>Activation functions influence the gradient through their derivatives.</p><p>For example:</p><ul><li>ReLU passes gradients through positive inputs.</li><li>ReLU blocks gradients through negative inputs.</li><li>Sigmoid may produce very small gradients for extreme inputs.</li><li>Tanh may also produce very small gradients near its saturation limits.</li><li>Leaky ReLU retains a small gradient for negative inputs.</li></ul><p>Thus, activation functions influence not only the predicted values but also how effectively the network learns.</p><p><strong>6.3 Explain the process: Loss → Gradient Calculation → Weight Updates</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*PdReZ0hRRVqS61qW81Td1w.png" /></figure><p><strong>Step 1: Forward pass</strong></p><p>The network receives input features and calculates predictions.</p><p><strong>Step 2: Loss calculation</strong></p><p>The loss function measures how different the prediction is from the target.</p><p>For example, cross-entropy is commonly used for classification.</p><p><strong>Step 3: Gradient calculation</strong></p><p>Backpropagation calculates derivatives of the loss with respect to the weights and biases. Activation derivatives are included through the chain rule.</p><p><strong>Step 4: Weight updates</strong></p><p>An optimizer such as SGD or Adam uses the gradients to update model parameters.</p><p><strong>6.4 Why is the activation derivative important?</strong></p><p>If the derivative is zero, the gradient through that path is zero. If it is extremely small, the update may be very small. If it remains informative, the optimizer can use that gradient to improve the model.</p><p>The choice of activation function therefore affects gradient flow, training stability, and the network’s ability to learn</p><h4>7. Choosing the Right Activation Function</h4><p><strong>7.1 Why should activation functions be selected according to the task?</strong></p><p>Different tasks require different output behavior.</p><ul><li>Binary classification requires a probability-like output for one positive class.</li><li>Multi-class classification often requires probabilities across mutually exclusive classes.</li><li>Regression requires a numerical prediction that may be outside the range zero to one.</li><li>Hidden layers need activations that support effective feature learning.</li></ul><p>The activation function should match the mathematical requirements of the layer and task.</p><p><strong>7.2 Why is ReLU commonly used in hidden layers?</strong></p><p>ReLU is simple, efficient, and has a derivative of one for positive inputs. It therefore works well as a general-purpose hidden-layer activation in many neural networks.</p><p>Its limitation is that neurons receiving negative pre-activation values have zero gradients.</p><p><strong>7.3 Why is Sigmoid used for binary classification?</strong></p><p>Sigmoid produces an output between zero and one, which can represent the model’s estimated probability of the positive class.</p><p>For example, a disease-screening classifier might output 0.85 as its estimated probability for the positive class. This is a hypothetical model output, not a calibrated guarantee.</p><p><strong>7.4 Why is Softmax used for multi-class classification?</strong></p><p>Softmax converts multiple logits into probabilities that sum to one. This is appropriate when the model must select among mutually exclusive classes, such as cat, dog, or bird.</p><p>If several labels can be true simultaneously, independent Sigmoid outputs are generally more appropriate.</p><p><strong>7.5 Why is linear activation used for regression?</strong></p><p>A linear output activation is:</p><p>[ f(x)=x ]</p><p>It allows the model to produce unrestricted real-valued outputs.</p><p>For example, a house-price prediction model may output ₹45,00,000 rather than being restricted to a value between zero and one.</p><p>For targets that must remain positive or within another specific range, a different output transformation may be more suitable.</p><p><strong>7.6 Must the same activation function be used in every layer?</strong></p><p>No. Different layers may use different activation functions.</p><p>For example, a multi-class image classifier may use:</p><ul><li>ReLU in hidden layers.</li><li>Softmax in the output layer.</li></ul><p>The hidden layers learn useful representations, while the output layer converts the final scores into the desired output format.</p><p><strong>7.7 Activation function selection table</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*y_CTu2WhasDOFy2YoIKCFA.png" /></figure><p>These are common choices, not absolute rules. The appropriate choice depends on the architecture, dataset, target, and loss function.</p><h4>8. Activation Function Comparison</h4><p>This section brings together the properties discussed in the earlier sections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*XKEPXs_LURf72_TAkmT45A.png" /></figure><h4>9. Conclusion</h4><p>Activation functions are essential components of neural networks because they enable non-linear learning. Without them, stacking linear transformations would still result in a linear or affine mapping, limiting the patterns a network could learn.</p><p>Each activation function serves a different purpose:</p><ul><li>Sigmoid produces values between zero and one, making it useful for binary classification outputs.</li><li>Tanh produces zero-centered outputs between −1 and one.</li><li>ReLU is efficient and widely used in hidden layers because it avoids saturation for positive inputs.</li><li>Leaky ReLU allows a small gradient for negative inputs, reducing the risk of dying neurons.</li><li>Softmax converts multiple logits into a normalized probability distribution for mutually exclusive classes.</li></ul><p>Activation functions also affect backpropagation because their derivatives influence gradient flow. The correct choice depends on the network architecture, the learning problem, and the required output.</p><p>The practical experiment demonstrates that activation functions behave differently for positive and negative inputs, have different output ranges, and create different gradient characteristics. Understanding these differences helps in designing neural networks that train effectively.</p><h4>Bonus: Modern Activation Function — GELU</h4><p><strong>B.1 What is GELU?</strong></p><p>GELU stands for Gaussian Error Linear Unit. It is a smooth activation function commonly used in Transformer-based neural network architectures.</p><p><strong>B.2 Mathematical formulation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*LL3xK3EiEwfPe1X8XNBU0A.png" /></figure><p>An approximation commonly used in implementations is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*nSoWLm_RqXUQaMDz8WxTTg.png" /></figure><p><strong>B.3 Why was GELU developed?</strong></p><p>ReLU uses a hard threshold: negative inputs become zero, while positive inputs remain unchanged. GELU instead applies a smooth, input-dependent scaling to the input.</p><p>This provides a different way to control information passing through a neuron.</p><p><strong>B.4 How does GELU differ from ReLU?</strong></p><p>GELU</p><p>Smooth transition with small negative outputs for some negative inputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*rpe-2KcBlkMlHbzQa3Uy7g.png" /></figure><p>ReLU</p><p>Hard threshold at zero, with no negative output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*f0d3JpQrv5vLWqM-0ncV1g.png" /></figure><p><strong>B.5 Advantages of GELU</strong></p><ul><li>Smooth activation behavior.</li><li>Can retain useful negative values.</li><li>Works well in many Transformer architectures.</li><li>Provides an alternative to the hard threshold of ReLU.</li></ul><p><strong>B.6 Limitations of GELU</strong></p><ul><li>More computationally expensive than ReLU.</li><li>Does not guarantee better performance on every dataset.</li><li>May be unnecessary for simpler neural networks.</li></ul><p><strong>B.7 Where is GELU commonly used?</strong></p><p>GELU is commonly used in Transformer architectures, including BERT-style models, particularly in their feedforward blocks.</p><p><strong>B.8 Why choose GELU over ReLU?</strong></p><p>GELU may be a good choice when following a Transformer architecture or when its smooth gating behavior works better empirically. ReLU remains an efficient default for many conventional feedforward and convolutional networks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b147a2fa4de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner-Friendly Guide to One of Machine Learning’s Simplest Yet Powerful Algorithm: K-Nearest…]]></title>
            <link>https://medium.com/@manojkumar8106875781/a-beginner-friendly-guide-to-one-of-machine-learnings-simplest-yet-powerful-algorithm-k-nearest-281e300f96b1?source=rss-d935260857ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/281e300f96b1</guid>
            <category><![CDATA[ml-knn-algorithm]]></category>
            <dc:creator><![CDATA[Manojkumar]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 19:47:25 GMT</pubDate>
            <atom:updated>2026-08-05T19:47:25.892Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Beginner-Friendly Guide to One of Machine Learning’s Simplest Yet Powerful Algorithm: K-Nearest Neighbors (KNN)</h3><p>“Sometimes the best way to predict the future is by looking at your closest neighbors.”</p><p>Machine Learning is transforming industries by enabling computers to recognize patterns and make intelligent decisions. While many algorithms rely on complex mathematical models, one algorithm stands out because of its simplicity and effectiveness — the <strong>K-Nearest Neighbors (KNN)</strong> algorithm.</p><p>Whether you’re recommending movies, detecting fraudulent transactions, or classifying handwritten digits, KNN provides a straightforward yet reliable approach for solving both classification and regression problems.</p><p>In this article, we’ll explore how KNN works, why similarity matters, where it’s used in the real world, and when it may or may not be the right choice.</p><p>## knn is also know as imputer means which is used to calculate the missing values in the data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*7fRCE2fWtYP8DOwA0vxiwg.jpeg" /></figure><h4>What is K-Nearest Neighbors (KNN)?</h4><p>K-Nearest Neighbors (KNN) is a <strong>supervised machine learning algorithm</strong> that predicts the output for a new data point by analyzing the outcomes of its closest neighboring data points.</p><p>Unlike algorithms that build a mathematical model during training, KNN simply stores the training dataset. When a new observation arrives, it searches for the nearest neighbors and makes predictions based on them.</p><p>Because of this behavior, KNN is known as a <strong>lazy learning</strong> or <strong>instance-based learning</strong> algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*sTDGMx3qWBnpllm5XZf3Jg.png" /></figure><p>It can be used for:</p><ul><li><strong>Classification</strong> — Predicting categories (Spam or Not Spam, Healthy or Diseased)</li><li><strong>Regression</strong> — Predicting continuous values (House Prices, Temperature, Sales)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*8bwdiC-tvuryyumHkxgW6g.png" /></figure><h3>The Core Idea: Similar Things Tend to Stay Together</h3><p>Imagine you’ve just moved to a new city and want to know whether a neighborhood is safe.</p><p>Instead of studying every street in the city, you ask people living nearby. If most neighbors describe the area as safe, you’ll probably reach the same conclusion.</p><p>This is exactly how KNN works.</p><p>When a new data point appears:</p><ol><li>Measure its distance from every training example.</li><li>Find the <strong>K closest neighbors</strong>.</li><li>Let those neighbors decide the prediction.</li></ol><p>The assumption behind KNN is simple:</p><blockquote><strong><em>Objects that are close to each other are more likely to have similar characteristics.</em></strong></blockquote><h3>Understanding Similarity Through Distance:</h3><p>To determine which data points are “neighbors,” KNN calculates the distance between observations.</p><p>Several distance metrics can be used depending on the type of data.</p><h4>1. Euclidean Distance</h4><p>This is the most common distance metric.</p><p>It measures the straight-line distance between two points.</p><p>Formula:</p><p>d=(x2​−x1​)2+(y2​−y1​)2​</p><p>Ideal for continuous numerical data.</p><h4>2. Manhattan Distance</h4><p>Instead of moving diagonally, Manhattan Distance measures movement along horizontal and vertical paths — similar to navigating city streets.</p><p>Formula:</p><p>d=∣x2​−x1​∣+∣y2​−y1​∣</p><p>Useful when movement follows grid-like paths.</p><h4>3. Minkowski Distance</h4><p>A generalized distance metric that includes both Euclidean and Manhattan distances as special cases.</p><p>It offers flexibility depending on the value of <strong>p</strong>.</p><h4>4. Hamming Distance</h4><p>Designed for categorical or binary data.</p><p>Instead of measuring physical distance, it counts how many values differ.</p><p>Different positions = Hamming Distance.</p><h3>How Does KNN Actually Work?</h3><p>Let’s break the algorithm into simple steps.</p><h4>Step 1: Store the Training Data</h4><p>KNN doesn’t create a mathematical model.</p><p>It simply remembers every training example.</p><h4>Step 2: Choose the Value of K</h4><p>The value of <strong>K</strong> represents the number of neighbors considered.</p><p>Example:</p><ul><li>K = 1 → Only the closest neighbor votes.</li><li>K = 3 → Three closest neighbors vote.</li><li>K = 5 → Five closest neighbors vote.</li></ul><p>Choosing the right K is critical.</p><h4>Step 3: Calculate Distance</h4><p>For every new observation, calculate the distance from every training sample.</p><h4>Step 4: Find the K Closest Neighbors</h4><p>Sort all distances from smallest to largest.</p><p>Select the first <strong>K</strong> observations.</p><h4>Step 5: Make the Prediction</h4><p>The prediction depends on the problem type.</p><h4><strong>Classification</strong></h4><p>Use <strong>majority voting</strong>.</p><h4>Regression</h4><p>Instead of voting, calculate the average value.</p><h3>Choosing the Right Value of K</h3><p>The performance of KNN heavily depends on selecting an appropriate value for <strong>K</strong>.</p><p><strong>when small k value is taken</strong></p><p>Advantages:</p><ul><li>Captures local patterns</li><li>Sensitive to fine details</li></ul><p>Disadvantages:</p><ul><li>Sensitive to noise</li><li>Can overfit the data</li></ul><p><strong>when large k value is taken</strong></p><p>Advantages:</p><ul><li>More stable predictions</li><li>Less affected by noisy observations</li></ul><p>Disadvantages:</p><ul><li>May ignore important local patterns</li><li>Can underfit</li></ul><p>A common approach is to test multiple values using <strong>cross-validation</strong> and choose the one that produces the best validation performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*UMJbmrLLyxc8PoLBIiDIgw.png" /></figure><h3>Advantages of KNN</h3><p>KNN offers several benefits, especially for beginners and smaller datasets.</p><p>✅ Easy to understand and implement</p><p>✅ No training phase required</p><p>✅ Works for both classification and regression</p><p>✅ Naturally handles multi-class classification</p><p>✅ Flexible with different distance metrics</p><p>✅ Can model complex decision boundaries</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*fo4yZf4PSaGU3tWSZ4QxeQ.png" /></figure><h3>Limitations of KNN</h3><p>Despite its simplicity, KNN has several challenges.</p><h4>High Prediction Time</h4><p>Since every new prediction compares against the entire dataset, prediction becomes slower as data grows.</p><h4>Memory Intensive</h4><p>The algorithm stores all training examples.</p><p>Large datasets require significant memory.</p><h4>Sensitive to Irrelevant Features</h4><p>Unimportant variables can distort distance calculations.</p><p>Feature selection improves performance.</p><h4>Requires Feature Scaling</h4><p>Different feature scales lead to inaccurate neighbor selection.</p><h4>Sensitive to Outliers</h4><p>Extreme values may become nearest neighbors and negatively affect predictions.</p><h3>Real-World Applications of KNN</h3><p>KNN is widely used across many industries.</p><h4>Recommendation Systems</h4><p>Streaming platforms recommend movies based on users with similar preferences.</p><h4>Medical Diagnosis</h4><p>Doctors classify diseases by comparing patient records with similar historical cases.</p><h4>Credit Risk Analysis</h4><p>Banks assess loan applicants by comparing them with previous borrowers.</p><h4>Fraud Detection</h4><p>Financial institutions identify suspicious transactions based on similar fraudulent patterns.</p><h4>Image Recognition</h4><p>KNN helps classify handwritten digits, faces, and objects by comparing image features.</p><h4>Customer Segmentation</h4><p>Businesses group customers with similar purchasing behavior to deliver personalized marketing campaigns.</p><p>Financial institutions identify suspicious transactions based on similar fraudulent patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*1dUmAi5MN_T7DYJVnjnOrQ.jpeg" /></figure><h3>Conclusion:</h3><p>K-Nearest Neighbors proves that effective machine learning doesn’t always require complicated mathematics or deep neural networks. By relying on the simple idea that <strong>similar data points are likely to share similar outcomes</strong>, KNN provides an intuitive solution for both classification and regression tasks.</p><p>Although it can become computationally expensive for large datasets and requires careful preprocessing, KNN remains an excellent algorithm for learning the fundamentals of machine learning and building reliable baseline models.</p><p>As you continue your machine learning journey, understanding KNN will strengthen your intuition about similarity, distance, and data-driven decision-making — concepts that are foundational to many advanced algorithms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=281e300f96b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to ML, Deep Learning, Generative AI, and the ML Lifecycle :]]></title>
            <link>https://medium.com/@manojkumar8106875781/a-beginners-guide-to-ml-deep-learning-generative-ai-and-the-ml-lifecycle-a35a93d125f8?source=rss-d935260857ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/a35a93d125f8</guid>
            <dc:creator><![CDATA[Manojkumar]]></dc:creator>
            <pubDate>Sun, 26 Jul 2026 07:42:51 GMT</pubDate>
            <atom:updated>2026-07-26T07:42:51.697Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence is transforming the world, and Machine Learning is one of the driving forces behind this revolution. Whether you’re unlocking your smartphone with Face ID, receiving Netflix recommendations, or chatting with AI assistants like ChatGPT, Machine Learning is quietly working behind the scenes.</p><p>__ In this article, we’ll explore what Machine Learning is, its different types, how Deep Learning and Generative AI fit into the AI ecosystem, and the complete Machine Learning lifecycle. By the end, you’ll have a solid foundation to start your AI journey.</p><h3><em>1. What is Machine Learning?</em></h3><p>Machine Learning (ML) is a branch of Artificial Intelligence (AI) that enables computers to learn from data without being explicitly programmed.Instead of following fixed instructions, ML systems identify patterns in historical data and use those patterns to make predictions or decisions when presented with new information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTuxPshZauTRCUhvHDZsfA.jpeg" /></figure><h3>Why is Machine Learning Important?</h3><p>Machine Learning is changing nearly every industry because it helps automate complex decision-making and uncover insights from large datasets.</p><h3>Benefits</h3><ol><li>Automates repetitive tasks</li><li>Improves decision-making</li><li>Learns from new data</li><li>Detects hidden patterns</li><li>Makes accurate predictions</li></ol><h3>Real-World Applications of Machine Learning :</h3><ol><li>Disease prediction</li><li>Fraud detection</li><li>Product recommendations</li><li>Personalized feeds</li><li>Stock price prediction</li><li>Traffic prediction</li></ol><h3>2. Types of machine learning :</h3><ol><li>Supervised Machine learning</li><li>Unsupervised Machine learning</li><li>Reinforcement Machine learning</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYCrxKiflRNAfyRUqi7xFQ.png" /></figure><h4>Supervised Machine learning :</h4><p>Supervised Learning trains a model using <strong>labeled data</strong>, where both the input and the correct output are already known. The model learns the relationship between inputs and outputs to make predictions on unseen data.</p><h4>Work flow :</h4><p>input data &gt; known labels &gt; Training &gt; model learns &gt; prediction</p><h4>Real-world Examples :</h4><ul><li>Spam email detection</li><li>House price prediction</li><li>Student result prediction</li><li>Credit risk assessment</li></ul><h4>Unsupervised Machine Learning :</h4><p>Unsupervised Learning works with <strong>unlabeled data</strong>.The algorithm identifies hidden structures, relationships, or clusters without knowing the correct answers..</p><h4>Workflow :</h4><p>Raw data &gt; Data recovery &gt; Grouping &gt; Clusters</p><h4>Real-World Examples :</h4><ul><li>Customer segmentation</li><li>Market basket analysis</li><li>Social network analysis</li><li>Fraud detection</li></ul><h4>Reinforcement Machine Learning:</h4><p>Reinforcement Learning allows an intelligent agent to learn through interaction with its environment. The agent receives rewards for correct actions and penalties for incorrect actions.</p><h4>Workflow :</h4><p>Agent &gt; Take Action &gt; Environment &gt; Reward / Penality &gt; Improve Strategy</p><h4>Real-world Examples :</h4><ul><li>Self-driving cars</li><li>Robotics</li><li>Chess-playing AI</li><li>Game-playing AI (AlphaGo)</li></ul><h3>3. What is deep learning :</h3><p>Deep Learning is a specialized subset of Machine Learning that uses <strong>Artificial Neural Networks</strong> with multiple hidden layers. Unlike traditional ML, Deep Learning automatically learns important features from raw data, reducing the need for manual feature engineering.</p><h4>Why is it a Subset of Machine Learning?</h4><p>Machine Learning includes many algorithms such as Decision Trees, Random Forests, and Support Vector Machines. Deep Learning belongs to this family but specifically relies on neural networks with many layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-Tzb4NydKLnHhjw-2uGUA.jpeg" /></figure><h4>Workflow :</h4><p>Artificial Intelligence &gt; Machine Learning &gt; Deep learning</p><h4>Real-world applications :</h4><ul><li>Face Recognition</li><li>Voice Assistants</li><li>Medical Imaging</li><li>Autonomous Vehicles</li><li>Language Translation</li></ul><h3>4. What is Generative AI :</h3><p>Generative AI is an advanced AI technology capable of creating entirely new content rather than simply analyzing existing information.</p><p>It can generate:</p><ul><li>Text</li><li>Images</li><li>Videos</li><li>Music</li><li>Computer Code</li><li>Audio</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*hUDXGCVZ-BVd7qeaFnpOSg.jpeg" /></figure><p>&gt;&gt; Popular Generative AI models include ChatGPT, Gemini, Claude..</p><h4>How is Generative AI Different from Traditional Machine Learning :</h4><p>Traditional Machine Learning focuses on:</p><ul><li>Classification</li><li>Prediction</li><li>Regression</li><li>Pattern recognition</li></ul><p>Generative AI focuses on:</p><ul><li>Content generation</li><li>Creativity</li><li>Human-like conversations</li><li>Image creation</li><li>Code generation</li></ul><h4>Real-World Applications of Generative AI :</h4><ul><li>AI Chatbots</li><li>Image Generation</li><li>Video Creation</li><li>Code Assistants</li><li>Virtual Tutors</li><li>Content Writing</li><li>Music Composition</li><li>Product Design</li></ul><h3>5. Difference Between Machine Learning, Deep Learning, and Generative AI :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aDFlBS1KgyehaY7L5CJNqQ.png" /></figure><h3>6. Machine Learning Lifecycle :</h3><p>The success of any Machine Learning project depends on following a structured workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*3ALZEsFleI9XFeWIKjR3pQ.jpeg" /></figure><p>Problem Definition<br> ↓<br>Data Collection<br> ↓<br>Data Preprocessing<br> ↓<br>Exploratory Data Analysis<br> ↓<br>Feature Engineering<br> ↓<br>Model Selection<br> ↓<br>Model Training<br> ↓<br>Model Evaluation<br> ↓<br>Hyperparameter Tuning<br> ↓<br>Model Deployment<br> ↓<br>Monitoring &amp; Maintenance</p><h4>1. Problem Definition :</h4><p>Clearly define the business problem and project objectives.</p><h4>2. Data Collection :</h4><p>Gather relevant data from databases, APIs, sensors, or other sources.</p><h4>3. Data Preprocessing :</h4><p>Clean the dataset by handling missing values, duplicates, outliers, and formatting inconsistencies.</p><h4>4. Exploratory Data Analysis (EDA) :</h4><p>Analyze the data using statistics and visualizations to identify trends and relationships.</p><h4>5. Feature Engineering :</h4><p>Create meaningful features that improve model performance.</p><h4>6. Model Selection :</h4><p>Choose an appropriate algorithm based on the problem and available data.</p><h4>7. Model Training :</h4><p>Train the selected model using the prepared dataset.</p><h4>8. Model Evaluation :</h4><p>Evaluate performance using suitable metrics such as Accuracy, Precision, Recall, F1-Score, or RMSE.</p><h4>9. Hyperparameter Tuning :</h4><p>Optimize model settings to improve predictive performance.</p><h4>10. Model Deployment :</h4><p>Deploy the trained model into production so real users can interact with it.</p><h4>11. Monitoring &amp; Maintenance :</h4><p>Continuously monitor the model, detect performance degradation, and retrain it as needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a35a93d125f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>