<?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 Afrin on Medium]]></title>
        <description><![CDATA[Stories by Afrin on Medium]]></description>
        <link>https://medium.com/@afrin_24?source=rss-4e08fe5ee8db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9KtTgpad1hS2dqe2</url>
            <title>Stories by Afrin on Medium</title>
            <link>https://medium.com/@afrin_24?source=rss-4e08fe5ee8db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:32:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@afrin_24/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[Artificial Neural Networks (ANN): From a Single Neuron to Deep Learning]]></title>
            <link>https://medium.com/@afrin_24/artificial-neural-networks-ann-from-a-single-neuron-to-deep-learning-02338e47793e?source=rss-4e08fe5ee8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/02338e47793e</guid>
            <dc:creator><![CDATA[Afrin]]></dc:creator>
            <pubDate>Fri, 25 Sep 2026 06:56:38 GMT</pubDate>
            <atom:updated>2026-09-25T06:56:38.980Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>A beginner-friendly journey through neurons, forward propagation, activation functions, backpropagation, optimization, regularization, and building an ANN from scratch</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QLmHAUSDM5KCfcdY6mXOEA.png" /></figure><h3>1. Introduction to Artificial Neural Networks</h3><p>Have you ever wondered how a machine learns to recognize whether an email is spam, predict house prices, or decide whether an image belongs to a particular category?</p><p>One of the fundamental ideas behind many of these systems is the <strong>Artificial Neural Network (ANN)</strong>.</p><p>An ANN is a machine-learning model inspired loosely by the way biological neurons process information. Instead of manually writing rules for every possible situation, we give the network examples and allow it to learn patterns from data.</p><p>A simple ANN can be represented as:</p><pre>Input Data<br>   ↓<br>Input Layer<br>   ↓<br>Hidden Layer(s)<br>   ↓<br>Output Layer<br>   ↓<br>Prediction</pre><p>For example, suppose we want to predict whether a student will pass based on:</p><ul><li>Study hours</li><li>Attendance</li><li>Previous marks</li></ul><p>The ANN receives these values as inputs and learns how they are related to the final result.</p><h4>Why do we need ANN?</h4><p>Traditional machine-learning algorithms can work extremely well for many structured datasets. However, as problems become more complex, we often need models that can automatically learn complicated relationships between inputs and outputs.</p><p>That’s where neural networks become useful.</p><h3>2. What Is a Neuron?</h3><p>Before understanding a neural network, we need to understand its smallest building block: the <strong>artificial neuron</strong>.</p><p>A neuron receives inputs, assigns importance to them using weights, adds a bias, and passes the result through an activation function.</p><p><strong>Step 1: Calculate the weighted sum</strong></p><p><strong>z = w₁x₁ + w₂x₂ + w₃x₃ + … + wₙxₙ + b</strong></p><p><strong>Step 2: Apply the activation function</strong></p><p><strong>y = f(z)</strong></p><p>Where:</p><ul><li><strong>x₁, x₂, …, xₙ</strong> → Inputs</li><li><strong>w₁, w₂, …, wₙ</strong> → Weights</li><li><strong>b</strong> → Bias</li><li><strong>f</strong> → Activation function</li><li><strong>y</strong> → Output</li></ul><h4>In simple words</h4><pre>Inputs<br>  ↓<br>Multiply by weights<br>  ↓<br>Add everything + bias<br>  ↓<br>Activation function<br>  ↓<br>Output</pre><h4>Simple visualization</h4><pre>x₁ ── w₁ ──┐<br>x₂ ── w₂ ──┤<br>x₃ ── w₃ ──┤──► Σ + b ──► Activation ──► Output<br>            │</pre><p>Think of weights as <strong>importance values</strong>.</p><p>If one input is more useful for making a prediction, the network can learn a larger or more appropriate weight for that input.</p><h3>3. Biological Neuron vs Artificial Neuron</h3><p>Artificial neurons are inspired by biological neurons, but they are <strong>not exact copies of the human brain</strong>.</p><p>A simplified comparison:</p><p>Biological neuronArtificial neuronDendrites receive signalsInputs receive valuesSynapses influence signalsWeights control importanceCell body processes signalsWeighted sum processes inputsAxon sends signalOutput sends result</p><p>The goal is not to perfectly reproduce the brain.</p><p>The goal is to create a computational model capable of learning patterns.</p><h3>4. Weights and Bias</h3><p>Two important components of a neuron are <strong>weights</strong> and <strong>bias</strong>.</p><h4>Weight</h4><p>A weight determines how strongly an input influences the output.</p><p>For example:</p><pre>Input          Weight<br>Study Hours ×   0.8<br>Attendance  ×   0.5<br>Marks       ×   0.3</pre><p>During training, the network adjusts these weights.</p><h4>Bias</h4><p>Bias gives the neuron additional flexibility.</p><p>The equation becomes:</p><p>z = Wx + b</p><p>Without bias, the neuron would have limitations in the functions it can represent.</p><h4>Easy analogy</h4><p>Think of <strong>weights as importance</strong> and <strong>bias as a starting adjustment</strong>.</p><h3>5. What Is an ANN?</h3><p>A collection of interconnected artificial neurons forms a neural network.</p><p>A basic ANN contains:</p><ol><li>Input layer</li><li>Hidden layer</li><li>Output layer</li></ol><pre>H₁<br>            /     \<br>X₁ ───────►/       \ <br>X₂ ───────►\  H₂   ───► Output<br>            \      /<br>X₃ ───────►  \    /<br>               H₃</pre><p>The connections between neurons contain learnable weights.</p><h3>6. Layers in an ANN</h3><h4>Input Layer</h4><p>The input layer receives the features.</p><p>For example:</p><pre>Age<br>Salary<br>Experience</pre><p>would give us three input neurons.</p><p>The input layer generally does not perform the main computation of the network.</p><h4>Hidden Layer</h4><p>Hidden layers perform transformations on the input.</p><p>A network can have:</p><pre>Input → Hidden → Output</pre><p>or:</p><pre>Input → Hidden → Hidden → Hidden → Output</pre><p>When a neural network has multiple hidden layers, we commonly refer to it as a <strong>deep neural network</strong>.</p><h4>Output Layer</h4><p>The output layer produces the final prediction.</p><p>For binary classification:</p><pre>0 → No<br>1 → Yes</pre><p>For multi-class classification:</p><pre>Class 1<br>Class 2<br>Class 3</pre><p>The output-layer activation depends on the problem.</p><h3>7. Forward Propagation</h3><p>Once the input enters the network, information moves from the input layer toward the output layer.</p><p>This is called <strong>forward propagation</strong>.</p><p>For a neuron:</p><p>z = Wx + b</p><p>Then:</p><p>a = f(z)</p><p>The activation becomes the input to the next layer.</p><h4>Flow</h4><pre>Input<br>  ↓<br>Weighted Sum<br>  ↓<br>Bias<br>  ↓<br>Activation Function<br>  ↓<br>Next Layer<br>  ↓<br>Prediction</pre><h4>For multiple layers</h4><p>The same process is repeated layer by layer.</p><p><strong>Layer 1:</strong></p><p><strong>a₁ = f(W₁x + b₁)</strong></p><p><strong>Layer 2:</strong></p><p><strong>a₂ = f(W₂a₁ + b₂)</strong></p><p>This continues until the final layer produces the prediction.</p><h3>8. Why Do We Need Activation Functions?</h3><p>Activation functions are one of the most important components of an Artificial Neural Network (ANN). They decide how strongly a neuron should respond to its input and, more importantly, introduce <strong>non-linearity</strong> into the network.</p><p>Before understanding why they are necessary, let’s first look at what happens when a neural network does <strong>not</strong> use an activation function.</p><h4>What Happens Without an Activation Function?</h4><p>A neuron first calculates a weighted sum of its inputs and adds a bias:</p><p><strong>z = Wx + b</strong></p><p>If we directly use this value as the output, the operation is simply a <strong>linear transformation</strong>:</p><p><strong>y = Wx + b</strong></p><p>A linear function can represent relationships such as a straight line.</p><p>For example, as the input increases, the output may increase at a constant rate.</p><h4>What if we add more layers?</h4><p>Consider a network with several layers:</p><p><strong>Layer 1:</strong></p><p><strong>z₁ = W₁x + b₁</strong></p><p><strong>Layer 2:</strong></p><p><strong>z₂ = W₂z₁ + b₂</strong></p><p>If there is no activation function between these layers, the transformations can be combined into another linear transformation.</p><p>In simple terms:</p><p><strong>Multiple linear layers → Still a linear transformation</strong></p><p>So, simply adding more layers would not give the network the ability to learn complex non-linear relationships.</p><p>This is a major limitation.</p><h4>The Role of an Activation Function</h4><p>An activation function is applied after the weighted sum:</p><p><strong>z = Wx + b</strong></p><p>Then:</p><p><strong>a = f(z)</strong></p><p>Here, <strong>f</strong> represents the activation function.</p><p>The activation function transforms the neuron’s output and introduces <strong>non-linearity</strong>.</p><p>This allows different layers of the neural network to learn increasingly complex patterns.</p><h4>Without activation</h4><pre>Input<br>   ↓<br>Weighted Sum<br>   ↓<br>Linear Output<br>   ↓<br>Next Layer</pre><h4>With activation</h4><pre>Input<br>   ↓<br>Weighted Sum<br>   ↓<br>Activation Function<br>   ↓<br>Non-Linear Output<br>   ↓<br>Next Layer</pre><h4>Why Is Non-Linearity So Important?</h4><p>Real-world problems are rarely perfectly linear.</p><p>For example, imagine trying to classify data where two classes form a curved pattern rather than being separated by a straight line.</p><p>A purely linear model would struggle to represent this relationship.</p><p>An activation function allows the neural network to create more flexible decision boundaries and learn complicated relationships between features.</p><p>This is why activation functions are essential when building deep neural networks.</p><h4>Linear vs. Non-Linear Relationship</h4><p>The graph below shows the difference.</p><p><strong>Without an activation function</strong>, the model produces a straight-line relationship.</p><p><strong>With an activation function</strong>, the output can follow a non-linear curve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K665PLDtOyA38KxBKMzItg.png" /></figure><h3>9. Common Activation Functions</h3><h4>9.1 Sigmoid</h4><p>The sigmoid function is:</p><p>σ(x) = 1 / (1 + e⁻ˣ)</p><p>Its output lies between 0 and 1.</p><p>For example:</p><p><strong>σ(0) = 0.5</strong></p><p>As the input becomes very large and positive, the output approaches <strong>1</strong>. As the input becomes very negative, the output approaches <strong>0</strong>.</p><p><strong>Simple</strong> <strong>flow:</strong></p><pre>Input → Sigmoid → Probability</pre><p>It is commonly associated with binary classification output layers.</p><h4>Example</h4><pre>import numpy as np</pre><pre>def sigmoid(x):<br>    return 1 / (1 + np.exp(-x))</pre><h3>10. ReLU</h3><p>ReLU stands for <strong>Rectified Linear Unit</strong>.</p><p>ReLU(x) = max(0, x)</p><p>So:</p><pre>x &lt; 0  → 0<br>x &gt; 0  → x</pre><p>Example:</p><pre>-5 → 0<br>-2 → 0<br> 0 → 0<br> 3 → 3<br> 7 → 7</pre><p>This simple behavior makes ReLU computationally efficient and helps neural networks learn non-linear patterns.</p><p>ReLU became extremely popular because it is simple and computationally efficient.</p><pre>def relu(x):<br>    return np.maximum(0, x)</pre><h3>11. Tanh</h3><p>The hyperbolic tangent function produces values between -1 and 1.</p><p>tanh(x) = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ)</p><p>Its output range is:</p><p><strong>−1 &lt; tanh(x) &lt; 1</strong></p><p>Compared with sigmoid:</p><pre>Sigmoid → 0 to 1<br>Tanh    → -1 to 1</pre><p>Because Tanh produces both positive and negative values, it can be useful when centered outputs are beneficial.</p><h3>12. Softmax</h3><p>Softmax is commonly used for <strong>multi-class classification</strong>, where a model needs to choose between more than two classes.</p><p>Suppose a model produces the following raw scores:</p><pre>Cat     2.5<br>Dog     1.2<br>Horse   0.8</pre><p>These values are called <strong>logits</strong>. They are not probabilities yet.</p><p>Softmax converts these scores into probabilities.</p><p><strong>The Softmax function is:</strong></p><p>P(y = i) = eᶻⁱ / Σⱼ eᶻʲ</p><p>The resulting probabilities add up to 1.</p><p>Example output:</p><pre>Cat     → 0.69<br>Dog     → 0.19<br>Horse   → 0.12</pre><p>So the model would assign the highest probability to <strong>Cat</strong>.</p><h3>13. Choosing an Activation Function</h3><p>A simple rule of thumb:</p><p>SituationCommon activationHidden layersReLUBinary classification outputSigmoidMulti-class classification outputSoftmaxSome hidden-layer scenariosTanh</p><p>The choice depends on the architecture and problem.</p><h3>14. Loss Function</h3><p>After the network produces a prediction, we need to know:</p><blockquote><strong><em>How wrong was the prediction?</em></strong></blockquote><p>That’s the job of the <strong>loss function</strong>.</p><p>The loss function measures the difference between the predicted value and the actual value.</p><pre>Actual value<br>     ↓<br>   Compare<br>     ↑<br>Prediction<br>     ↓<br>   Loss</pre><p>A smaller loss generally means the model’s predictions are closer to the target.</p><h3>15. Mean Squared Error</h3><p>For regression problems, a common loss is <strong>Mean Squared Error (MSE)</strong>.</p><p>MSE = (1 / n) × Σ (yᵢ − ŷᵢ)²</p><p><strong>Where:</strong></p><ul><li><strong>yᵢ</strong> = actual value</li><li><strong>ŷᵢ</strong> = predicted value</li><li><strong>n</strong> = number of observations</li></ul><p>Mean Squared Error measures the average squared difference between the actual values and the predicted values.</p><p>A smaller MSE means that the predictions are closer to the actual values.</p><p>Example:</p><pre>Actual     Prediction<br>10         8<br>20         18<br>30         32</pre><p>The errors are:</p><p><strong>10 − 8 = 2</strong></p><p><strong>20 − 18 = 2</strong></p><p><strong>30 − 32 = −2</strong></p><p>Squaring them gives:</p><p><strong>²² + ²² + (−2)² = 4 + 4 + 4</strong></p><p>Therefore:</p><p><strong>MSE = (4 + 4 + 4) / 3 = 4</strong></p><p>So, the MSE for this example is <strong>4</strong>.</p><p><strong>closing sentence:</strong></p><blockquote><em>The goal during training is to minimize the loss, meaning the network gradually adjusts its weights to make its predictions closer to the actual values.</em></blockquote><h3>16. Binary Cross-Entropy</h3><p>For <strong>binary classification</strong>, Binary Cross-Entropy (BCE) is a commonly used loss function.</p><p>It measures how different the predicted probability is from the actual class.</p><p><strong>The Binary Cross-Entropy formula is:</strong></p><p><strong>L = −[y × log(ŷ) + (1 − y) × log(1 − ŷ)]</strong></p><p>Where:</p><ul><li><strong>y</strong> = actual class, usually 0 or 1</li><li><strong>ŷ</strong> = predicted probability</li><li><strong>L</strong> = loss</li></ul><p>For example, suppose the actual class is <strong>1</strong>.</p><p>If the model predicts a probability close to <strong>1</strong>, the loss is small.</p><p>If the model predicts a probability close to <strong>0</strong>, the loss becomes much larger.</p><p>This means BCE strongly penalizes confident incorrect predictions.</p><h4>Simple intuition</h4><pre>Actual = 1</pre><pre>Prediction → 0.95 → Small loss<br>Prediction → 0.70 → Moderate loss<br>Prediction → 0.10 → Large loss</pre><p>Binary Cross-Entropy is commonly used with a <strong>Sigmoid output layer</strong> for binary classification.</p><h3>17. How Does an ANN Learn?</h3><p>This is where ANN becomes really interesting.</p><p>Initially, the weights are not the correct values.</p><p>So the network:</p><pre>1. Makes prediction<br>       ↓<br>2. Calculates loss<br>       ↓<br>3. Finds how weights contributed to error<br>       ↓<br>4. Updates weights<br>       ↓<br>5. Makes another prediction</pre><p>This process repeats many times.</p><p>The goal is to gradually reduce the loss.</p><h3>18. Backpropagation</h3><p><strong>Backpropagation</strong> is the algorithm used to calculate how much each parameter contributed to the error.</p><p>The basic idea:</p><pre>Forward Pass<br>Input → Network → Prediction<br>                    ↓<br>                   Loss<br>                    ↓<br>Backward Pass       ↓<br>Gradients ← ← ← ← ← </pre><p>The gradients tell us the direction in which parameters should change to reduce the loss.</p><p>Backpropagation uses the <strong>chain rule of calculus</strong> to calculate these gradients.</p><h3>19. Gradient Descent</h3><p>Once the gradients are calculated, the network needs a method to update its weights.</p><p>One of the fundamental optimization algorithms used for this purpose is <strong>Gradient Descent</strong>.</p><p>The basic update rule is:</p><p><strong>wₙₑw = wₒld − η × (∂L / ∂w)</strong></p><p>Where:</p><ul><li><strong>wₙₑw</strong> = updated weight</li><li><strong>wₒld</strong> = current weight</li><li><strong>η</strong> = learning rate</li><li><strong>L</strong> = loss</li><li><strong>∂L / ∂w</strong> = gradient of the loss with respect to the weight</li></ul><p>The gradient tells the network <strong>which direction the loss is increasing</strong>.</p><p>The network moves in the opposite direction to reduce the loss.</p><h4>Simple intuition</h4><p>Imagine standing on a hill and trying to reach the lowest point.</p><p>The <strong>height of the hill represents the loss</strong>.</p><p>The gradient tells you the direction of the slope.</p><p>Gradient Descent takes small steps toward the lower point.</p><pre>High Loss<br>   ●<br>    \<br>     ●<br>      \<br>       ●<br>        \<br>         ●  ← Minimum Loss</pre><p>You can keep this as a simple text illustration, but <strong>for your final Medium article, I recommend replacing this with an actual gradient-descent graph image</strong> rather than a grey code box.</p><h3>20. Learning Rate</h3><p>The learning rate determines <strong>how large each update is</strong>.</p><h4>Very small learning rate</h4><pre>Small steps<br>→ training may be very slow</pre><h4>Very large learning rate</h4><pre>Huge steps<br>→ may jump around the minimum</pre><h4>Appropriate learning rate</h4><pre>Controlled steps<br>→ smoother optimization</pre><p>This is why learning rate is an important hyperparameter.</p><h3>21. Epoch, Batch and Iteration</h3><p>These three terms often confuse beginners.</p><h4>Epoch</h4><p>One complete pass through the training dataset.</p><h4>Batch</h4><p>A smaller group of training examples processed together.</p><h4>Iteration</h4><p>One parameter-update step for a batch.</p><p><strong>For example:</strong></p><pre>Dataset = 1,000 samples<br>Batch size = 100</pre><pre>10 batches = 1 epoch</pre><h3>22. Batch Gradient Descent vs Mini-Batch Gradient Descent</h3><p>There are different ways to calculate gradients.</p><h4>Batch Gradient Descent</h4><p>Uses the complete training dataset for one update.</p><h4>Stochastic Gradient Descent</h4><p>Uses one training example at a time.</p><h4>Mini-Batch Gradient Descent</h4><p>Uses a small batch.</p><pre>Full dataset<br>     ↓<br>Mini-batches<br> ↓   ↓   ↓   ↓<br>Update Update Update Update</pre><p>Mini-batch training is widely used because it provides a practical balance between computation and learning stability.</p><h3>23. Optimizers</h3><p>Gradient descent is the basic idea, but several optimization algorithms improve the parameter-update process.</p><p>Popular optimizers include:</p><ul><li>SGD</li><li>Momentum</li><li>AdaGrad</li><li>RMSProp</li><li>Adam</li></ul><h3>24. Adam Optimizer</h3><p><strong>Adam</strong> stands for Adaptive Moment Estimation.</p><p>It combines ideas related to momentum and adaptive learning rates.</p><p>In practice, Adam is often a convenient starting optimizer for neural-network experiments.</p><p>Example:</p><pre>model.compile(<br>    optimizer=&quot;adam&quot;,<br>    loss=&quot;binary_crossentropy&quot;,<br>    metrics=[&quot;accuracy&quot;]<br>)</pre><p>The important point is not simply memorizing the name “Adam.”</p><p>Understand what an optimizer does:</p><blockquote><strong><em>It helps the model update its parameters efficiently during training.</em></strong></blockquote><h3>25. Parameters vs Hyperparameters</h3><p>This distinction is very important.</p><h4>Parameters</h4><p>Learned automatically during training.</p><p>Examples:</p><pre>Weights<br>Biases</pre><h4>Hyperparameters</h4><p>Chosen by the developer before or during training.</p><p>Examples:</p><pre>Learning rate<br>Batch size<br>Number of epochs<br>Number of hidden layers<br>Number of neurons</pre><pre>ANN<br>                 |<br>        ┌────────┴────────┐<br>        ↓                 ↓<br>   Parameters       Hyperparameters<br>   Weights            Learning rate<br>   Biases             Batch size<br>                      Epochs</pre><h3>26. Overfitting</h3><p>One of the biggest problems in neural networks is <strong>overfitting</strong>.</p><p>An overfitted model performs very well on training data but poorly on unseen data.</p><pre>Training Accuracy → 99%<br>Validation Accuracy → 72%</pre><p>This can indicate that the model has learned the training examples too specifically.</p><h4>Visual idea</h4><pre>Underfitting       Good Fit       Overfitting</pre><pre>   ___               /---\            /\/\/\<br>  /                 /     \          /      \<br> /                 /       \        /        \</pre><p>The goal is not simply to maximize training accuracy.</p><p>The goal is to <strong>generalize to unseen data</strong>.</p><h3>27. Underfitting</h3><p>Underfitting occurs when the model is too simple to capture the underlying patterns.</p><p>For example:</p><pre>Training performance → Poor<br>Validation performance → Poor</pre><p>Possible reasons include:</p><ul><li>Model too simple</li><li>Insufficient training</li><li>Poor features</li><li>Excessive regularization</li></ul><h3>28. Regularization</h3><p>Regularization helps reduce overfitting by discouraging overly complex models.</p><p>Common approaches include:</p><ul><li>L1 regularization</li><li>L2 regularization</li><li>Dropout</li><li>Early stopping</li></ul><h3>29. L1 and L2 Regularization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BP1yl0geUyzHZjKOmNL6yA.png" /></figure><h4>L1 Regularization</h4><p>L1 regularization adds a penalty based on the absolute values of the model’s weights.</p><p><strong>Formula:</strong></p><p><strong>Lₜₒₜₐₗ = L + λ × Σ|wᵢ|</strong></p><p>Where:</p><ul><li><strong>Lₜₒₜₐₗ</strong> = total loss</li><li><strong>L</strong> = original loss</li><li><strong>λ</strong> = regularization strength</li><li><strong>wᵢ</strong> = model weight</li></ul><p>L1 regularization encourages some weights to become exactly zero. As a result, it can help the model focus on the most important features and can produce a simpler model.</p><h4>Simple intuition</h4><p>If a model has many unnecessary features, L1 regularization can push the corresponding weights toward zero.</p><pre>Before regularization:</pre><pre>w₁ = 2.4<br>w₂ = 0.8<br>w₃ = 0.03<br>w₄ = 1.7</pre><pre>After L1 regularization:</pre><pre>w₁ = 2.1<br>w₂ = 0.6<br>w₃ = 0<br>w₄ = 1.5</pre><h4>L2 Regularization</h4><p>L2 regularization adds a penalty based on the squared values of the weights.</p><p><strong>Formula:</strong></p><p><strong>Lₜₒₜₐₗ = L + λ × Σwᵢ²</strong></p><p>Where:</p><ul><li><strong>Lₜₒₜₐₗ</strong> = total loss</li><li><strong>L</strong> = original loss</li><li><strong>λ</strong> = regularization strength</li><li><strong>wᵢ</strong> = model weight</li></ul><p>Unlike L1, L2 regularization usually does not force weights exactly to zero. Instead, it encourages them to remain relatively small.</p><h4>Simple intuition</h4><pre>L1 → pushes some weights toward 0<br>   → can make some weights exactly 0<br>   → useful for feature selection</pre><pre>L2 → pushes weights toward smaller values<br>   → usually does not make them exactly 0<br>   → helps reduce overfitting</pre><h4>L1 vs L2</h4><pre>L1 Regularization          L2 Regularization<br>──────────────────         ──────────────────<br>Absolute weights           Squared weights<br>Can make weights 0         Keeps weights small<br>Sparse model               Smoother model<br>Feature selection          Reduces large weights</pre><h4>In simple terms</h4><pre>L1 → &quot;Remove unnecessary features.&quot;</pre><pre>L2 → &quot;Keep all features, but reduce their influence.&quot;</pre><h3>30. Dropout</h3><p>Dropout is a popular regularization technique.</p><p>During training, randomly selected neurons are temporarily ignored.</p><pre>Before Dropout</pre><pre>● ─ ● ─ ● ─ ●<br> \  |  / \  |<br>  ● ─ ● ─ ●</pre><pre>After Dropout</pre><pre>● ─ ✕ ─ ● ─ ●<br> \     /    |<br>  ✕ ─ ● ─ ✕</pre><p>This prevents the network from relying too heavily on particular neurons.</p><h3>31. Early Stopping</h3><p>Sometimes training for too many epochs causes overfitting.</p><p>Early stopping monitors validation performance.</p><pre>Epoch 1 → Improving<br>Epoch 2 → Improving<br>Epoch 3 → Improving<br>Epoch 4 → Improving<br>Epoch 5 → No improvement<br>Epoch 6 → Worse</pre><pre>          ↓<br>     Stop Training</pre><p>Instead of blindly training for a fixed number of epochs, we can stop when validation performance stops improving.</p><h3>32. Data Preprocessing for ANN</h3><p>Neural networks usually work better when input data is appropriately prepared.</p><p>Typical steps include:</p><pre>Raw Dataset<br>    ↓<br>Handle Missing Values<br>    ↓<br>Encode Categorical Variables<br>    ↓<br>Scale Numerical Features<br>    ↓<br>Train / Validation / Test Split<br>    ↓<br>ANN</pre><h3>33. Feature Scaling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUC7RskNWOWo-qMPQh-DzQ.png" /></figure><p>Suppose our features are:</p><pre>Age       = 23<br>Salary    = 500000<br>Experience = 2</pre><p>Their scales are very different.</p><p>Scaling can help optimization behave more effectively.</p><p>Two common methods are:</p><h4>Standardization</h4><pre>z = (x − μ) / σ</pre><p>Where:</p><pre>x  = original value<br>μ  = mean<br>σ  = standard deviation</pre><blockquote><em>Standardization transforms the data so that it has a mean close to 0 and a standard deviation close to 1.</em></blockquote><h4>Min-Max Scaling</h4><pre>x′ = (x − x_min) / (x_max − x_min)</pre><p>Where:</p><pre>x      = original value<br>x_min  = minimum value<br>x_max  = maximum value<br>x′     = scaled value</pre><blockquote><em>Min-Max Scaling typically transforms values into the range 0 to 1.</em></blockquote><h3>34. Training, Validation and Test Data</h3><p>A dataset is commonly divided into:</p><pre>Dataset<br>   |<br>   ├── Training Data<br>   ├── Validation Data<br>   └── Test Data</pre><h4>Training set</h4><p>Used to learn parameters.</p><h4>Validation set</h4><p>Used during model development for choices such as hyperparameters and model selection.</p><h4>Test set</h4><p>Used for final evaluation on unseen data.</p><p>The exact split depends on the dataset and problem.</p><h3>35. ANN Architecture Design</h3><p>There is no universal ANN architecture that works for every dataset.</p><p>You might start with:</p><pre>Input<br>  ↓<br>Dense(64)<br>  ↓<br>ReLU<br>  ↓<br>Dense(32)<br>  ↓<br>ReLU<br>  ↓<br>Output</pre><p>For a binary classification problem:</p><pre>Output → 1 neuron → Sigmoid</pre><p>For a three-class problem:</p><pre>Output → 3 neurons → Softmax</pre><p>The architecture should be chosen according to the task, data, and experimental results.</p><h3>36. Building an ANN Using Python</h3><p>One common framework for building neural networks is TensorFlow/Keras.</p><p>A simple example:</p><pre>from tensorflow.keras.models import Sequential<br>from tensorflow.keras.layers import Dense</pre><pre>model = Sequential([<br>    Dense(64, activation=&quot;relu&quot;, input_shape=(10,)),<br>    Dense(32, activation=&quot;relu&quot;),<br>    Dense(1, activation=&quot;sigmoid&quot;)<br>])</pre><pre>model.compile(<br>    optimizer=&quot;adam&quot;,<br>    loss=&quot;binary_crossentropy&quot;,<br>    metrics=[&quot;accuracy&quot;]<br>)</pre><p>Here:</p><pre>10 input features<br>       ↓<br>64 neurons<br>       ↓<br>32 neurons<br>       ↓<br>1 output neuron</pre><h3>37. Training the Model</h3><p>Once the model is created:</p><pre>history = model.fit(<br>    X_train,<br>    y_train,<br>    epochs=20,<br>    batch_size=32,<br>    validation_data=(X_val, y_val)<br>)</pre><p>The model repeatedly performs:</p><pre>Forward propagation<br>        ↓<br>Calculate loss<br>        ↓<br>Backpropagation<br>        ↓<br>Optimizer updates weights<br>        ↓<br>Next batch</pre><p>This continues across multiple epochs.</p><h3>38. Evaluating the Model</h3><p>After training:</p><pre>loss, accuracy = model.evaluate(X_test, y_test)</pre><pre>print(&quot;Test Accuracy:&quot;, accuracy)</pre><p>But accuracy alone isn’t always enough.</p><p><strong>For classification, we can also examine:</strong></p><ul><li>Precision</li><li>Recall</li><li>F1-score</li><li>Confusion matrix</li></ul><p><strong>For regression:</strong></p><ul><li>MAE</li><li>MSE</li><li>RMSE</li><li>R²</li></ul><p>The appropriate metric depends on the problem.</p><h3>39. Understanding Training Curves</h3><p>During training, we can plot:</p><pre>Training Loss<br>Validation Loss<br>Training Accuracy<br>Validation Accuracy</pre><p>For example:</p><pre>import matplotlib.pyplot as plt</pre><pre>plt.plot(history.history[&quot;loss&quot;])<br>plt.plot(history.history[&quot;val_loss&quot;])</pre><pre>plt.xlabel(&quot;Epoch&quot;)<br>plt.ylabel(&quot;Loss&quot;)<br>plt.legend([&quot;Training&quot;, &quot;Validation&quot;])<br>plt.show()</pre><p>These curves can reveal useful information.</p><p>For example:</p><pre>Training loss ↓<br>Validation loss ↓</pre><p>usually indicates learning is progressing.</p><p>But if:</p><pre>Training loss ↓↓↓<br>Validation loss ↑↑</pre><p>it can indicate overfitting.</p><h3>40. Confusion Matrix</h3><p>For classification problems, a confusion matrix shows how predictions are distributed.</p><pre>Predicted<br>                 0          1<br>Actual  0       TN         FP<br>        1       FN         TP</pre><p>Where:</p><ul><li>TP = True Positive</li><li>TN = True Negative</li><li>FP = False Positive</li><li>FN = False Negative</li></ul><p>From these values, we can calculate several useful metrics.</p><h3>41. Precision, Recall and F1-Score</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaufTj9Eslc-A3-0JxINcg.png" /></figure><h4>Precision</h4><p>Precision tells us:</p><blockquote><strong><em>Of all the examples predicted as positive, how many were actually positive?</em></strong></blockquote><pre>Precision = TP / (TP + FP)</pre><pre>TP = True Positives<br>FP = False Positives</pre><h4>Example</h4><p>Suppose a model predicts <strong>100 emails as spam</strong>.</p><p>Out of those 100 emails:</p><ul><li>80 were actually spam</li><li>20 were actually not spam</li></ul><p>Then:</p><p><strong>TP = 80</strong></p><p><strong>FP = 20</strong></p><p>Therefore:</p><p><strong>Precision = 80 / (80 + 20) = 0.80</strong></p><p>So the precision is <strong>80%</strong>.</p><p>A high precision means that when the model predicts a positive class, it is usually correct.</p><h4>Recall</h4><p>Recall tells us:</p><blockquote><strong><em>Of all the actual positive examples, how many did the model successfully find?</em></strong></blockquote><pre>Recall = TP / (TP + FN)</pre><pre>TP = True Positives<br>FN = False Negatives</pre><h4>Example</h4><p>Suppose there are <strong>100 actual spam emails</strong>.</p><p>The model correctly identifies <strong>80</strong> of them.</p><p>Therefore:</p><p><strong>TP = 80</strong></p><p><strong>FN = 20</strong></p><p>So:</p><p><strong>Recall = 80 / (80 + 20) = 0.80</strong></p><p>Therefore, the recall is <strong>80%</strong>.</p><p>A high recall means the model is able to identify most of the actual positive cases.</p><h4>F1-Score</h4><p>Sometimes we want a balance between <strong>precision and recall</strong>.</p><p>The F1-score combines both metrics using their harmonic mean.</p><pre>F1 = 2 × (Precision × Recall)<br>        ─────────────────────<br>          Precision + Recall</pre><p>For example, if:</p><p><strong>Precision = 0.80</strong></p><p><strong>Recall = 0.80</strong></p><p>Then:</p><p><strong>F1 = 2 × (0.80 × 0.80) / (0.80 + 0.80)</strong></p><p><strong>F1 = 0.80</strong></p><p>Therefore, the F1-score is <strong>80%</strong>.</p><p>A higher F1-score indicates a better balance between precision and recall.</p><h4>Easy way<strong> </strong>to remember</h4><pre>Precision → Of predicted positives, how many were correct?<br>Recall    → Of actual positives, how many did we find?<br>F1-Score  → Balance between Precision and Recall.</pre><h3>42. ANN Limitations</h3><p>ANNs are powerful, but they are not perfect.</p><p>Some challenges include:</p><h4>1. Large data requirements</h4><p>Complex neural networks can benefit from substantial amounts of training data.</p><h4>2. Computational cost</h4><p>Larger networks require more computation.</p><h4>3. Hyperparameter tuning</h4><p>Choosing:</p><ul><li>learning rate</li><li>architecture</li><li>batch size</li><li>epochs</li></ul><p>can require experimentation.</p><h4>4. Overfitting</h4><p>Large networks can memorize training data.</p><h4>5. Interpretability</h4><p>Understanding exactly why a complex neural network produced a particular prediction can be difficult.</p><h3>43. Why Did Deep Learning Become So Successful?</h3><p>Several developments contributed to the growth of deep learning:</p><pre>More Data<br>   +<br>Better Hardware<br>   +<br>GPUs<br>   +<br>Improved Algorithms<br>   +<br>Better Architectures<br>   ↓<br>Rapid Growth of Deep Learning</pre><p>ANNs provided the foundation for increasingly specialized neural architectures.</p><h3>44. ANN vs Traditional Machine Learning</h3><p>A simplified comparison:</p><p>Traditional MLANNOften requires feature engineeringCan learn representationsWorks well on many structured datasetsPowerful for complex patternsOften easier to interpretCan be harder to interpretUsually lower computational requirementsCan require more computationOften works well with smaller datasetsOften benefits from more data</p><p>Neither approach is universally better.</p><p>The right method depends on the dataset, objective, constraints, and problem type.</p><h3>45. Complete ANN Learning Pipeline</h3><p>Now let’s connect everything together.</p><pre>DATA<br>                  ↓<br>          Data Preprocessing<br>                  ↓<br>            Feature Scaling<br>                  ↓<br>        Train / Validation / Test<br>                  ↓<br>           Design ANN Model<br>                  ↓<br>          Initialize Parameters<br>                  ↓<br>        ┌── Forward Propagation<br>        │<br>        ↓<br>      Prediction<br>        ↓<br>    Calculate Loss<br>        ↓<br>    Backpropagation<br>        ↓<br>    Calculate Gradients<br>        ↓<br>      Optimizer<br>        ↓<br>   Update Weights/Bias<br>        │<br>        └────── Repeat<br>                  ↓<br>              Evaluation<br>                  ↓<br>             Deployment</pre><p>This is the complete learning loop behind a basic ANN.</p><h3>46. A Simple Real-World Example</h3><p>Imagine we want to predict whether a student is likely to pass an exam.</p><p>Inputs:</p><pre>Study Hours<br>Attendance<br>Previous Score<br>Assignments Completed</pre><p>The ANN might learn:</p><pre>Study Hours ───────┐<br>Attendance ────────┤<br>Previous Score ────┤ → ANN → Probability<br>Assignments ───────┘</pre><p>Suppose the model produces:</p><pre>Probability of Passing = 0.87</pre><p>The model doesn’t “understand” the student like a human teacher.</p><p>It has learned numerical patterns from the training data.</p><p>That distinction is important.</p><h3>47. From One Neuron to Deep Neural Networks</h3><p>The journey can be visualized like this:</p><pre>Single Neuron<br>     ↓<br>Perceptron<br>     ↓<br>Multi-Layer Neural Network<br>     ↓<br>Deep Neural Network<br>     ↓<br>Specialized Neural Architectures</pre><p>The fundamental ideas remain:</p><pre>Inputs<br> ↓<br>Weights<br> ↓<br>Activation<br> ↓<br>Prediction<br> ↓<br>Loss<br> ↓<br>Gradients<br> ↓<br>Parameter Updates</pre><p>The architecture becomes more sophisticated, but these fundamentals remain important.</p><h3>48. Key ANN Concepts at a Glance</h3><pre>Neuron<br>   ↓<br>Weights + Bias<br>   ↓<br>Activation Function<br>   ↓<br>Forward Propagation<br>   ↓<br>Prediction<br>   ↓<br>Loss Function<br>   ↓<br>Backpropagation<br>   ↓<br>Gradient<br>   ↓<br>Optimizer<br>   ↓<br>Updated Parameters<br>   ↓<br>Repeat</pre><p>If you understand this flow, you understand the <strong>core learning mechanism of an ANN</strong>.</p><h3>49. Final Takeaway</h3><p>Artificial Neural Networks can look complicated when we first encounter terms like <em>backpropagation, gradients, activation functions, optimizers,</em> and <em>regularization</em>.</p><p>But the central idea is actually quite simple:</p><blockquote><strong><em>An ANN learns by making predictions, measuring its mistakes, and repeatedly adjusting its parameters to reduce those mistakes.</em></strong></blockquote><p>The important concepts connect naturally:</p><p><strong>Neuron → Layers → Forward Propagation → Loss → Backpropagation → Gradient Descent → Optimization → Regularization → Evaluation</strong></p><p>Understanding these foundations makes it much easier to move toward more advanced deep-learning architectures later.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02338e47793e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Natural Language Processing: From Simple Words to Modern Language Models]]></title>
            <link>https://medium.com/@afrin_24/natural-language-processing-from-simple-words-to-modern-language-models-1a13daf6aeb8?source=rss-4e08fe5ee8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a13daf6aeb8</guid>
            <dc:creator><![CDATA[Afrin]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 19:30:16 GMT</pubDate>
            <atom:updated>2026-09-21T19:30:16.123Z</atom:updated>
            <content:encoded><![CDATA[<h3>A beginner-friendly journey through how machines learned to understand human language</h3><p>Have you ever wondered how Google understands what you search, how a chatbot understands your question, or how an AI application can extract skills from a job description?</p><p>All of these are connected to <strong>Natural Language Processing (NLP)</strong>.</p><p>NLP is a field of Artificial Intelligence that helps computers <strong>process, understand, analyze, and generate human language</strong>.</p><p>But NLP did not become powerful overnight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVxWJg_rZaPmx18Up2nqew.png" /></figure><p>It evolved step by step:</p><pre>Raw Text<br>   ↓<br>Text Preprocessing<br>   ↓<br>One-Hot Encoding<br>   ↓<br>BoW<br>   ↓<br>TF-IDF<br>   ↓<br>Word Embeddings<br>   ↓<br>RNN → LSTM → GRU<br>   ↓<br>Seq2Seq + Attention<br>   ↓<br>Transformer<br>   ↓<br>LLMs &amp; Generative AI</pre><p>Let’s understand this journey in simple terms.</p><h3>1. What is Natural Language Processing?</h3><p>Human language is messy.</p><p>We use:</p><ul><li>Different sentence structures</li><li>Short forms</li><li>Emojis</li><li>Spelling mistakes</li><li>Different meanings for the same word</li><li>Multiple languages</li></ul><p>For example:</p><blockquote><strong><em>“The bank is near the river.”</em></strong></blockquote><p>Here, <em>bank</em> means the side of a river.</p><p>But:</p><blockquote><strong><em>“I deposited money in the bank.”</em></strong></blockquote><p>Here, <em>bank</em> means a financial institution.</p><p>Humans understand this from context. Teaching computers to do the same is one of the major challenges of NLP.</p><h3>Common NLP applications</h3><ul><li>Chatbots</li><li>Machine translation</li><li>Sentiment analysis</li><li>Spam detection</li><li>Search engines</li><li>Resume analysis</li><li>Text summarization</li><li>Question answering</li><li>Voice assistants</li><li>Generative AI</li></ul><h3>2. Text Preprocessing</h3><p>Before giving text to a machine learning model, we usually need to clean and prepare it.</p><p>Consider:</p><blockquote><strong><em>“I LOVE Python!!! 😊”</em></strong></blockquote><p>A preprocessing pipeline might convert it into:</p><blockquote><strong><em>“love python”</em></strong></blockquote><h3>Common preprocessing techniques</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2lYhZrGtOtn4KWSjTw7HyA.png" /></figure><h3>🔹 Tokenization</h3><p>Breaking text into smaller pieces called <strong>tokens</strong>.</p><pre>&quot;I love NLP&quot;<br>      ↓<br>[&quot;I&quot;, &quot;love&quot;, &quot;NLP&quot;]</pre><p>Simple Python:</p><pre>text = &quot;I love NLP&quot;<br>tokens = text.split()</pre><pre>print(tokens)</pre><p>Output:</p><pre>[&#39;I&#39;, &#39;love&#39;, &#39;NLP&#39;]</pre><h3>🔹 Stopword Removal</h3><p>Stopwords are very common words such as:</p><blockquote><em>the, is, a, an, and</em></blockquote><p>Depending on the task, some of these words can be removed.</p><pre>&quot;The student is learning Python&quot;</pre><pre>        ↓</pre><pre>&quot;student learning Python&quot;</pre><p>However, stopword removal is <strong>not always necessary</strong>. It depends on the NLP problem.</p><h3>🔹 Stemming</h3><p>Stemming tries to reduce words to a common root by cutting word endings.</p><pre>playing<br>played<br>plays<br>       ↓<br>     play</pre><p>It is fast, but the resulting word may not always be a proper dictionary word.</p><h3>🔹 Lemmatization</h3><p>Lemmatization tries to find the meaningful base form of a word.</p><pre>better → good<br>running → run</pre><p>It generally uses more linguistic information than simple stemming.</p><h3>🔹 Text Cleaning</h3><p>Text cleaning may include handling:</p><ul><li>Extra spaces</li><li>URLs</li><li>HTML tags</li><li>Unwanted symbols</li><li>Punctuation</li><li>Special characters</li></ul><p>The exact cleaning steps depend on the application.</p><h3>3. One-Hot Encoding</h3><p>After preprocessing, machines still cannot directly understand words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ijbrCwLe7g3VgAG1zr3Ng.png" /></figure><p>One early solution was <strong>One-Hot Encoding</strong>.</p><p>Suppose our vocabulary is:</p><pre>[&quot;cat&quot;, &quot;dog&quot;, &quot;car&quot;]</pre><p>We can represent them as:</p><pre>cat → [1, 0, 0]</pre><pre>dog → [0, 1, 0]</pre><pre>car → [0, 0, 1]</pre><p>Only one position contains 1, hence the name <strong>One-Hot</strong>.</p><h3>Problem</h3><p>These vectors do not tell us that:</p><blockquote><em>cat and dog are both animals.</em></blockquote><p>Every word is treated independently.</p><p>This leads us to the next approach.</p><h3>4. Bag of Words (BoW)</h3><p><strong>Bag of Words</strong> represents a document using the words that occur in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZauqBH6oyCCcuQh2vCD_lw.png" /></figure><p>Consider:</p><blockquote><em>“Python is easy”</em></blockquote><p>Vocabulary:</p><pre>Python | is | easy</pre><p>The sentence can be represented as:</p><pre>[1, 1, 1]</pre><p>Another sentence:</p><blockquote><em>“Python is powerful”</em></blockquote><p>could become:</p><pre>[1, 1, 0]</pre><p>BoW considers <strong>word frequency</strong>, but it ignores grammar and word order.</p><p>For example:</p><blockquote><em>“Dog bites man”</em></blockquote><p>and</p><blockquote><em>“Man bites dog”</em></blockquote><p>can look very similar because they contain the same words.</p><h3>5. TF-IDF</h3><p><strong>TF-IDF</strong> stands for:</p><blockquote><strong><em>Term Frequency — Inverse Document Frequency</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UEdPbdQo9Q8nPBnfDj1F4w.png" /></figure><p>It tries to identify words that are important to a particular document.</p><p>The basic idea is:</p><ul><li>A word appearing frequently in a document is important.</li><li>A word appearing in almost every document is less useful for distinguishing documents.</li></ul><h3>Formula</h3><p>TF-IDF = TF × IDF</p><p>where:</p><p>IDF = log(N / df)</p><p>Here:</p><ul><li><strong>TF</strong> = Term Frequency</li><li><strong>IDF</strong> = Inverse Document Frequency</li><li><strong>N</strong> = Total number of documents</li><li><strong>df</strong> = Number of documents containing the word</li></ul><p>TF-IDF gives higher importance to words that are frequent in a particular document but less common across the entire collection.</p><h3>6. Problems with One-Hot, BoW and TF-IDF</h3><p>These traditional methods were useful, but they had important limitations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoM0Rj1kIe1Da7T7Th6GTA.png" /></figure><h3>❌ Sparsity</h3><p>If the vocabulary contains thousands of words, most positions in a vector are zero.</p><h3>❌ No semantic understanding</h3><p>The model does not naturally understand that:</p><blockquote><strong><em>car ≈ automobile</em></strong></blockquote><h3>❌ No contextual information</h3><p>The meaning of a word can change depending on context.</p><h3>❌ High dimensionality</h3><p>Large vocabularies can create very large vectors.</p><p>So researchers needed a better way to represent words.</p><pre>One-Hot<br>   ↓<br>BoW<br>   ↓<br>TF-IDF<br>   ↓<br>&quot;Can we represent meaning?&quot;<br>   ↓<br>Word Embeddings</pre><h3>7. Neural Probabilistic Language Model — NPLM</h3><p>The <strong>Neural Probabilistic Language Model</strong> introduced the idea of learning distributed representations of words using neural networks.</p><p>Instead of treating words as completely independent symbols, the model learns numerical representations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUt72oSKMYygOJZVQxQ9gw.png" /></figure><p>A simplified idea:</p><pre>Previous Words<br>      ↓<br> Word Embeddings<br>      ↓<br> Neural Network<br>      ↓<br> Next Word Probability</pre><p>For example:</p><blockquote><em>“I drink ___”</em></blockquote><p>The model may learn that:</p><blockquote><em>water, tea, coffee</em></blockquote><p>are more likely than unrelated words.</p><h3>Advantages</h3><ul><li>Learns word representations</li><li>Captures relationships between words</li><li>Uses neural networks</li></ul><h3>Limitations</h3><ul><li>Computationally expensive</li><li>Difficult to scale</li><li>Context window is limited</li></ul><p>This motivated more efficient word-embedding techniques.</p><h3>8. Word2Vec</h3><p><strong>Word2Vec</strong> became one of the most popular methods for learning word embeddings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4LlxsbkgWg_u6DoC56WYA.png" /></figure><p>Instead of representing a word using a huge sparse vector, it represents it using a <strong>dense numerical vector</strong>.</p><p>Conceptually:</p><pre>king   → [0.21, 0.45, -0.13, ...]<br>queen  → [0.20, 0.44, -0.10, ...]<br>apple  → [0.72, -0.18, 0.31, ...]</pre><p>Words used in similar contexts tend to have similar representations.</p><h3>Advantages</h3><ul><li>Dense vectors</li><li>Captures semantic relationships</li><li>More efficient than one-hot representations</li></ul><h3>Limitation</h3><p>A word generally receives <strong>one fixed vector</strong>.</p><p>This creates a problem for words with multiple meanings.</p><h3>9. CBOW</h3><p><strong>Continuous Bag of Words (CBOW)</strong> predicts a target word from surrounding words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1BV1AMnwzaRHQXvyDrTcsw.png" /></figure><p>For example:</p><blockquote><em>“I drink ___ every morning.”</em></blockquote><p>The surrounding words help predict:</p><blockquote><strong><em>coffee</em></strong></blockquote><p>Diagram:</p><pre>I       drink       every       morning<br> \        |           |            /<br>          ↓<br>     Neural Network<br>          ↓<br>        coffee</pre><p>CBOW is generally efficient and works well for learning common word relationships.</p><h3>10. Skip-Gram</h3><p>Skip-Gram works in the opposite direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UB01LGD3qh8Il6LfsAi88Q.png" /></figure><p>Instead of using surrounding words to predict a target word, it uses the target word to predict surrounding words.</p><pre>coffee<br>          /    |    \<br>        drink morning cup</pre><h3>CBOW</h3><p><strong>Context → Target</strong></p><h3>Skip-Gram</h3><p><strong>Target → Context</strong></p><p>Both approaches are used to learn useful word embeddings.</p><h3>11. FastText</h3><p>FastText improved upon traditional word embeddings by considering <strong>subword information</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ieW8UGqusYJ63JtFDpVSjw.png" /></figure><p>Instead of treating:</p><blockquote><em>playing</em></blockquote><p>as one complete word, FastText can learn from smaller character pieces.</p><p>This is particularly useful for:</p><ul><li>Rare words</li><li>Spelling variations</li><li>Morphologically rich languages</li></ul><h3>Simple idea</h3><pre>playing</pre><pre>pla | lay | ayi | yin | ing</pre><p>The model can learn information from these smaller pieces.</p><h3>12. GloVe</h3><p><strong>GloVe — Global Vectors for Word Representation</strong> — learns word vectors using information about how frequently words occur together across a large collection of text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wWidya1uEjGRGmAYpWyA3g.png" /></figure><p>The central idea is:</p><blockquote><strong><em>Words that appear in similar contexts tend to have related meanings.</em></strong></blockquote><p>For example:</p><pre>king → queen<br>man  → woman</pre><p>GloVe became another important method for creating dense word representations.</p><h3>13. Limitations of Static Word Embeddings</h3><p>Word2Vec, GloVe, and FastText were major improvements, but they still had a fundamental problem.</p><h3>The polysemy problem</h3><p>Consider:</p><blockquote><em>“I went to the bank to deposit money.”</em></blockquote><p>and:</p><blockquote><em>“We sat on the river bank.”</em></blockquote><p>The word <strong>bank</strong> has two meanings.</p><p>But a static embedding generally gives the word one fixed representation.</p><pre>bank<br> ↓<br>ONE VECTOR</pre><p>What we really want is:</p><pre>bank + context<br>       ↓<br>meaning 1</pre><pre>bank + different context<br>       ↓<br>meaning 2</pre><p>This created the need for models that understand <strong>context</strong>.</p><h3>14. Rule-Based Machine Translation — RBMT</h3><p>Before modern neural translation, one approach was <strong>Rule-Based Machine Translation</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFtPUazhdp1cZlZFy8MDqg.png" /></figure><p>RBMT used:</p><ul><li>Grammar rules</li><li>Dictionaries</li><li>Language-specific rules</li></ul><p>Simplified:</p><pre>Source Language<br>       ↓<br>Grammar Rules<br>       ↓<br>Dictionary<br>       ↓<br>Target Language</pre><h3>Limitation</h3><p>Human languages contain too many exceptions and complex structures to be completely described using manually written rules.</p><h3>15. Statistical Machine Translation — SMT</h3><p>SMT introduced a statistical approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIkg_e6X3JxxiHYJDrbIHQ.png" /></figure><p>Instead of manually writing every translation rule, the system learned translation patterns from large collections of translated text.</p><pre>Parallel Text<br>     ↓<br>Statistical Model<br>     ↓<br>Most likely translation</pre><p>This reduced dependence on manually written rules.</p><p>However, SMT systems still relied on multiple components and could struggle with long-range context.</p><h3>16. Neural Machine Translation — NMT</h3><p>Neural Machine Translation uses neural networks to translate one language into another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvYdXL_EAgkVEoEiUa7gCQ.png" /></figure><h3>Why was NMT introduced?</h3><p>The goal was to create a system that could learn translation patterns <strong>end-to-end</strong> and represent language using continuous numerical representations.</p><pre>English<br>  ↓<br>Neural Network<br>  ↓<br>French</pre><p>This eventually led to sequence models such as RNNs, LSTMs, and later Transformers.</p><h3>17. Recurrent Neural Networks — RNN</h3><p>RNNs were designed to process sequential information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PmimLCSjCyTFqNTGCRplUA.png" /></figure><p>They process words one after another while maintaining a hidden state.</p><pre>Word 1 → Word 2 → Word 3 → Word 4<br>  ↓        ↓        ↓        ↓<br> h1       h2       h3       h4</pre><p>The hidden state carries information from previous words.</p><h3>Advantages</h3><ul><li>Designed for sequential data</li><li>Can remember previous information</li><li>Useful for language modelling</li></ul><h3>Limitations</h3><p>RNNs can struggle with <strong>long-term dependencies</strong>.</p><p>For a long sentence, information from the beginning may become difficult to preserve.</p><p>This problem encouraged the development of LSTM.</p><h3>18. Long Short-Term Memory — LSTM</h3><p>LSTM is a special type of RNN designed to handle long-term dependencies better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kj_l4QimVtE8pWUrFblc3g.png" /></figure><p>It uses <strong>gates</strong> to control information.</p><h3>Three important gates</h3><p>🔹 <strong>Forget Gate</strong> — What information should be removed?</p><p>🔹 <strong>Input Gate</strong> — What new information should be stored?</p><p>🔹 <strong>Output Gate</strong> — What information should be passed forward?</p><p>Simple view:</p><pre>Previous State<br>      ↓<br> ┌─────────────┐<br> │ Forget Gate │<br> │ Input Gate  │<br> │ Output Gate │<br> └─────────────┘<br>      ↓<br> New State</pre><h3>Why is LSTM better than basic RNN?</h3><p>LSTM can preserve useful information for longer sequences and helps reduce the vanishing-gradient problem that affected simple RNNs.</p><h3>19. Gated Recurrent Unit — GRU</h3><p>GRU is another gated recurrent architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEKElT202Dg-TUOKXbH9lA.png" /></figure><p>It is simpler than LSTM.</p><p>Instead of three separate gates, GRU mainly uses:</p><ul><li>Update Gate</li><li>Reset Gate</li></ul><pre>Input + Previous State<br>          ↓<br>     GRU Gates<br>          ↓<br>     New Hidden State</pre><h3>Advantages over LSTM</h3><ul><li>Simpler architecture</li><li>Fewer parameters</li><li>Often faster to train</li></ul><p>The choice between LSTM and GRU depends on the problem and dataset.</p><h3>20. Sequence-to-Sequence — Seq2Seq</h3><p>Seq2Seq models are useful when both the input and output are sequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lA6HDLCH1fVz59PofMx-w.png" /></figure><p>For example:</p><blockquote><em>English sentence → French sentence</em></blockquote><p>The architecture contains:</p><h3>Encoder</h3><p>Reads the input.</p><h3>Context Vector</h3><p>Stores information about the input.</p><h3>Decoder</h3><p>Generates the output.</p><pre>Input<br> ↓<br>ENCODER<br> ↓<br>Context Vector<br> ↓<br>DECODER<br> ↓<br>Output</pre><h3>Problem</h3><p>The entire input needs to be compressed into a single context vector.</p><p>For long sentences, this can become a bottleneck.</p><p>That led to the <strong>Attention Mechanism</strong>.</p><h3>21. Seq2Seq with Attention</h3><p>Attention allowed the decoder to look at <strong>different parts of the input</strong> instead of depending only on one fixed context vector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a40S4ju1kiI0WAMMIjZ51w.png" /></figure><pre>Input words<br>   ↓ ↓ ↓ ↓<br> ┌──────────────┐<br> │    Encoder   │<br> └──────────────┘<br>   ↓ ↓ ↓ ↓<br> Attention<br>   ↓<br> Decoder<br>   ↓<br> Output</pre><p>For every generated word, the model can focus more strongly on the relevant input words.</p><h3>Advantage</h3><p>Instead of:</p><blockquote><strong><em>One sentence → One fixed vector</em></strong></blockquote><p>we get:</p><blockquote><strong><em>Output word → Relevant parts of input</em></strong></blockquote><p>This significantly improved sequence-to-sequence modelling.</p><h3>22. Transformer Architecture</h3><p>Attention was powerful, but researchers wanted an architecture that could process sequences more efficiently without depending on recurrence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8sx8VfjTuNkzcLTOZ32pRQ.png" /></figure><p>In 2017, the Transformer architecture was introduced.</p><p>The Transformer paper was titled:</p><blockquote><strong><em>“Attention Is All You Need.”</em></strong></blockquote><h3>Basic architecture</h3><pre>INPUT<br>                  ↓<br>             Embeddings<br>                  ↓<br>        ┌─────────────────┐<br>        │     ENCODER     │<br>        │                 │<br>        │ Self-Attention  │<br>        │       ↓         │<br>        │ Feed Forward    │<br>        └─────────────────┘<br>                  ↓<br>        ┌─────────────────┐<br>        │     DECODER     │<br>        │                 │<br>        │ Self-Attention  │<br>        │ Cross-Attention │<br>        │ Feed Forward    │<br>        └─────────────────┘<br>                  ↓<br>               OUTPUT</pre><h3>Self-Attention</h3><p>Self-attention allows tokens to look at other tokens and determine their relevance.</p><h3>Multi-Head Attention</h3><p>Instead of using one attention mechanism, multiple attention heads can learn different relationships.</p><h3>Positional Encoding</h3><p>Because Transformers do not process words sequentially like RNNs, positional information is added so the model knows the order of tokens.</p><h3>Feed Forward Network</h3><p>Each Transformer layer contains a feed-forward network that further processes the representations.</p><h3>Residual Connections</h3><p>Residual connections help information flow through deep networks and make training more stable.</p><h3>Layer Normalization</h3><p>Layer normalization helps stabilize the network during training.</p><h3>Why Transformers replaced many RNN-based approaches</h3><p>Transformers offer:</p><ul><li>Better parallel processing</li><li>Strong context modelling</li><li>Better handling of long-range relationships</li><li>Excellent scalability</li></ul><p>This architecture became the foundation for many modern language models.</p><h3>23. Supervised Fine-Tuning — SFT</h3><p>A pretrained language model can be adapted to perform specific tasks using <strong>Supervised Fine-Tuning</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J5UoOOkmLzRRBLXIvGlZVA.png" /></figure><p>A simplified pipeline is:</p><pre>Base LLM<br>   ↓<br>Instruction Dataset<br>   ↓<br>Tokenization<br>   ↓<br>Fine-Tuning<br>   ↓<br>Evaluation<br>   ↓<br>Deployment</pre><h3>1. Base LLM</h3><p>Start with a pretrained language model.</p><h3>2. Instruction Dataset</h3><p>Provide examples of:</p><blockquote><em>Instruction → Expected Response</em></blockquote><h3>3. Tokenization</h3><p>Convert text into tokens that the model can process.</p><h3>4. Fine-Tuning</h3><p>Train the model further using the prepared dataset.</p><h3>5. Evaluation</h3><p>Measure how well the model performs.</p><h3>6. Deployment</h3><p>Make the trained model available for users or applications.</p><p>This is one of the ways modern AI systems can be adapted to specific use cases.</p><h3>24. NLP Evaluation Metrics</h3><p>Building an NLP model is not enough. We also need to measure its performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*coWruyuoK9MdUJ7hR87TGA.png" /></figure><h3>BLEU</h3><p>Often used for machine translation.</p><p>It compares generated text with reference translations using matching n-grams.</p><h3>ROUGE</h3><p>Commonly used for text summarization.</p><p>It measures overlap between generated and reference summaries.</p><h3>Perplexity</h3><p>Often used to evaluate language models.</p><p>Lower perplexity generally indicates that the model finds the test text more predictable.</p><h3>Precision</h3><p>Of the items predicted as positive, how many were actually positive?</p><p>Precision = TP / (TP + FP)</p><h3>Recall</h3><p>Of all actual positive items, how many did the model find?</p><p>Recall = TP / (TP + FN)</p><h3>F1-Score</h3><p>F1 combines precision and recall.</p><p>F1 = 2 × (Precision × Recall) / (Precision + Recall)</p><h3>Accuracy</h3><p>Accuracy measures the proportion of correct predictions.</p><p>Accuracy = Correct Predictions / Total Predictions</p><p>Accuracy can be useful for some classification problems, but it may be misleading when classes are highly imbalanced.</p><h3>🌱 The Complete NLP Evolution</h3><p>Now we can see why NLP evolved step by step:</p><pre>NATURAL LANGUAGE PROCESSING<br>                            │<br>                            ▼<br>                    Text Preprocessing<br>                            │<br>                            ▼<br>              One-Hot → BoW → TF-IDF<br>                            │<br>                            ▼<br>                    Word Embeddings<br>                            │<br>                 ┌──────────┼──────────┐<br>                 ▼          ▼          ▼<br>              Word2Vec   GloVe     FastText<br>                 │<br>                 ▼<br>          RNN → LSTM → GRU<br>                 │<br>                 ▼<br>              Seq2Seq<br>                 │<br>                 ▼<br>             Attention<br>                 │<br>                 ▼<br>            TRANSFORMERS<br>                 │<br>                 ▼<br>              LLMs<br>                 │<br>                 ▼<br>           Generative AI</pre><p>The important point is that <strong>each new technique was introduced to address limitations of earlier approaches</strong>.</p><h3>💡 What I Learned From This Journey</h3><p>When I first started learning NLP, the number of techniques felt overwhelming.</p><p>One-Hot Encoding, TF-IDF, Word2Vec, RNN, LSTM, Attention, Transformers… it can seem like a collection of unrelated topics.</p><p>But when we look at the evolution, the picture becomes much clearer.</p><p>Each technique answers a problem from the previous one:</p><blockquote><strong><em>How do we represent words?</em></strong></blockquote><p>↓</p><blockquote><strong><em>How do we represent meaning?</em></strong></blockquote><p>↓</p><blockquote><strong><em>How do we remember previous words?</em></strong></blockquote><p>↓</p><blockquote><strong><em>How do we handle long-term context?</em></strong></blockquote><p>↓</p><blockquote><strong><em>How do we focus on the relevant words?</em></strong></blockquote><p>↓</p><blockquote><strong><em>How do we process language more efficiently at scale?</em></strong></blockquote><p>And that journey eventually leads us to <strong>Transformers and modern Large Language Models.</strong></p><h3>🚀 Conclusion</h3><p>Natural Language Processing has evolved from simple rule-based systems and word-counting techniques into sophisticated neural architectures capable of understanding and generating human language.</p><p>We started with:</p><p><strong>Text Cleaning → One-Hot Encoding → BoW → TF-IDF</strong></p><p>Then moved toward:</p><p><strong>Word2Vec → GloVe → FastText</strong></p><p>Then sequence models:</p><p><strong>RNN → LSTM → GRU → Seq2Seq</strong></p><p>Then:</p><p><strong>Attention → Transformers → LLMs</strong></p><p>Understanding this evolution is more valuable than simply memorizing the names of different algorithms.</p><p>Because once we understand <strong>what problem each technique was trying to solve</strong>, modern NLP becomes much easier to understand.</p><blockquote><strong><em>NLP is not one technology. It is a journey of solving one limitation after another.</em></strong><em> 🌱</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a13daf6aeb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ My Learning Journey in Machine Learning: From Pipeline to Model Building]]></title>
            <link>https://medium.com/@afrin_24/my-learning-journey-in-machine-learning-from-pipeline-to-model-building-fd8a6df493e1?source=rss-4e08fe5ee8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd8a6df493e1</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[learning-journey]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[model-building]]></category>
            <dc:creator><![CDATA[Afrin]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 19:22:30 GMT</pubDate>
            <atom:updated>2026-04-15T19:22:30.458Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning is one of the most exciting areas in Data Science because it helps systems learn from historical data and make future predictions.</p><p>In this blog, I am sharing my understanding of the <strong>Machine Learning Pipeline</strong> and the key concepts I have learned so far, from data preprocessing to final model selection.</p><p><strong>For example:</strong></p><ul><li>predicting house prices</li><li>predicting whether a customer will purchase a product</li><li>predicting student exam results</li><li>fraud detection</li></ul><p><strong>A simple real-life example discussed in class was:</strong></p><p><em>If a person enters a mall, can we predict whether they are going to purchase something or not?</em></p><p>This is where Machine Learning helps in building intelligent systems.</p><h3>📌 What is Machine Learning?</h3><p>Machine Learning is a branch of AI where systems learn from data using <strong>mathematics and statistics-based algorithms</strong>.</p><p>An algorithm is simply a <strong>set of rules or instructions</strong>.</p><p>The output of any ML algorithm is called a <strong>model</strong>.</p><p>This model learns from past data and predicts future outputs.</p><h3>📌 Categories of AI</h3><p>The major categories we learned are:</p><h3>1. Machine Learning</h3><p>If algorithms are built using mathematics and statistics, they come under Machine Learning.</p><p>Mostly works on <strong>structured/tabular data</strong> such as:</p><ul><li>CSV</li><li>Excel</li><li>SQL tables</li></ul><h3>2. Deep Learning</h3><p>Deep Learning is an advanced form of ML that mainly works on:</p><ul><li>images</li><li>audio</li><li>video</li><li>text</li></ul><p>It uses <strong>Neural Networks</strong> with a large number of parameters.</p><h3>3. Generative AI</h3><p>Generative AI is an advanced Deep Learning concept.</p><p>Examples include <strong>LLMs (Large Language Models)</strong>.</p><p>LLMs mainly handle <strong>text input and text output</strong>.</p><p><strong>Example:</strong></p><ul><li>input → text</li><li>output → text</li></ul><h3>📌 Types of Data</h3><p>We learned that data can be divided into:</p><h3>Structured Data</h3><p>Tabular data like:</p><ul><li>Excel</li><li>CSV</li><li>SQL</li></ul><h3>Semi-Structured Data</h3><ul><li>JSON</li><li>XML</li></ul><h3>Unstructured Data</h3><ul><li>text</li><li>images</li><li>audio</li><li>video</li></ul><p>Machine Learning mainly handles <strong>structured data</strong>.</p><p>Deep Learning handles unstructured data.</p><h3>📌 Types of Machine Learning</h3><h3>1. Supervised Learning</h3><p>In supervised learning, both <strong>input and output (target)</strong> are available.</p><p><strong>Example:</strong></p><ul><li>salary prediction</li><li>exam pass/fail</li><li>product purchase prediction</li></ul><p>Supervised learning is divided into:</p><h4>Regression</h4><p>If the target column is continuous, it is regression.</p><p><strong>Examples:</strong></p><ul><li>house price prediction</li><li>sales prediction</li><li>stock price prediction</li></ul><h4>Classification</h4><p>If the target column is discrete/categorical, it is classification.</p><p><strong>Examples:</strong></p><ul><li>yes / no</li><li>pass / fail</li><li>spam / ham</li></ul><h3>2. Unsupervised Learning</h3><p>In this case, there is <strong>no target column</strong>.</p><p>The algorithm groups data into clusters.</p><p><strong>Examples:</strong></p><ul><li>customer segmentation</li><li>market targeting</li><li>grouping similar users</li></ul><p><strong>Types include:</strong></p><ul><li>clustering</li><li>dimensionality reduction</li><li>association rules</li></ul><h3>3. Semi-Supervised Learning</h3><p>Combination of labelled and unlabelled data.</p><p><strong>Example:</strong><br>Google Photos image grouping.</p><h3>4. Reinforcement Learning</h3><p>The system learns through <strong>trial and error</strong>.</p><p><strong>Example:</strong><br>self-driving cars</p><h3>📌 Machine Learning Pipeline</h3><p>The Machine Learning Pipeline is a <strong>step-by-step workflow</strong> followed to build a machine learning model.</p><p>Instead of directly applying an algorithm to raw data, we first prepare the data properly, train the model, evaluate it, and then choose the best version of the model.</p><p>Think of it like a journey:</p><p><strong>Raw Data → Data Preprocessing → Model Training → Prediction &amp; Evaluation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/0*uPvEI4Kb6o9EB4zk" /></figure><p>Let’s understand each step in a simple way.</p><h3>1. Load the Data</h3><p>This is the very first step.</p><p>Here, we bring the dataset into Python so that we can work with it.</p><p>Usually, data comes from:</p><ul><li>CSV files</li><li>Excel sheets</li><li>SQL databases</li><li>APIs</li></ul><p><strong>For example:</strong></p><pre>import pandas as pd</pre><pre>df = pd.read_csv(&quot;data.csv&quot;)</pre><p>This converts the file into a DataFrame, which is easier to analyze.</p><p>In simple words, this step means:</p><p><em>“bringing the data into our workspace”</em></p><h3>2. Data Cleaning</h3><p>Real-world data is rarely perfect.</p><p><strong>Sometimes it contains:</strong></p><ul><li>missing values</li><li>duplicate rows</li><li>wrong data types</li><li>spelling issues</li><li>outliers</li></ul><p>So before using the data, we need to clean it.</p><p><strong>For example:</strong></p><ul><li>replacing null values</li><li>removing duplicates</li><li>fixing column names</li><li>correcting data types</li></ul><p>This step is important because:</p><p><strong><em>bad data gives bad predictions</em></strong></p><p>That’s why data cleaning is one of the most crucial steps.</p><h3>3. Data Analysis</h3><p>Once the data is cleaned, we try to understand it.</p><p><strong>This step is all about asking questions like:</strong></p><ul><li>What patterns exist?</li><li>Which columns are important?</li><li>Is the data balanced?</li><li>Are there relationships between features?</li></ul><p>This is where EDA (Exploratory Data Analysis) comes in.</p><p><strong>We use:</strong></p><ul><li>graphs</li><li>statistics</li><li>summary tables</li></ul><p>This helps us understand the story behind the data.</p><h3>4. Feature Engineering</h3><p>Features are basically the input columns used for prediction.</p><p>In this step, we improve those features.</p><p><strong>For example:</strong></p><ul><li>converting text categories into numbers</li><li>creating new useful columns</li><li>scaling numerical values</li><li>extracting date parts like month/year</li></ul><p>This step helps the model learn better.</p><p><strong>In simple words:</strong></p><p><em>“making the input data smarter for the model”</em></p><h3>5. Train Test Split</h3><p>This is one of the most important steps in ML.</p><p>We split the data into two parts:</p><ul><li><strong>training data</strong> → used to teach the model</li><li><strong>testing data</strong> → used to check how well it learned</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*M0_XrE-9T-VfhGx1" /></figure><p><strong>Example:</strong></p><pre>from sklearn.model_selection import train_test_split<br><br>X_train, X_test, y_train, y_test = train_test_split(<br>    X, y, test_size=0.2, random_state=42<br>)</pre><p><strong>Usually:</strong></p><ul><li>80% → training</li><li>20% → testing</li></ul><p>This helps us check whether the model works well on unseen data.</p><h3>6. Model Building</h3><p>Now comes the actual learning step.</p><p>Here, we choose an algorithm and train it on the training data.</p><p><strong>Examples:</strong></p><ul><li>Linear Regression</li><li>KNN</li><li>Decision Tree</li><li>Random Forest</li></ul><p>The model tries to learn patterns from the data.</p><p><strong>For example:</strong></p><p><em>students who study more hours are more likely to pass</em></p><p>This learned logic becomes the model.</p><h3>7. Model Prediction</h3><p>After training, we use the model to make predictions.</p><p><strong>For example:</strong></p><pre>y_pred = model.predict(X_test)</pre><p>This gives predicted outputs for unseen test data.</p><p>This is where we see how the model performs.</p><h3>8. Hyperparameter Tuning</h3><p>Sometimes the model works, but not perfectly.</p><p>So we improve it by changing some settings called parameters.</p><p><strong>For example:</strong></p><ul><li>number of neighbors in KNN</li><li>depth of a decision tree</li><li>learning rate</li></ul><p>Changing these values helps improve accuracy.</p><p><strong>Think of it like:</strong></p><p><em>“fine-tuning the model for better performance”</em></p><h3>9. Cross Validation</h3><p>Instead of checking the model on only one test split, we check it on multiple splits.</p><p>This helps us know whether the model is stable and consistent.</p><p>It reduces the chance of overfitting.</p><h3>10. Model Optimization</h3><p>This step is about improving the overall model performance.</p><p><strong>We may:</strong></p><ul><li>select better features</li><li>remove unnecessary columns</li><li>tune parameters</li><li>improve preprocessing</li></ul><p>The goal is to get the best possible results.</p><h3>11. Model Comparison</h3><p>Sometimes we build multiple models.</p><p><strong>For example:</strong></p><ul><li>Linear Regression</li><li>Decision Tree</li><li>Random Forest</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*qAdWnRra3bDB0aPR" /></figure><p><strong>Then we compare them using metrics like:</strong></p><ul><li>accuracy</li><li>precision</li><li>recall</li><li>RMSE</li></ul><p>The best-performing model is selected.</p><h3>12. Final Model Selection</h3><p>After all comparisons and improvements, we select the final model.</p><p>This model is then ready for real-world predictions and deployment.</p><p>This is the final step of the pipeline.</p><h3>📌 Overfitting vs Underfitting</h3><h3>Overfitting</h3><p>Works well on training data but poorly on testing data.</p><h3>Underfitting</h3><p>Performs poorly on both training and testing data.</p><h3>✨ My Learning</h3><p>From this topic, I understood that Machine Learning is not only about following the pipeline, but also about understanding <strong>which algorithm to use for which type of problem</strong>.</p><p>For example, if the target value is continuous, we use <strong>regression algorithms</strong>, and if the output is categorical, we use <strong>classification algorithms</strong>.</p><p>This learning helped me understand how to choose the right approach based on the problem statement and the type of data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd8a6df493e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>