<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Audrine Marion</title>
    <description>The latest articles on DEV Community by Audrine Marion (@audrine_m).</description>
    <link>https://dev.to/audrine_m</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3818409%2F9fb58cc0-5333-4494-84ef-e77061565cba.jpg</url>
      <title>DEV Community: Audrine Marion</title>
      <link>https://dev.to/audrine_m</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/audrine_m"/>
    <language>en</language>
    <item>
      <title>Neural Networks: Inspired by the Brain, Built for Data</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Tue, 08 Sep 2026 07:37:16 +0000</pubDate>
      <link>https://dev.to/audrine_m/neural-networks-inspired-by-the-brain-built-for-data-2ha</link>
      <guid>https://dev.to/audrine_m/neural-networks-inspired-by-the-brain-built-for-data-2ha</guid>
      <description>&lt;p&gt;When I first started learning about neural networks, I found the idea both fascinating and slightly intimidating.&lt;/p&gt;

&lt;p&gt;The phrase &lt;em&gt;“neural network”&lt;/em&gt; makes it sound like something extremely complex, and honestly, once you start looking at layers, weights, activation functions, forward propagation, backpropagation, and optimization, it can become overwhelming pretty quickly.&lt;/p&gt;

&lt;p&gt;But beneath all of that mathematics and code is a surprisingly simple idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A neural network learns patterns from data by adjusting itself based on its mistakes.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That idea is what made neural networks interesting to me.&lt;/p&gt;

&lt;p&gt;As I continue exploring data science and machine learning, understanding neural networks has helped me see machine learning from a different perspective. Instead of simply telling a computer what rules to follow, we can give it data and allow it to learn patterns that may be difficult for us to define manually.&lt;/p&gt;

&lt;p&gt;In this article, I'll break down where the inspiration for neural networks came from, what they are, and the major components that make them work.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where Did Neural Networks Come From?
&lt;/h2&gt;

&lt;p&gt;The inspiration behind artificial neural networks comes from something we already have:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the human brain.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our brains contain billions of neurons that communicate with one another. A biological neuron receives signals, processes them, and passes a signal forward when certain conditions are met.&lt;/p&gt;

&lt;p&gt;Artificial neural networks don't replicate the human brain perfectly. Instead, they borrow a simplified idea from how biological neurons work.&lt;/p&gt;

&lt;p&gt;A biological neuron can be thought of roughly as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;receive signals → process them → produce a response&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An artificial neuron follows a similar conceptual process:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;receive inputs → calculate a weighted sum → apply an activation function → produce an output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This was one of the things I found interesting when learning about neural networks.&lt;/p&gt;

&lt;p&gt;The goal isn't to recreate the brain inside a computer.&lt;/p&gt;

&lt;p&gt;The goal is to take a useful idea from biology and turn it into a mathematical model that can learn from data.&lt;/p&gt;




&lt;h2&gt;
  
  
  So, What Exactly Is a Neural Network?
&lt;/h2&gt;

&lt;p&gt;A neural network is a machine learning model made up of interconnected nodes, commonly called &lt;strong&gt;neurons&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These neurons are organized into layers.&lt;/p&gt;

&lt;p&gt;A basic neural network usually contains:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Input layer&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One or more hidden layers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Output layer&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A simple representation looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input Layer        Hidden Layer        Output Layer

   x₁  ─────────►    ○
                    │
   x₂  ─────────►    ○ ─────────►     ŷ
                    │
   x₃  ─────────►    ○
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The input layer receives the data.&lt;/p&gt;

&lt;p&gt;The hidden layers transform the data and learn patterns.&lt;/p&gt;

&lt;p&gt;The output layer produces the final prediction.&lt;/p&gt;

&lt;p&gt;The interesting part is that we don't manually program the network to recognize every possible pattern.&lt;/p&gt;

&lt;p&gt;Instead, the network learns the parameters needed to recognize those patterns from examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Input Layer
&lt;/h2&gt;

&lt;p&gt;Everything starts with the input.&lt;/p&gt;

&lt;p&gt;Suppose we want to predict whether a student is likely to pass an exam.&lt;/p&gt;

&lt;p&gt;Our dataset might contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hours studied&lt;/li&gt;
&lt;li&gt;Attendance&lt;/li&gt;
&lt;li&gt;Previous test scores&lt;/li&gt;
&lt;li&gt;Assignment completion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These become our input features.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hours Studied     = 6
Attendance        = 85%
Previous Score    = 72
Assignments       = 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The neural network receives these values through the input layer.&lt;/p&gt;

&lt;p&gt;One important thing I learned is that neural networks generally work best when the input data has been appropriately prepared.&lt;/p&gt;

&lt;p&gt;That can involve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handling missing values&lt;/li&gt;
&lt;li&gt;Encoding categorical variables&lt;/li&gt;
&lt;li&gt;Scaling numerical features&lt;/li&gt;
&lt;li&gt;Removing irrelevant features&lt;/li&gt;
&lt;li&gt;Splitting data into training and testing sets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So even though neural networks are powerful, &lt;strong&gt;data preparation still matters.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Garbage in can still mean garbage out.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Neurons
&lt;/h3&gt;

&lt;p&gt;The basic building block of a neural network is the &lt;strong&gt;artificial neuron&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A neuron takes several inputs, assigns different importance to them using weights, adds a bias, and then passes the result through an activation function.&lt;/p&gt;

&lt;p&gt;Mathematically, we can represent this as:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
z = w_1x_1 + w_2x_2 + ... + w_nx_n + b&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(x) = input&lt;/li&gt;
&lt;li&gt;(w) = weight&lt;/li&gt;
&lt;li&gt;(b) = bias&lt;/li&gt;
&lt;li&gt;(z) = weighted sum&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The neuron then applies an activation function:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
a = f(z)&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The result becomes the neuron's output.&lt;/p&gt;

&lt;p&gt;This might look complicated initially, but the basic idea is straightforward:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neuron combines information from its inputs and decides how strongly to activate.&lt;/strong&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  3. Weights
&lt;/h3&gt;

&lt;p&gt;Weights determine how important different inputs are to a neuron.&lt;/p&gt;

&lt;p&gt;Imagine we're predicting whether a student will pass.&lt;/p&gt;

&lt;p&gt;Perhaps hours studied is more predictive than the number of assignments completed.&lt;/p&gt;

&lt;p&gt;The network can learn this by assigning different weights to those features.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hours studied       → weight = 0.8
Attendance          → weight = 0.5
Previous score      → weight = 0.9
Assignments         → weight = 0.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These numbers are only examples.&lt;/p&gt;

&lt;p&gt;During training, the neural network continuously adjusts its weights to improve its predictions.&lt;/p&gt;

&lt;p&gt;This is one of the key ideas behind learning in neural networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The model isn't explicitly told what the correct weights are. It learns them from data.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Bias
&lt;/h3&gt;

&lt;p&gt;Another component is the &lt;strong&gt;bias&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Bias gives the neuron some flexibility in determining when it should activate.&lt;/p&gt;

&lt;p&gt;Without going too deep into the mathematics, you can think of the bias as an additional parameter that allows the activation function to shift.&lt;/p&gt;

&lt;p&gt;The basic equation becomes:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
z = wx + b&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;The weights control the influence of the inputs, while the bias helps adjust the overall output.&lt;/p&gt;

&lt;p&gt;Both weights and biases are learned during training.&lt;/p&gt;


&lt;h3&gt;
  
  
  5. Activation Functions
&lt;/h3&gt;

&lt;p&gt;This was one of the concepts that really helped me understand why neural networks can learn complex patterns.&lt;/p&gt;

&lt;p&gt;After calculating the weighted sum, a neuron applies an &lt;strong&gt;activation function&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because without activation functions, stacking multiple layers of neurons would still result in a fundamentally linear transformation.&lt;/p&gt;

&lt;p&gt;Activation functions introduce &lt;strong&gt;non-linearity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And real-world data is rarely perfectly linear.&lt;/p&gt;

&lt;p&gt;Some commonly used activation functions include:&lt;/p&gt;
&lt;h4&gt;
  
  
  Sigmoid
&lt;/h4&gt;

&lt;p&gt;The sigmoid function produces values between 0 and 1.&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
\sigma(x) = \frac{1}{1 + e^{-x}}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;This makes it useful in certain binary classification problems, particularly as an output activation.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0.91 → high probability of class 1
0.12 → low probability of class 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  ReLU
&lt;/h4&gt;

&lt;p&gt;ReLU stands for &lt;strong&gt;Rectified Linear Unit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is defined as:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
ReLU(x) = \max(0,x)&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = -3 → 0
x =  2 → 2
x =  7 → 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ReLU became particularly important in deep learning because it is simple and computationally efficient and helps neural networks model nonlinear relationships.&lt;/p&gt;




&lt;h4&gt;
  
  
  Softmax
&lt;/h4&gt;

&lt;p&gt;Softmax is commonly used in the output layer for multi-class classification.&lt;/p&gt;

&lt;p&gt;Suppose we're classifying an image as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cat
Dog
Bird
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Softmax can convert the model's outputs into probabilities that sum to 1.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Cat  → 0.10
Dog  → 0.82
Bird → 0.08
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model would predict &lt;strong&gt;Dog&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  6. Hidden Layers
&lt;/h3&gt;

&lt;p&gt;Now we get to one of the most important parts of a neural network.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;hidden layers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These layers sit between the input and output layers.&lt;/p&gt;

&lt;p&gt;A network with only a few layers might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input → Hidden → Output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A deeper network could look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input
  ↓
Hidden Layer 1
  ↓
Hidden Layer 2
  ↓
Hidden Layer 3
  ↓
Hidden Layer 4
  ↓
Output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each layer can learn different representations of the data.&lt;/p&gt;

&lt;p&gt;This is where the term &lt;strong&gt;deep learning&lt;/strong&gt; comes from.&lt;/p&gt;

&lt;p&gt;A neural network with many hidden layers is generally described as a deep neural network.&lt;/p&gt;

&lt;p&gt;The interesting part is that the network can learn increasingly complex representations as information moves through the layers.&lt;/p&gt;

&lt;p&gt;For example, in an image recognition task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pixels
  ↓
Edges
  ↓
Shapes
  ↓
Patterns
  ↓
Objects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The network isn't necessarily programmed with these exact rules.&lt;/p&gt;

&lt;p&gt;It learns useful representations from the training data.&lt;/p&gt;




&lt;h3&gt;
  
  
  7. Forward Propagation
&lt;/h3&gt;

&lt;p&gt;So how does a neural network actually make a prediction?&lt;/p&gt;

&lt;p&gt;This happens through &lt;strong&gt;forward propagation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The input data moves through the network from the input layer toward the output layer.&lt;/p&gt;

&lt;p&gt;At each neuron:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inputs are multiplied by weights.&lt;/li&gt;
&lt;li&gt;The results are added together.&lt;/li&gt;
&lt;li&gt;A bias is added.&lt;/li&gt;
&lt;li&gt;An activation function is applied.&lt;/li&gt;
&lt;li&gt;The result is passed to the next layer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Eventually, the network produces a prediction.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input
  ↓
Weighted Sum
  ↓
Activation
  ↓
Next Layer
  ↓
Weighted Sum
  ↓
Activation
  ↓
Prediction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This happens extremely quickly when implemented computationally.&lt;/p&gt;




&lt;h3&gt;
  
  
  8. Loss Functions
&lt;/h3&gt;

&lt;p&gt;The network makes a prediction.&lt;/p&gt;

&lt;p&gt;But how does it know whether the prediction is good or bad?&lt;/p&gt;

&lt;p&gt;This is where the &lt;strong&gt;loss function&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;p&gt;A loss function measures the difference between the model's prediction and the actual target.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Actual value      = 1
Predicted value   = 0.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a significant difference.&lt;/p&gt;

&lt;p&gt;The loss function quantifies that error.&lt;/p&gt;

&lt;p&gt;Different problems use different loss functions.&lt;/p&gt;

&lt;p&gt;Some common examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mean Squared Error (MSE)&lt;/li&gt;
&lt;li&gt;Binary Cross-Entropy&lt;/li&gt;
&lt;li&gt;Categorical Cross-Entropy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The general goal during training is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Minimize the loss.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  9. Backpropagation
&lt;/h3&gt;

&lt;p&gt;This is probably one of the most important concepts in neural networks.&lt;/p&gt;

&lt;p&gt;After making a prediction and calculating the loss, the network needs to figure out:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which weights contributed to the error, and how should they change?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;backpropagation&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;p&gt;The error is propagated backward through the network.&lt;/p&gt;

&lt;p&gt;Using calculus—particularly the chain rule—the network calculates gradients that indicate how changes in the parameters would affect the loss.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Prediction
    ↓
Calculate Loss
    ↓
Propagate Error Backward
    ↓
Calculate Gradients
    ↓
Update Weights
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the process repeats.&lt;/p&gt;

&lt;p&gt;Again.&lt;/p&gt;

&lt;p&gt;And again.&lt;/p&gt;

&lt;p&gt;And again.&lt;/p&gt;

&lt;p&gt;This is how the neural network gradually improves.&lt;/p&gt;




&lt;h3&gt;
  
  
  10. Optimizers
&lt;/h3&gt;

&lt;p&gt;Backpropagation tells us how the parameters should change.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;optimizer&lt;/strong&gt; determines how those changes are actually made.&lt;/p&gt;

&lt;p&gt;One of the most well-known optimization algorithms is &lt;strong&gt;Gradient Descent&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The basic idea is to move the model's parameters in a direction that reduces the loss.&lt;/p&gt;

&lt;p&gt;A simplified update rule looks like:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
w_{new} = w_{old} - \eta \frac{\partial L}{\partial w}&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(w) = weight&lt;/li&gt;
&lt;li&gt;(\eta) = learning rate&lt;/li&gt;
&lt;li&gt;(L) = loss&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The learning rate controls how large each update should be.&lt;/p&gt;

&lt;p&gt;If the learning rate is too large, the model may overshoot useful solutions.&lt;/p&gt;

&lt;p&gt;If it is too small, training may take a very long time.&lt;/p&gt;

&lt;p&gt;Other optimizers include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adam&lt;/li&gt;
&lt;li&gt;RMSprop&lt;/li&gt;
&lt;li&gt;Adagrad&lt;/li&gt;
&lt;li&gt;SGD with momentum&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adam is particularly common in practical deep learning applications.&lt;/p&gt;


&lt;h3&gt;
  
  
  11. Epochs and Batches
&lt;/h3&gt;

&lt;p&gt;Neural networks don't normally learn from the entire dataset in a single step.&lt;/p&gt;

&lt;p&gt;Instead, training data is often divided into smaller groups called &lt;strong&gt;batches&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, if we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10,000 training samples
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we might use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Batch size = 32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The network processes 32 samples at a time.&lt;/p&gt;

&lt;p&gt;Once it has processed the entire training dataset, we have completed one &lt;strong&gt;epoch&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dataset
   ↓
Batch 1
Batch 2
Batch 3
...
Batch N
   ↓
One Epoch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model typically trains for multiple epochs.&lt;/p&gt;




&lt;h3&gt;
  
  
  12. Learning Rate
&lt;/h3&gt;

&lt;p&gt;The learning rate determines how aggressively the model updates its parameters.&lt;/p&gt;

&lt;p&gt;Think of it as the size of the steps the model takes while trying to minimize its loss.&lt;/p&gt;

&lt;p&gt;A very large learning rate might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Too large
    ↓
Overshoot
    ↓
Unstable training
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A very small learning rate might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Too small
    ↓
Tiny updates
    ↓
Very slow learning
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finding an appropriate learning rate can make a significant difference in training performance.&lt;/p&gt;




&lt;h3&gt;
  
  
  13. Training, Validation, and Testing
&lt;/h3&gt;

&lt;p&gt;Another important concept is understanding how we evaluate a neural network.&lt;/p&gt;

&lt;p&gt;We generally don't want to train and evaluate the model on exactly the same data.&lt;/p&gt;

&lt;p&gt;Instead, data can be divided into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dataset
   │
   ├── Training Data
   │
   ├── Validation Data
   │
   └── Test Data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Training data
&lt;/h4&gt;

&lt;p&gt;Used to learn the model's parameters.&lt;/p&gt;

&lt;h4&gt;
  
  
  Validation data
&lt;/h4&gt;

&lt;p&gt;Used to monitor performance and help with choices such as hyperparameters and model architecture.&lt;/p&gt;

&lt;h4&gt;
  
  
  Test data
&lt;/h4&gt;

&lt;p&gt;Used to evaluate how well the final model performs on unseen data.&lt;/p&gt;

&lt;p&gt;This is important because a model can perform extremely well on its training data but poorly on new data.&lt;/p&gt;

&lt;p&gt;That brings us to one of the biggest challenges in machine learning.&lt;/p&gt;




&lt;h3&gt;
  
  
  14. Overfitting
&lt;/h3&gt;

&lt;p&gt;A neural network can become &lt;strong&gt;too good at memorizing the training data&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is known as overfitting.&lt;/p&gt;

&lt;p&gt;Imagine studying for an exam by memorizing the answers to last year's exact questions.&lt;/p&gt;

&lt;p&gt;You might perform extremely well if the same questions appear.&lt;/p&gt;

&lt;p&gt;But if the questions change, your performance may drop.&lt;/p&gt;

&lt;p&gt;A similar thing can happen with machine learning models.&lt;/p&gt;

&lt;p&gt;The model learns the training examples extremely well but fails to generalize to unseen data.&lt;/p&gt;

&lt;p&gt;Some techniques used to reduce overfitting include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dropout&lt;/li&gt;
&lt;li&gt;Regularization&lt;/li&gt;
&lt;li&gt;Early stopping&lt;/li&gt;
&lt;li&gt;Data augmentation&lt;/li&gt;
&lt;li&gt;More training data&lt;/li&gt;
&lt;li&gt;Simpler model architectures&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Why Are Neural Networks So Powerful?
&lt;/h4&gt;

&lt;p&gt;What makes neural networks particularly interesting is their ability to learn &lt;strong&gt;nonlinear relationships and complex representations&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Traditional programming often looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rules + Data → Output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Machine learning changes the approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Data + Expected Outputs → Learned Rules
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And neural networks take this further by learning multiple levels of representation.&lt;/p&gt;

&lt;p&gt;This is why they have become so useful in areas such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Computer vision&lt;/li&gt;
&lt;li&gt;Natural language processing&lt;/li&gt;
&lt;li&gt;Speech recognition&lt;/li&gt;
&lt;li&gt;Recommendation systems&lt;/li&gt;
&lt;li&gt;Time-series forecasting&lt;/li&gt;
&lt;li&gt;Fraud detection&lt;/li&gt;
&lt;li&gt;Medical imaging&lt;/li&gt;
&lt;li&gt;Generative AI&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  From Neural Networks to Deep Learning
&lt;/h4&gt;

&lt;p&gt;A neural network with many layers is generally referred to as a &lt;strong&gt;deep neural network&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Deep learning is essentially about using these deeper architectures to learn increasingly complex representations from data.&lt;/p&gt;

&lt;p&gt;This has led to architectures designed for different kinds of problems.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;h4&gt;
  
  
  Convolutional Neural Networks (CNNs)
&lt;/h4&gt;

&lt;p&gt;Often associated with image and computer vision tasks.&lt;/p&gt;

&lt;h4&gt;
  
  
  Recurrent Neural Networks (RNNs)
&lt;/h4&gt;

&lt;p&gt;Designed to work with sequential data, although many modern sequence tasks now use transformer-based architectures instead.&lt;/p&gt;

&lt;h4&gt;
  
  
  Transformers
&lt;/h4&gt;

&lt;p&gt;Transformers have become extremely important in modern AI, particularly for language and other sequence-based problems.&lt;/p&gt;

&lt;p&gt;They power many of the systems behind today's generative AI applications.&lt;/p&gt;




&lt;h3&gt;
  
  
  What I Take Away From Learning Neural Networks
&lt;/h3&gt;

&lt;p&gt;One thing I appreciate about neural networks is that they changed how I think about machine learning.&lt;/p&gt;

&lt;p&gt;At first, the equations can make the subject feel intimidating.&lt;/p&gt;

&lt;p&gt;You see:&lt;/p&gt;

&lt;p&gt;$$&lt;br&gt;
z = wx+b&lt;br&gt;
$$&lt;/p&gt;

&lt;p&gt;then activation functions, gradients, derivatives, optimization algorithms, layers, epochs, and suddenly it feels like you're drowning in mathematics.&lt;/p&gt;

&lt;p&gt;But when you break the process down, the basic idea becomes much easier to understand.&lt;/p&gt;

&lt;p&gt;A neural network:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;takes data → makes a prediction → measures its error → adjusts itself → tries again.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That cycle is at the heart of learning.&lt;/p&gt;

&lt;p&gt;And I think that's the part that makes neural networks so fascinating.&lt;/p&gt;




&lt;h4&gt;
  
  
  Final Thoughts
&lt;/h4&gt;

&lt;p&gt;I'm still learning neural networks, and I don't think understanding them means memorizing every equation or being able to build a state-of-the-art architecture from scratch.&lt;/p&gt;

&lt;p&gt;For me, understanding the fundamentals is more important.&lt;/p&gt;

&lt;p&gt;I want to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is happening to the data?&lt;/li&gt;
&lt;li&gt;Why do we need weights?&lt;/li&gt;
&lt;li&gt;What does a bias actually do?&lt;/li&gt;
&lt;li&gt;Why do we need activation functions?&lt;/li&gt;
&lt;li&gt;How does the model know that it made a mistake?&lt;/li&gt;
&lt;li&gt;How does backpropagation help?&lt;/li&gt;
&lt;li&gt;What does an optimizer actually change?&lt;/li&gt;
&lt;li&gt;How do we know whether the model is learning or simply memorizing?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once these pieces start fitting together, neural networks stop looking like a mysterious black box.&lt;/p&gt;

&lt;p&gt;They become a collection of understandable ideas working together.&lt;/p&gt;

&lt;p&gt;And that's probably the most important lesson I've taken from studying them so far:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Complex models become much less intimidating when you understand the simple ideas underneath them.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'm still on that learning journey and neural networks are definitely one of the areas I'm excited to explore more deeply.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>deeplearning</category>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Using Scikit-Learn Pipelines: A Cleaner Way to Build Machine Learning Models</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Fri, 28 Aug 2026 17:49:57 +0000</pubDate>
      <link>https://dev.to/audrine_m/using-scikit-learn-pipelines-a-cleaner-way-to-build-machine-learning-models-2moh</link>
      <guid>https://dev.to/audrine_m/using-scikit-learn-pipelines-a-cleaner-way-to-build-machine-learning-models-2moh</guid>
      <description>&lt;p&gt;If you've spent some time building machine learning models with Python, you've probably had a notebook that looked something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;X_train&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;X_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;predictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then a few cells later, you realize you also need to encode categorical variables.&lt;/p&gt;

&lt;p&gt;Then there's imputation.&lt;/p&gt;

&lt;p&gt;Then feature selection.&lt;/p&gt;

&lt;p&gt;Then maybe PCA.&lt;/p&gt;

&lt;p&gt;Before you know it, your notebook has a collection of preprocessing steps that depend on being executed in exactly the right order.&lt;/p&gt;

&lt;p&gt;I've been there.&lt;/p&gt;

&lt;p&gt;One of the things that made my machine learning workflow much cleaner was learning how to use &lt;strong&gt;Scikit-Learn Pipelines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this article, I'll walk through what pipelines are, why they matter, and how I use them to make machine learning workflows more reliable and easier to maintain.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a Scikit-Learn Pipeline?
&lt;/h2&gt;

&lt;p&gt;A pipeline is essentially a way of connecting multiple machine learning steps together so that they can be treated as &lt;strong&gt;one workflow&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, suppose we have a dataset where we need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Handle missing values&lt;/li&gt;
&lt;li&gt;Scale numerical features&lt;/li&gt;
&lt;li&gt;Train a machine learning model&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of doing everything separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;X_train&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;imputer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;X_train&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can put everything into a pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pipeline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.impute&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SimpleImputer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.linear_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LogisticRegression&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the entire process is represented by one object.&lt;/p&gt;

&lt;p&gt;And that's the part I really like about pipelines.&lt;/p&gt;

&lt;p&gt;Instead of thinking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"First I need to do this, then this, then this..."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;you can think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This is my machine learning workflow."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Why Should We Use Pipelines?
&lt;/h3&gt;

&lt;p&gt;At first, pipelines can feel like extra syntax.&lt;/p&gt;

&lt;p&gt;Why not just preprocess the data manually?&lt;/p&gt;

&lt;p&gt;You absolutely can.&lt;/p&gt;

&lt;p&gt;But pipelines solve several important problems.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. They reduce data leakage
&lt;/h4&gt;

&lt;p&gt;This is probably the biggest reason to use them.&lt;/p&gt;

&lt;p&gt;Imagine you're scaling your dataset before splitting it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;scaler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;X_scaled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;train_test_split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;X_scaled&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It looks harmless.&lt;/p&gt;

&lt;p&gt;But there's a problem.&lt;/p&gt;

&lt;p&gt;The scaler has seen the entire dataset, including the test set.&lt;/p&gt;

&lt;p&gt;That means information from your test data has influenced the preprocessing step.&lt;/p&gt;

&lt;p&gt;This is a form of &lt;strong&gt;data leakage&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The model hasn't technically seen the test labels, but information about the distribution of the test features has already entered the training process.&lt;/p&gt;

&lt;p&gt;A pipeline helps prevent this when used correctly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During &lt;code&gt;fit()&lt;/code&gt;, the scaler learns its parameters only from &lt;code&gt;X_train&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When we evaluate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the same fitted scaler transforms &lt;code&gt;X_test&lt;/code&gt; without learning anything new from it.&lt;/p&gt;

&lt;p&gt;That separation is extremely important.&lt;/p&gt;




&lt;h4&gt;
  
  
  2. Pipelines Keep Preprocessing and Modeling Together
&lt;/h4&gt;

&lt;p&gt;Without a pipeline, you might end up with something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;imputer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;scaler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;X_train&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;imputer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;X_train&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, when making predictions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;X_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;imputer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;X_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;predictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the problem?&lt;/p&gt;

&lt;p&gt;You have to remember the exact preprocessing sequence.&lt;/p&gt;

&lt;p&gt;With a pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you simply do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;predictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much cleaner.&lt;/p&gt;




&lt;h4&gt;
  
  
  3. Pipelines Make Cross-Validation Safer
&lt;/h4&gt;

&lt;p&gt;This is another major advantage.&lt;/p&gt;

&lt;p&gt;Suppose we want to evaluate different models using cross-validation.&lt;/p&gt;

&lt;p&gt;We could create a pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.model_selection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cross_val_score&lt;/span&gt;

&lt;span class="n"&gt;scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cross_val_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;cv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;scoring&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;accuracy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each fold gets its own preprocessing fitted only on that fold's training data.&lt;/p&gt;

&lt;p&gt;This is exactly what we want.&lt;/p&gt;

&lt;p&gt;Without a pipeline, it is easy to accidentally preprocess the entire dataset before cross-validation and introduce leakage.&lt;/p&gt;




&lt;h3&gt;
  
  
  Building a Simple Pipeline
&lt;/h3&gt;

&lt;p&gt;Let's create a slightly more realistic example.&lt;/p&gt;

&lt;p&gt;Imagine we're building a model to predict whether a customer belongs to a particular class.&lt;/p&gt;

&lt;p&gt;Our workflow might be:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Missing values → Scaling → Logistic Regression&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pipeline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.impute&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SimpleImputer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.linear_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LogisticRegression&lt;/span&gt;

&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The names we give each step, such as &lt;code&gt;"imputer"&lt;/code&gt; and &lt;code&gt;"scaler"&lt;/code&gt;, are useful because they allow us to access those individual components later.&lt;/p&gt;

&lt;p&gt;Training becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prediction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;y_pred&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And evaluation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.metrics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;classification_report&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;classification_report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_pred&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the whole workflow.&lt;/p&gt;




&lt;h3&gt;
  
  
  What About Categorical and Numerical Features?
&lt;/h3&gt;

&lt;p&gt;This is where pipelines become even more useful.&lt;/p&gt;

&lt;p&gt;Real-world datasets rarely contain only numerical variables.&lt;/p&gt;

&lt;p&gt;You might have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Age          → numerical
Income       → numerical
Education    → categorical
Gender       → categorical
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We shouldn't necessarily preprocess all of these columns in the same way.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Numerical columns → imputation + scaling&lt;/li&gt;
&lt;li&gt;Categorical columns → imputation + one-hot encoding&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scikit-Learn gives us &lt;code&gt;ColumnTransformer&lt;/code&gt; for exactly this situation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.compose&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ColumnTransformer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pipeline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.impute&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SimpleImputer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OneHotEncoder&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.linear_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LogisticRegression&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's define our columns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;numerical_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;income&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;categorical_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;education&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gender&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we create separate preprocessing pipelines.&lt;/p&gt;

&lt;h4&gt;
  
  
  Numerical pipeline
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;numeric_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Categorical pipeline
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;categorical_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;most_frequent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;encoder&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OneHotEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handle_unknown&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ignore&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we combine them using &lt;code&gt;ColumnTransformer&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;preprocessor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ColumnTransformer&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;num&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numeric_pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numerical_features&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cat&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;categorical_pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;categorical_features&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we connect preprocessing to our model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;preprocessor&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;preprocessor&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have one complete workflow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Raw Data
   ↓
Numerical preprocessing ──┐
                          ├──→ Model
Categorical preprocessing ┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And training is still just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model_pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prediction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;y_pred&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model_pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is much closer to how machine learning workflows look in real projects.&lt;/p&gt;




&lt;h3&gt;
  
  
  Pipelines and Hyperparameter Tuning
&lt;/h3&gt;

&lt;p&gt;Here's where things get even more interesting.&lt;/p&gt;

&lt;p&gt;We can use pipelines with &lt;code&gt;GridSearchCV&lt;/code&gt; to tune both preprocessing and model parameters.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.model_selection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;GridSearchCV&lt;/span&gt;

&lt;span class="n"&gt;param_grid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model__C&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model__max_iter&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;grid_search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;GridSearchCV&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model_pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;param_grid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;cv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;scoring&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;accuracy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;grid_search&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model__C&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The double underscore allows us to access parameters inside pipeline steps.&lt;/p&gt;

&lt;p&gt;If our pipeline contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model__C&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The &lt;code&gt;C&lt;/code&gt; parameter belonging to the &lt;code&gt;model&lt;/code&gt; step."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We can then check the best parameters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grid_search&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;best_params_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And use the best estimator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;best_model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;grid_search&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;best_estimator_&lt;/span&gt;

&lt;span class="n"&gt;predictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;best_model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes experimentation much more systematic.&lt;/p&gt;




&lt;h3&gt;
  
  
  Pipelines Are Not Just for Classification
&lt;/h3&gt;

&lt;p&gt;Pipelines work across many Scikit-Learn workflows.&lt;/p&gt;

&lt;p&gt;For example, regression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.ensemble&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RandomForestRegressor&lt;/span&gt;

&lt;span class="n"&gt;regression_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;RandomForestRegressor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or clustering:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.cluster&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;KMeans&lt;/span&gt;

&lt;span class="n"&gt;clustering_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;KMeans&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_clusters&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same basic idea applies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Preprocessing
     ↓
Transformation
     ↓
Model / Algorithm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  One Important Thing I Learned
&lt;/h3&gt;

&lt;p&gt;One mistake that's easy to make when learning pipelines is assuming that &lt;strong&gt;every model needs every preprocessing step&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It doesn't.&lt;/p&gt;

&lt;p&gt;For example, scaling is generally important for algorithms that are sensitive to feature magnitude, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logistic Regression&lt;/li&gt;
&lt;li&gt;KNN&lt;/li&gt;
&lt;li&gt;SVM&lt;/li&gt;
&lt;li&gt;K-Means&lt;/li&gt;
&lt;li&gt;PCA&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But tree-based models such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Decision Trees&lt;/li&gt;
&lt;li&gt;Random Forest&lt;/li&gt;
&lt;li&gt;Gradient Boosting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;generally don't require feature scaling.&lt;/p&gt;

&lt;p&gt;So don't build pipelines mechanically.&lt;/p&gt;

&lt;p&gt;Think about what your algorithm actually needs.&lt;/p&gt;




&lt;h3&gt;
  
  
  Pipelines Make Your Code More Reproducible
&lt;/h3&gt;

&lt;p&gt;There's another benefit that isn't always obvious when you're first learning machine learning.&lt;/p&gt;

&lt;p&gt;A pipeline makes your workflow easier for someone else to reproduce.&lt;/p&gt;

&lt;p&gt;Imagine handing someone this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compared with giving them five different preprocessing scripts and telling them:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Run this first, then this, then remember to use the same scaler when predicting."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The pipeline communicates the workflow much more clearly.&lt;/p&gt;

&lt;p&gt;This becomes especially useful when working on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Team projects&lt;/li&gt;
&lt;li&gt;Research projects&lt;/li&gt;
&lt;li&gt;Production ML systems&lt;/li&gt;
&lt;li&gt;GitHub projects&lt;/li&gt;
&lt;li&gt;Machine learning competitions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also makes your notebooks less cluttered.&lt;/p&gt;

&lt;p&gt;And honestly, once you start working with several models, that becomes a big deal.&lt;/p&gt;




&lt;h3&gt;
  
  
  A Complete Example
&lt;/h3&gt;

&lt;p&gt;Here's a compact example putting everything together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.model_selection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;train_test_split&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.compose&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ColumnTransformer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pipeline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.impute&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SimpleImputer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OneHotEncoder&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.linear_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LogisticRegression&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.metrics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;classification_report&lt;/span&gt;


&lt;span class="c1"&gt;#### Load data
&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;customer_data.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Separate features and target
&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;target&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;target&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;#### Define feature types
&lt;/span&gt;&lt;span class="n"&gt;numeric_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;income&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;categorical_features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gender&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;education&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;#### Numerical preprocessing
&lt;/span&gt;&lt;span class="n"&gt;numeric_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;median&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;scaler&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;#### Categorical preprocessing
&lt;/span&gt;&lt;span class="n"&gt;categorical_pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;imputer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpleImputer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;most_frequent&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;encoder&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OneHotEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handle_unknown&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ignore&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;#### Combine preprocessing
&lt;/span&gt;&lt;span class="n"&gt;preprocessor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ColumnTransformer&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;num&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numeric_pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numeric_features&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cat&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;categorical_pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;categorical_features&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;#### Full pipeline
&lt;/span&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;preprocessor&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;preprocessor&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_iter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;#### Split data
&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;train_test_split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;test_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;stratify&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;### Train
&lt;/span&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;### Predict
&lt;/span&gt;&lt;span class="n"&gt;y_pred&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;### Evaluate
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;classification_report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_pred&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I like about this structure is that the code tells a story.&lt;/p&gt;

&lt;p&gt;You can almost read it from top to bottom:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Load → Separate → Preprocess → Build → Split → Train → Predict → Evaluate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's what good ML code should do.&lt;/p&gt;




&lt;h3&gt;
  
  
  When Should You Use Pipelines?
&lt;/h3&gt;

&lt;p&gt;I'd recommend getting comfortable with pipelines as soon as you're moving beyond very simple machine learning exercises.&lt;/p&gt;

&lt;p&gt;They're particularly useful when you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple preprocessing steps&lt;/li&gt;
&lt;li&gt;Missing values&lt;/li&gt;
&lt;li&gt;Categorical variables&lt;/li&gt;
&lt;li&gt;Feature scaling&lt;/li&gt;
&lt;li&gt;Feature selection&lt;/li&gt;
&lt;li&gt;Dimensionality reduction&lt;/li&gt;
&lt;li&gt;Cross-validation&lt;/li&gt;
&lt;li&gt;Hyperparameter tuning&lt;/li&gt;
&lt;li&gt;Multiple models to compare&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even when a pipeline isn't strictly necessary, using one can make your workflow cleaner.&lt;/p&gt;




&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;When I first started working with machine learning workflows, preprocessing felt like a collection of separate tasks.&lt;/p&gt;

&lt;p&gt;Clean the data.&lt;/p&gt;

&lt;p&gt;Encode it.&lt;/p&gt;

&lt;p&gt;Scale it.&lt;/p&gt;

&lt;p&gt;Split it.&lt;/p&gt;

&lt;p&gt;Train the model.&lt;/p&gt;

&lt;p&gt;Then somehow remember to apply the exact same transformations to the test data.&lt;/p&gt;

&lt;p&gt;Scikit-Learn Pipelines changed the way I think about that process.&lt;/p&gt;

&lt;p&gt;A pipeline isn't just a convenient way to shorten your code. It's a way of &lt;strong&gt;defining the entire machine learning workflow as one reproducible object&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And perhaps the biggest lesson is this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Your model is only one part of a machine learning system.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The preprocessing that happens before the model matters just as much.&lt;/p&gt;

&lt;p&gt;Once you start using pipelines, you'll find yourself writing ML code that is cleaner, safer, and much easier to maintain.&lt;/p&gt;

&lt;p&gt;And when you eventually move from Jupyter notebooks to real-world machine learning projects, that habit becomes incredibly valuable.&lt;/p&gt;




&lt;h4&gt;
  
  
  Key Takeaways
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pipeline&lt;/strong&gt; connects preprocessing and modeling into one workflow.&lt;/li&gt;
&lt;li&gt;It helps reduce the risk of &lt;strong&gt;data leakage&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;It makes &lt;strong&gt;cross-validation&lt;/strong&gt; safer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ColumnTransformer&lt;/code&gt; allows different preprocessing for different feature types.&lt;/li&gt;
&lt;li&gt;Pipelines work with &lt;strong&gt;GridSearchCV&lt;/strong&gt; and hyperparameter tuning.&lt;/li&gt;
&lt;li&gt;They improve &lt;strong&gt;reproducibility and maintainability&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Not every algorithm needs the same preprocessing, so build your pipeline based on the model you're using.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're learning Scikit-Learn right now, pipelines are one of those concepts I'd strongly recommend getting comfortable with early. They might seem like extra structure at first, but once your projects become more complicated, you'll be very glad you have them.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>beginners</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Unsupervised Learning: Teaching Machines to Find the Patterns We Didn't Know Were There</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Fri, 21 Aug 2026 18:43:10 +0000</pubDate>
      <link>https://dev.to/audrine_m/unsupervised-learning-teaching-machines-to-find-the-patterns-we-didnt-know-were-there-m9i</link>
      <guid>https://dev.to/audrine_m/unsupervised-learning-teaching-machines-to-find-the-patterns-we-didnt-know-were-there-m9i</guid>
      <description>&lt;p&gt;When I first started learning machine learning, I naturally gravitated toward supervised learning.&lt;/p&gt;

&lt;p&gt;It made sense.&lt;/p&gt;

&lt;p&gt;Give the model some data, tell it what the correct answer is, train it to recognize the relationship, and then use it to make predictions.&lt;/p&gt;

&lt;p&gt;But eventually I came across a different question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when we don't have the answers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What if our dataset doesn't have a target column telling us what each observation is?&lt;/p&gt;

&lt;p&gt;What if, instead of asking a model to predict something, we want it to help us &lt;strong&gt;discover what is already hiding inside the data&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;That is where unsupervised learning becomes interesting.&lt;/p&gt;




&lt;h3&gt;
  
  
  So, what exactly is unsupervised learning?
&lt;/h3&gt;

&lt;p&gt;Unsupervised learning is a branch of machine learning where algorithms work with data &lt;strong&gt;without predefined target labels&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of learning:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"These are the correct answers. Learn to predict them."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;we essentially say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Here is the data. Find something interesting."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The algorithm looks for patterns, similarities, structures, relationships, or unusual observations within the data.&lt;/p&gt;

&lt;p&gt;This can be incredibly useful because real-world datasets don't always come neatly labeled.&lt;/p&gt;

&lt;p&gt;Imagine having thousands of customers but no column saying:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer type A&lt;/li&gt;
&lt;li&gt;Customer type B&lt;/li&gt;
&lt;li&gt;Customer type C&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, you might have information about their income, spending habits, transaction frequency, savings, age, and other characteristics.&lt;/p&gt;

&lt;p&gt;You can use unsupervised learning to investigate whether naturally occurring groups exist.&lt;/p&gt;

&lt;p&gt;And this is one of the things I find most interesting about it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The model isn't necessarily confirming what we already know. It can help us discover what we didn't know to look for.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Main Families of Unsupervised Learning
&lt;/h2&gt;

&lt;p&gt;Unsupervised learning isn't just one algorithm.&lt;/p&gt;

&lt;p&gt;It is more useful to think of it as a collection of approaches designed to answer different questions.&lt;/p&gt;

&lt;p&gt;Some of the major categories include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Clustering&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dimensionality reduction&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Density estimation&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Anomaly/outlier detection&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mixture models&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Matrix factorization and decomposition&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's break these down.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Clustering
&lt;/h3&gt;

&lt;p&gt;Clustering is probably the first thing most people encounter when learning unsupervised learning.&lt;/p&gt;

&lt;p&gt;The goal is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Group observations that are similar to each other.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose I have customer data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer    Income    Spending    Savings
A           30,000    8,000       5,000
B           32,000    7,500       4,800
C           90,000    25,000      30,000
D           95,000    28,000      35,000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is no target telling us which customers belong together.&lt;/p&gt;

&lt;p&gt;A clustering algorithm might discover that A and B are quite similar, while C and D form another group.&lt;/p&gt;

&lt;p&gt;That's the basic idea.&lt;/p&gt;

&lt;p&gt;There are several clustering algorithms, and they don't all define "similarity" in the same way.&lt;/p&gt;

&lt;h4&gt;
  
  
  K-Means
&lt;/h4&gt;

&lt;p&gt;K-Means is probably the most recognizable clustering algorithm.&lt;/p&gt;

&lt;p&gt;The basic idea is to divide observations into &lt;strong&gt;K clusters&lt;/strong&gt;, with each observation assigned to the cluster whose center is closest according to the algorithm's objective.&lt;/p&gt;

&lt;p&gt;One of the first things I learned with K-Means was that choosing K isn't as simple as saying:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;K&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and moving on.&lt;/p&gt;

&lt;p&gt;You need to investigate whether that number of clusters actually makes sense.&lt;/p&gt;

&lt;p&gt;Two common techniques are the:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Elbow Method&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Silhouette Score&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Elbow Method looks at how the within-cluster sum of squares changes as K increases.&lt;/p&gt;

&lt;p&gt;The silhouette score evaluates how well observations fit within their assigned cluster compared with neighboring clusters.&lt;/p&gt;

&lt;p&gt;This is an important lesson with clustering:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The algorithm can create clusters, but that doesn't automatically mean the clusters are meaningful.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;K-Means works particularly well when clusters have relatively simple, compact geometry, but it can struggle with irregularly shaped clusters. (&lt;a href="https://github.com/scikit-learn/scikit-learn/blob/main/doc/modules/clustering.rst?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;)&lt;/p&gt;




&lt;h2&gt;
  
  
  Hierarchical Clustering
&lt;/h2&gt;

&lt;p&gt;Another approach I find particularly interesting is hierarchical clustering.&lt;/p&gt;

&lt;p&gt;Instead of simply producing a flat set of clusters, hierarchical clustering builds a hierarchy of relationships between observations.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;agglomerative hierarchical clustering&lt;/strong&gt;, every observation starts as its own cluster. The algorithm progressively merges similar clusters until everything is eventually part of one large cluster. (&lt;a href="https://sklearn.org/stable/modules/clustering.html?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;scikit-learn&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The result can be visualized using a &lt;strong&gt;dendrogram&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The dendrogram allows us to look at the different levels at which observations or groups merge and decide where we might "cut" the hierarchy.&lt;/p&gt;

&lt;p&gt;This makes hierarchical clustering particularly useful when I want to understand not just &lt;em&gt;which observations are grouped together&lt;/em&gt;, but also &lt;strong&gt;how those groups relate to one another&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  DBSCAN
&lt;/h3&gt;

&lt;p&gt;Not every dataset naturally forms neat circular or compact groups.&lt;/p&gt;

&lt;p&gt;This is where algorithms such as &lt;strong&gt;DBSCAN&lt;/strong&gt; become useful.&lt;/p&gt;

&lt;p&gt;DBSCAN is a density-based clustering algorithm.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How many clusters should I create?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;it looks for areas where observations are densely packed together.&lt;/p&gt;

&lt;p&gt;One advantage is that it can identify clusters with more irregular shapes and can also identify observations that don't belong to dense regions.&lt;/p&gt;

&lt;p&gt;That makes it particularly interesting for datasets where unusual observations are part of the problem rather than something we simply want to remove.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Dimensionality Reduction
&lt;/h3&gt;

&lt;p&gt;Now let's say my dataset has 100 features.&lt;/p&gt;

&lt;p&gt;Trying to visualize or work with all 100 dimensions isn't exactly convenient.&lt;/p&gt;

&lt;p&gt;This is where dimensionality reduction comes in.&lt;/p&gt;

&lt;p&gt;The goal is to represent high-dimensional data using fewer dimensions while attempting to preserve useful information or structure.&lt;/p&gt;

&lt;p&gt;One of the most widely used approaches is &lt;strong&gt;Principal Component Analysis (PCA)&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  PCA
&lt;/h3&gt;

&lt;p&gt;PCA transforms the original features into a smaller number of new variables called &lt;strong&gt;principal components&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The first component captures as much of the variance in the data as possible, followed by subsequent components capturing additional variance subject to the method's constraints. (&lt;a href="https://scikit-learn.org/1.9/modules/unsupervised_reduction.html?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Scikit-learn&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.decomposition&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PCA&lt;/span&gt;

&lt;span class="n"&gt;pca&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PCA&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_components&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;X_pca&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pca&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_scaled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now a dataset with many features can be represented using two principal components.&lt;/p&gt;

&lt;p&gt;Why is this useful?&lt;/p&gt;

&lt;p&gt;One reason is visualization.&lt;/p&gt;

&lt;p&gt;I can plot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Principal Component 1
        vs.
Principal Component 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and potentially see structures that were difficult to observe in the original feature space.&lt;/p&gt;

&lt;p&gt;PCA can also be useful before other machine-learning techniques when a dataset has many features.&lt;/p&gt;

&lt;p&gt;But there is an important caveat:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PCA doesn't magically make information disappear without consequences.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Reducing dimensions means making a trade-off between simplicity and information retention.&lt;/p&gt;




&lt;h3&gt;
  
  
  t-SNE
&lt;/h3&gt;

&lt;p&gt;Another dimensionality-reduction technique you'll often encounter is &lt;strong&gt;t-SNE&lt;/strong&gt; — t-distributed Stochastic Neighbor Embedding.&lt;/p&gt;

&lt;p&gt;Unlike PCA, which focuses on preserving variance through linear transformations, t-SNE is primarily useful for visualizing complex high-dimensional relationships.&lt;/p&gt;

&lt;p&gt;It is particularly popular for creating 2D or 3D visualizations of high-dimensional data.&lt;/p&gt;

&lt;p&gt;However, I wouldn't treat a t-SNE plot as proof that a particular number of clusters exists.&lt;/p&gt;

&lt;p&gt;It's a visualization tool, and its output can be influenced by its parameters and the structure of the data.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Anomaly Detection
&lt;/h2&gt;

&lt;p&gt;Sometimes we're not interested in finding groups.&lt;/p&gt;

&lt;p&gt;We're interested in finding the observations that &lt;strong&gt;don't fit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is anomaly detection.&lt;/p&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fraudulent transactions&lt;/li&gt;
&lt;li&gt;unusual network activity&lt;/li&gt;
&lt;li&gt;abnormal sensor readings&lt;/li&gt;
&lt;li&gt;unusual customer behavior&lt;/li&gt;
&lt;li&gt;manufacturing defects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In these situations, the unusual observation may actually be the most important one.&lt;/p&gt;

&lt;p&gt;Algorithms such as &lt;strong&gt;Isolation Forest&lt;/strong&gt;, &lt;strong&gt;Local Outlier Factor (LOF)&lt;/strong&gt;, and &lt;strong&gt;One-Class SVM&lt;/strong&gt; can be used for different forms of anomaly or novelty detection.&lt;/p&gt;

&lt;p&gt;This is one of the areas where unsupervised learning becomes particularly practical.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What class does this transaction belong to?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;we might ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Does this transaction look unusual compared with the rest?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Scikit-learn treats novelty and outlier detection as a distinct part of its unsupervised-learning toolkit. (&lt;a href="https://scikit-learn.org/stable/unsupervised_learning.html?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Scikit-learn&lt;/a&gt;)&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Gaussian Mixture Models
&lt;/h2&gt;

&lt;p&gt;Another approach is the &lt;strong&gt;Gaussian Mixture Model (GMM)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;At a high level, GMM assumes that the data can be represented as a mixture of several underlying probability distributions.&lt;/p&gt;

&lt;p&gt;This is different from simply assigning every observation to one cluster.&lt;/p&gt;

&lt;p&gt;A GMM can provide probabilities representing how strongly an observation belongs to different components.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer A

Cluster 1: 0.85
Cluster 2: 0.10
Cluster 3: 0.05
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be useful when boundaries between groups aren't perfectly clear.&lt;/p&gt;

&lt;p&gt;Scikit-learn includes both Gaussian Mixture and Variational Bayesian Gaussian Mixture models within its unsupervised-learning tools. (&lt;a href="https://scikit-learn.org/stable/unsupervised_learning.html?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Scikit-learn&lt;/a&gt;)&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Matrix Factorization and Decomposition
&lt;/h2&gt;

&lt;p&gt;Another family of unsupervised methods focuses on breaking complex data into underlying components.&lt;/p&gt;

&lt;p&gt;This includes techniques such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PCA&lt;/li&gt;
&lt;li&gt;Independent Component Analysis (ICA)&lt;/li&gt;
&lt;li&gt;Non-negative Matrix Factorization (NMF)&lt;/li&gt;
&lt;li&gt;Latent Dirichlet Allocation (LDA)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These approaches can be useful when we believe that complicated observations may be explained by a smaller number of underlying factors or components.&lt;/p&gt;

&lt;p&gt;For example, in text analysis, LDA can be used for topic modeling — helping identify groups of words that tend to occur together and may represent underlying topics.&lt;/p&gt;




&lt;h3&gt;
  
  
  So Which Algorithm Should I Use?
&lt;/h3&gt;

&lt;p&gt;This is probably one of the most important questions.&lt;/p&gt;

&lt;p&gt;There isn't one "best" unsupervised learning algorithm.&lt;/p&gt;

&lt;p&gt;The right choice depends on the question you're asking and the structure of your data.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Possible approach&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Find natural groups&lt;/td&gt;
&lt;td&gt;K-Means&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Understand hierarchical relationships&lt;/td&gt;
&lt;td&gt;Hierarchical Clustering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find irregularly shaped dense groups&lt;/td&gt;
&lt;td&gt;DBSCAN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reduce many features&lt;/td&gt;
&lt;td&gt;PCA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Visualize complex high-dimensional data&lt;/td&gt;
&lt;td&gt;t-SNE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find unusual observations&lt;/td&gt;
&lt;td&gt;Isolation Forest / LOF&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Model probabilistic groups&lt;/td&gt;
&lt;td&gt;Gaussian Mixture Models&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Discover latent components/topics&lt;/td&gt;
&lt;td&gt;NMF / LDA / other decomposition methods&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Scikit-learn's own comparison of clustering methods emphasizes that different algorithms make different assumptions about cluster geometry, scalability, and the type of structure they are designed to capture. (&lt;a href="https://github.com/scikit-learn/scikit-learn/blob/main/doc/modules/clustering.rst?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;)&lt;/p&gt;




&lt;h3&gt;
  
  
  What I Have Learned About Unsupervised Learning
&lt;/h3&gt;

&lt;p&gt;One thing that has stood out to me while working through clustering is that &lt;strong&gt;unsupervised learning requires a different mindset&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In supervised learning, evaluation can feel more straightforward.&lt;/p&gt;

&lt;p&gt;You have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Actual value
      ↓
Prediction
      ↓
Compare them
      ↓
Measure performance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With unsupervised learning, the question becomes much more open-ended.&lt;/p&gt;

&lt;p&gt;If K-Means gives me three clusters, how do I know those clusters are actually useful?&lt;/p&gt;

&lt;p&gt;If PCA reduces my features to two components, what information did I lose?&lt;/p&gt;

&lt;p&gt;If an anomaly detection algorithm identifies an observation as unusual, is it actually an error — or is it simply an important but rare case?&lt;/p&gt;

&lt;p&gt;These questions require more than just running &lt;code&gt;.fit()&lt;/code&gt; and looking at the output.&lt;/p&gt;

&lt;p&gt;They require &lt;strong&gt;domain knowledge, exploration, visualization, and critical thinking&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  My Practical Unsupervised Learning Workflow
&lt;/h3&gt;

&lt;p&gt;When working with a real dataset, I wouldn't immediately jump into K-Means.&lt;/p&gt;

&lt;p&gt;I'd start with understanding the data.&lt;/p&gt;

&lt;p&gt;My workflow would look something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Load dataset
      ↓
Basic checks
      ↓
Missing values
      ↓
Duplicates
      ↓
Data types
      ↓
Outlier analysis
      ↓
Correlation analysis
      ↓
Feature selection
      ↓
Scaling
      ↓
Choose an unsupervised technique
      ↓
Train the model
      ↓
Evaluate the structure
      ↓
Visualize
      ↓
Interpret the results
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And preprocessing matters.&lt;/p&gt;

&lt;p&gt;For distance-based algorithms such as K-Means and many hierarchical clustering approaches, features with very different scales can distort the distance calculations. That's why scaling is an important part of the workflow. Scikit-learn also highlights feature scaling as relevant when methods depend on relationships between features. (&lt;a href="https://scikit-learn.org/1.9/modules/unsupervised_reduction.html?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Scikit-learn&lt;/a&gt;)&lt;/p&gt;




&lt;h3&gt;
  
  
  The Bigger Picture
&lt;/h3&gt;

&lt;p&gt;For me, unsupervised learning is interesting because it changes the role of the data scientist.&lt;/p&gt;

&lt;p&gt;Sometimes we're not trying to build a model that predicts an answer.&lt;/p&gt;

&lt;p&gt;Sometimes we're trying to &lt;strong&gt;ask better questions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Maybe the dataset contains customer segments we hadn't considered.&lt;/p&gt;

&lt;p&gt;Maybe there are unusual transactions hiding among millions of normal ones.&lt;/p&gt;

&lt;p&gt;Maybe dozens of variables can be represented by a much smaller number of meaningful components.&lt;/p&gt;

&lt;p&gt;Maybe the groups we assumed existed don't actually appear in the data.&lt;/p&gt;

&lt;p&gt;And that last possibility is important.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unsupervised learning doesn't guarantee that the pattern we hoped to find exists.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes the most valuable result is discovering that our assumptions were wrong.&lt;/p&gt;




&lt;h4&gt;
  
  
  Final Thoughts
&lt;/h4&gt;

&lt;p&gt;I'm still learning my way through machine learning, but unsupervised learning has made me appreciate something I think is easy to overlook:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data doesn't always need to give us the answer before we can learn something from it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes the most interesting insights come from allowing the data to reveal its own structure.&lt;/p&gt;

&lt;p&gt;K-Means, hierarchical clustering, DBSCAN, PCA, t-SNE, Gaussian Mixture Models, anomaly detection, and decomposition methods all approach that idea differently.&lt;/p&gt;

&lt;p&gt;The real skill isn't memorizing every algorithm.&lt;/p&gt;

&lt;p&gt;It's learning to ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What am I trying to discover, what assumptions does this algorithm make, and does the structure it finds actually make sense?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's where unsupervised learning becomes more than just another machine-learning technique.&lt;/p&gt;

&lt;p&gt;It becomes a way of exploring data.&lt;/p&gt;




&lt;h4&gt;
  
  
  References
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://scikit-learn.org/stable/unsupervised_learning.html" rel="noopener noreferrer"&gt;Scikit-learn: Unsupervised Learning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://scikit-learn.org/stable/modules/clustering.html" rel="noopener noreferrer"&gt;Scikit-learn: Clustering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://scikit-learn.org/stable/modules/unsupervised_reduction.html" rel="noopener noreferrer"&gt;Scikit-learn: Unsupervised Dimensionality Reduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>ai</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Machine Learning: The Technology You Use Every Day Without Realizing It</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Thu, 06 Aug 2026 10:41:17 +0000</pubDate>
      <link>https://dev.to/audrine_m/machine-learning-the-technology-you-use-every-day-without-realizing-it-kb4</link>
      <guid>https://dev.to/audrine_m/machine-learning-the-technology-you-use-every-day-without-realizing-it-kb4</guid>
      <description>&lt;p&gt;When most people hear the words &lt;em&gt;machine learning&lt;/em&gt;, they immediately think of robots, self-driving cars, or science fiction movies. I used to think the same.&lt;/p&gt;

&lt;p&gt;But the truth is much simpler and much more interesting.&lt;/p&gt;

&lt;p&gt;Machine learning is already part of our daily lives. Every time Netflix recommends your next favorite show, Spotify creates a playlist you'll probably love, or Google Maps finds the fastest route home, you're interacting with machine learning.&lt;/p&gt;

&lt;p&gt;The surprising part? Most of us use it every day without even noticing.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore what machine learning actually is, how it works, and the real-world applications that are quietly changing the way we live and work.&lt;/p&gt;




&lt;h2&gt;
  
  
  So, What Exactly Is Machine Learning?
&lt;/h2&gt;

&lt;p&gt;Machine learning (ML) is a branch of artificial intelligence (AI) that enables computers to learn from data instead of being explicitly programmed for every single task.&lt;/p&gt;

&lt;p&gt;Think about teaching a child to recognize cats.&lt;/p&gt;

&lt;p&gt;You don't give them a long list of mathematical rules describing cats. Instead, you show them hundreds of pictures. Over time, they begin to recognize patterns - pointy ears, whiskers, fur, and a tail.&lt;/p&gt;

&lt;p&gt;Machine learning works in a similar way.&lt;/p&gt;

&lt;p&gt;Instead of writing thousands of rules, we provide a model with data. The model identifies patterns and uses those patterns to make predictions or decisions when it encounters new information.&lt;/p&gt;

&lt;p&gt;For example, rather than programming every possible spam email, we train a machine learning model using thousands of examples of both spam and legitimate emails. Eventually, it becomes capable of identifying spam on its own.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Does Machine Learning Work?
&lt;/h2&gt;

&lt;p&gt;Although machine learning can become mathematically complex, the overall process is surprisingly straightforward.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Collect Data
&lt;/h3&gt;

&lt;p&gt;Everything starts with data.&lt;/p&gt;

&lt;p&gt;The quality of a machine learning model depends heavily on the quality of the data it's trained on. This data could include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer purchases&lt;/li&gt;
&lt;li&gt;Medical records&lt;/li&gt;
&lt;li&gt;Images&lt;/li&gt;
&lt;li&gt;Text documents&lt;/li&gt;
&lt;li&gt;Sensor readings&lt;/li&gt;
&lt;li&gt;Financial transactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more relevant and accurate the data, the better the model can learn.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Prepare the Data
&lt;/h3&gt;

&lt;p&gt;Raw data is rarely perfect.&lt;/p&gt;

&lt;p&gt;It often contains missing values, duplicate records, inconsistent formatting, or irrelevant information.&lt;/p&gt;

&lt;p&gt;Before training a model, data scientists clean and prepare the data by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removing duplicates&lt;/li&gt;
&lt;li&gt;Handling missing values&lt;/li&gt;
&lt;li&gt;Correcting errors&lt;/li&gt;
&lt;li&gt;Encoding categorical variables&lt;/li&gt;
&lt;li&gt;Scaling numerical features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This step may not be glamorous, but it often determines whether a project succeeds or fails.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Train the Model
&lt;/h3&gt;

&lt;p&gt;Once the data is ready, it's fed into a machine learning algorithm.&lt;/p&gt;

&lt;p&gt;The algorithm studies the relationships between different variables and gradually learns patterns hidden within the data.&lt;/p&gt;

&lt;p&gt;For example, a model trained on housing data might learn that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Larger houses generally cost more.&lt;/li&gt;
&lt;li&gt;Houses near schools tend to have higher prices.&lt;/li&gt;
&lt;li&gt;Location often matters more than the age of the house.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4. Test the Model
&lt;/h3&gt;

&lt;p&gt;Learning patterns is one thing.&lt;/p&gt;

&lt;p&gt;Applying them to new data is another.&lt;/p&gt;

&lt;p&gt;That's why we evaluate the model using data it has never seen before. This helps determine whether it truly understands the patterns or has simply memorized the training data.&lt;/p&gt;

&lt;p&gt;A good model performs well on new, unseen examples.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. Make Predictions
&lt;/h3&gt;

&lt;p&gt;Once the model performs well, it can be deployed into real applications.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Predicting loan defaults&lt;/li&gt;
&lt;li&gt;Detecting fraudulent transactions&lt;/li&gt;
&lt;li&gt;Recommending products&lt;/li&gt;
&lt;li&gt;Forecasting sales&lt;/li&gt;
&lt;li&gt;Diagnosing diseases&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Types of Machine Learning
&lt;/h2&gt;

&lt;p&gt;Not all machine learning problems are the same. Depending on the type of data and the desired outcome, different learning approaches are used.&lt;/p&gt;

&lt;h3&gt;
  
  
  Supervised Learning
&lt;/h3&gt;

&lt;p&gt;In supervised learning, the model learns using labeled data.&lt;/p&gt;

&lt;p&gt;This means every training example already contains the correct answer.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;House features&lt;/td&gt;
&lt;td&gt;House price&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Email&lt;/td&gt;
&lt;td&gt;Spam or Not Spam&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Medical symptoms&lt;/td&gt;
&lt;td&gt;Disease diagnosis&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Common algorithms include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linear Regression&lt;/li&gt;
&lt;li&gt;Logistic Regression&lt;/li&gt;
&lt;li&gt;Decision Trees&lt;/li&gt;
&lt;li&gt;Random Forest&lt;/li&gt;
&lt;li&gt;Support Vector Machines (SVM)&lt;/li&gt;
&lt;li&gt;K-Nearest Neighbors (KNN)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Unsupervised Learning
&lt;/h3&gt;

&lt;p&gt;Here, the data has no labels.&lt;/p&gt;

&lt;p&gt;The model tries to discover hidden patterns or group similar data together.&lt;/p&gt;

&lt;p&gt;Applications include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer segmentation&lt;/li&gt;
&lt;li&gt;Market basket analysis&lt;/li&gt;
&lt;li&gt;Document clustering&lt;/li&gt;
&lt;li&gt;Anomaly detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Popular algorithms include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;K-Means Clustering&lt;/li&gt;
&lt;li&gt;DBSCAN&lt;/li&gt;
&lt;li&gt;Hierarchical Clustering&lt;/li&gt;
&lt;li&gt;Principal Component Analysis (PCA)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Reinforcement Learning
&lt;/h3&gt;

&lt;p&gt;In reinforcement learning, an agent learns by interacting with an environment.&lt;/p&gt;

&lt;p&gt;It receives rewards for good decisions and penalties for poor ones, gradually improving through trial and error.&lt;/p&gt;

&lt;p&gt;Applications include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Robotics&lt;/li&gt;
&lt;li&gt;Game AI&lt;/li&gt;
&lt;li&gt;Autonomous vehicles&lt;/li&gt;
&lt;li&gt;Recommendation optimization&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Real-World Applications of Machine Learning
&lt;/h2&gt;

&lt;p&gt;Machine learning isn't confined to research labs. It's solving real problems across almost every industry.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Healthcare
&lt;/h2&gt;

&lt;p&gt;Healthcare has experienced significant improvements thanks to machine learning.&lt;/p&gt;

&lt;p&gt;Doctors and researchers use ML to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detect diseases earlier&lt;/li&gt;
&lt;li&gt;Analyze X-rays and MRI scans&lt;/li&gt;
&lt;li&gt;Predict patient outcomes&lt;/li&gt;
&lt;li&gt;Discover new medicines&lt;/li&gt;
&lt;li&gt;Personalize treatments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For instance, machine learning models can identify early signs of diseases such as diabetic retinopathy from eye scans, helping patients receive treatment before their vision deteriorates.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Finance
&lt;/h2&gt;

&lt;p&gt;Banks process millions of transactions every day.&lt;/p&gt;

&lt;p&gt;Machine learning helps by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detecting fraudulent transactions&lt;/li&gt;
&lt;li&gt;Assessing credit risk&lt;/li&gt;
&lt;li&gt;Predicting loan defaults&lt;/li&gt;
&lt;li&gt;Automating investment decisions&lt;/li&gt;
&lt;li&gt;Identifying suspicious financial activity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whenever your bank sends an alert about unusual activity on your card, there's a good chance machine learning played a role.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. E-commerce
&lt;/h2&gt;

&lt;p&gt;Online retailers use machine learning to create more personalized shopping experiences.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product recommendations&lt;/li&gt;
&lt;li&gt;Personalized discounts&lt;/li&gt;
&lt;li&gt;Demand forecasting&lt;/li&gt;
&lt;li&gt;Inventory optimization&lt;/li&gt;
&lt;li&gt;Dynamic pricing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ever wondered how Amazon seems to know exactly what you might want to buy next? That's machine learning analyzing shopping behavior and identifying patterns.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Entertainment
&lt;/h2&gt;

&lt;p&gt;Streaming platforms rely heavily on recommendation systems.&lt;/p&gt;

&lt;p&gt;Netflix recommends movies.&lt;/p&gt;

&lt;p&gt;Spotify builds personalized playlists.&lt;/p&gt;

&lt;p&gt;YouTube suggests videos you might enjoy.&lt;/p&gt;

&lt;p&gt;These recommendations are generated by machine learning models that learn from your viewing or listening habits and compare them with millions of other users.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Transportation
&lt;/h2&gt;

&lt;p&gt;Navigation apps do much more than display maps.&lt;/p&gt;

&lt;p&gt;Machine learning helps estimate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traffic conditions&lt;/li&gt;
&lt;li&gt;Travel times&lt;/li&gt;
&lt;li&gt;Accident risks&lt;/li&gt;
&lt;li&gt;Optimal delivery routes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ride-hailing services also use ML to predict demand, estimate fares, and match drivers with passengers efficiently.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Agriculture
&lt;/h2&gt;

&lt;p&gt;Farmers are increasingly adopting machine learning to improve productivity.&lt;/p&gt;

&lt;p&gt;Applications include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Crop disease detection&lt;/li&gt;
&lt;li&gt;Yield prediction&lt;/li&gt;
&lt;li&gt;Weather forecasting&lt;/li&gt;
&lt;li&gt;Precision irrigation&lt;/li&gt;
&lt;li&gt;Soil monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These technologies help farmers make informed decisions while reducing waste and improving food production.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Cybersecurity
&lt;/h2&gt;

&lt;p&gt;As cyber threats become more sophisticated, machine learning has become an essential defense tool.&lt;/p&gt;

&lt;p&gt;ML systems can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detect malware&lt;/li&gt;
&lt;li&gt;Identify unusual network activity&lt;/li&gt;
&lt;li&gt;Prevent phishing attacks&lt;/li&gt;
&lt;li&gt;Recognize suspicious login attempts&lt;/li&gt;
&lt;li&gt;Respond to threats more quickly than manual monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of relying only on predefined rules, these systems continuously learn from new attack patterns.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Environmental Conservation
&lt;/h2&gt;

&lt;p&gt;Machine learning is also making a difference in protecting our planet.&lt;/p&gt;

&lt;p&gt;Researchers use it to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Monitor deforestation&lt;/li&gt;
&lt;li&gt;Predict floods and droughts&lt;/li&gt;
&lt;li&gt;Track wildlife populations&lt;/li&gt;
&lt;li&gt;Analyze satellite imagery&lt;/li&gt;
&lt;li&gt;Forecast climate trends&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By processing massive environmental datasets, ML helps governments and conservation organizations make better decisions about protecting natural resources.&lt;/p&gt;




&lt;h2&gt;
  
  
  Challenges of Machine Learning
&lt;/h2&gt;

&lt;p&gt;Despite its impressive capabilities, machine learning is not without limitations.&lt;/p&gt;

&lt;p&gt;Some common challenges include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Poor-quality data leading to inaccurate predictions&lt;/li&gt;
&lt;li&gt;Bias in training data producing unfair outcomes&lt;/li&gt;
&lt;li&gt;High computational costs for large models&lt;/li&gt;
&lt;li&gt;Privacy concerns surrounding sensitive data&lt;/li&gt;
&lt;li&gt;Difficulty explaining complex model decisions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Building an accurate model is only part of the challenge. Ensuring it is fair, reliable, and transparent is equally important.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Learning Machine Learning Matters
&lt;/h2&gt;

&lt;p&gt;As industries continue to generate enormous amounts of data, the demand for professionals who can analyze that data and build intelligent systems is growing rapidly.&lt;/p&gt;

&lt;p&gt;The good news is that you don't need a PhD to get started.&lt;/p&gt;

&lt;p&gt;A strong foundation in Python, statistics, SQL, and data analysis is often enough to begin exploring machine learning. From there, you can gradually learn algorithms, model evaluation, feature engineering, and deployment.&lt;/p&gt;

&lt;p&gt;The field rewards curiosity and consistent practice more than memorizing complex formulas.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Machine learning isn't some distant technology reserved for tech giants. It's already woven into everyday life from the recommendations you see online to the fraud alerts that protect your bank account and the navigation apps that save you time.&lt;/p&gt;

&lt;p&gt;What makes machine learning so powerful isn't that it replaces human intelligence; it's that it helps us make better decisions by uncovering patterns hidden within data.&lt;/p&gt;

&lt;p&gt;As the amount of data we generate continues to grow, machine learning will play an even bigger role in healthcare, finance, education, environmental conservation, and countless other fields.&lt;/p&gt;

&lt;p&gt;Whether you're a student, an aspiring data scientist, or simply curious about technology, understanding machine learning is becoming less of a niche skill and more of a valuable form of digital literacy.&lt;/p&gt;

&lt;p&gt;And who knows? The next machine learning application that changes people's lives might be the one you build.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>beginners</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Why Hypothesis Testing is the Backbone of Data Science</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Mon, 29 Jun 2026 11:37:00 +0000</pubDate>
      <link>https://dev.to/audrine_m/why-hypothesis-testing-is-the-backbone-of-data-science-41lf</link>
      <guid>https://dev.to/audrine_m/why-hypothesis-testing-is-the-backbone-of-data-science-41lf</guid>
      <description>&lt;p&gt;&lt;em&gt;From A/B testing and machine learning to business intelligence and scientific research, hypothesis testing helps data scientists separate signal from noise.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Imagine you're analyzing customer data and discover that users who receive promotional emails spend 15% more than those who don't.&lt;/p&gt;

&lt;p&gt;Sounds like a breakthrough, right?&lt;/p&gt;

&lt;p&gt;But before presenting your findings to stakeholders, you need to answer an important question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Is this difference real, or could it have happened by random chance?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is where hypothesis testing comes in.&lt;/p&gt;

&lt;p&gt;Hypothesis testing is one of the most important statistical tools in data science. It provides a systematic way to evaluate assumptions, validate findings, and make data-driven decisions with confidence.&lt;/p&gt;

&lt;p&gt;Whether you're building machine learning models, conducting market research, optimizing products, or running experiments, hypothesis tests help ensure that your conclusions are supported by evidence rather than coincidence.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore the most common hypothesis tests used in data science and why each one matters.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Hypothesis Testing?
&lt;/h2&gt;

&lt;p&gt;Hypothesis testing is a statistical method used to determine whether there is enough evidence in a dataset to support a particular claim.&lt;/p&gt;

&lt;p&gt;Every hypothesis test starts with two competing statements:&lt;/p&gt;

&lt;h3&gt;
  
  
  Null Hypothesis (H₀)
&lt;/h3&gt;

&lt;p&gt;The assumption that there is no effect, no difference, or no relationship.&lt;/p&gt;

&lt;h3&gt;
  
  
  Alternative Hypothesis (H₁)
&lt;/h3&gt;

&lt;p&gt;The assumption that an effect, difference, or relationship exists.&lt;/p&gt;

&lt;p&gt;The goal is to collect data and determine whether the evidence is strong enough to reject the null hypothesis.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Chi-Square Test
&lt;/h2&gt;

&lt;h2&gt;
  
  
  What It Does
&lt;/h2&gt;

&lt;p&gt;The Chi-Square Test is used with categorical data to determine whether variables are related or whether observed frequencies match expected frequencies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Types
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Chi-Square Test of Independence&lt;/li&gt;
&lt;li&gt;Chi-Square Goodness-of-Fit Test&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why It Matters in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Customer Behavior Analysis
&lt;/h3&gt;

&lt;p&gt;Suppose an online retailer wants to know whether gender influences product preference.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Gender&lt;/th&gt;
&lt;th&gt;Product A&lt;/th&gt;
&lt;th&gt;Product B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;120&lt;/td&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;90&lt;/td&gt;
&lt;td&gt;110&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A Chi-Square Test can determine whether the differences are statistically significant.&lt;/p&gt;

&lt;h3&gt;
  
  
  Market Research
&lt;/h3&gt;

&lt;p&gt;Businesses use Chi-Square tests to answer questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does age influence brand choice?&lt;/li&gt;
&lt;li&gt;Does region affect purchasing behavior?&lt;/li&gt;
&lt;li&gt;Does device type affect website engagement?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Fraud Detection
&lt;/h3&gt;

&lt;p&gt;Banks compare expected and observed transaction patterns to identify unusual behavior that may indicate fraud.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Question It Answers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Are categorical variables associated with each other?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. T-Test
&lt;/h2&gt;

&lt;h2&gt;
  
  
  What It Does
&lt;/h2&gt;

&lt;p&gt;A T-Test compares the means of two groups.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Types
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;One-Sample T-Test&lt;/li&gt;
&lt;li&gt;Independent T-Test&lt;/li&gt;
&lt;li&gt;Paired T-Test&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why It Matters in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A/B Testing
&lt;/h3&gt;

&lt;p&gt;Imagine testing two versions of a website:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Version A conversion rate: 4.1%&lt;/li&gt;
&lt;li&gt;Version B conversion rate: 5.0%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A T-Test helps determine whether Version B truly performs better or if the difference occurred by chance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Product Improvement
&lt;/h3&gt;

&lt;p&gt;Companies frequently compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;New versus old interfaces&lt;/li&gt;
&lt;li&gt;New versus old recommendation systems&lt;/li&gt;
&lt;li&gt;Marketing campaigns&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Healthcare Analytics
&lt;/h3&gt;

&lt;p&gt;Researchers compare treatment outcomes, recovery times, and drug effectiveness.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Question It Answers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Are the means of two groups significantly different?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. ANOVA (Analysis of Variance)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What It Does
&lt;/h3&gt;

&lt;p&gt;ANOVA compares the means of three or more groups simultaneously.&lt;/p&gt;

&lt;p&gt;Without ANOVA, analysts would need multiple T-Tests, increasing the risk of incorrect conclusions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why It Matters in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Marketing Performance Analysis
&lt;/h3&gt;

&lt;p&gt;Suppose a company advertises on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google&lt;/li&gt;
&lt;li&gt;Facebook&lt;/li&gt;
&lt;li&gt;Instagram&lt;/li&gt;
&lt;li&gt;LinkedIn&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ANOVA determines whether at least one platform produces significantly different results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Customer Segmentation
&lt;/h3&gt;

&lt;p&gt;Businesses often classify customers into segments and compare spending behavior across groups.&lt;/p&gt;

&lt;h3&gt;
  
  
  Machine Learning Evaluation
&lt;/h3&gt;

&lt;p&gt;Researchers may compare the performance of multiple algorithms and use ANOVA to determine whether observed differences are meaningful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Question It Answers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Is there a significant difference among multiple group means?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. Correlation Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What It Does
&lt;/h3&gt;

&lt;p&gt;Correlation measures the strength and direction of a relationship between variables.&lt;/p&gt;

&lt;p&gt;Common methods include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pearson Correlation&lt;/li&gt;
&lt;li&gt;Spearman Correlation&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why It Matters in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Feature Selection
&lt;/h3&gt;

&lt;p&gt;When building predictive models, data scientists need to identify variables that influence outcomes.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;House size vs house price&lt;/li&gt;
&lt;li&gt;Advertising spend vs revenue&lt;/li&gt;
&lt;li&gt;Study hours vs exam scores&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Strong correlations often indicate useful predictive features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Business Intelligence
&lt;/h3&gt;

&lt;p&gt;Organizations use correlation analysis to uncover hidden relationships in data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Question It Answers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Are two variables related?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Regression Significance Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What It Does
&lt;/h3&gt;

&lt;p&gt;Regression models use hypothesis testing to determine whether predictor variables contribute significantly to predictions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why It Matters in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Predictive Modeling
&lt;/h3&gt;

&lt;p&gt;Suppose you're predicting sales using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Marketing spend&lt;/li&gt;
&lt;li&gt;Product price&lt;/li&gt;
&lt;li&gt;Website traffic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Regression significance tests help identify which variables genuinely impact sales.&lt;/p&gt;

&lt;h3&gt;
  
  
  Explainable AI
&lt;/h3&gt;

&lt;p&gt;Organizations increasingly require transparency in machine learning models.&lt;/p&gt;

&lt;p&gt;Regression testing helps answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which factors matter most?&lt;/li&gt;
&lt;li&gt;Which variables can be removed?&lt;/li&gt;
&lt;li&gt;What drives business outcomes?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Key Question It Answers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Which variables significantly influence the target variable?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. Z-Test
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What It Does
&lt;/h3&gt;

&lt;p&gt;A Z-Test compares sample statistics with population parameters, typically when sample sizes are large.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why It Matters in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Large-Scale Experiments
&lt;/h3&gt;

&lt;p&gt;Technology companies often analyze millions of users.&lt;/p&gt;

&lt;p&gt;When datasets become very large, Z-tests provide efficient statistical evaluation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quality Control
&lt;/h3&gt;

&lt;p&gt;Manufacturers use Z-tests to verify whether products meet required standards.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Question It Answers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Is a sample significantly different from a population expectation?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. Non-Parametric Tests
&lt;/h2&gt;

&lt;p&gt;Not all datasets follow a normal distribution.&lt;/p&gt;

&lt;p&gt;When traditional assumptions are violated, non-parametric tests become extremely valuable.&lt;/p&gt;




&lt;h2&gt;
  
  
  Mann-Whitney U Test
&lt;/h2&gt;

&lt;p&gt;Alternative to the Independent T-Test.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Customer satisfaction surveys&lt;/li&gt;
&lt;li&gt;Product ratings&lt;/li&gt;
&lt;li&gt;User review analysis&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Key Question
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Are two independent groups different when normality assumptions are not met?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Wilcoxon Signed-Rank Test
&lt;/h2&gt;

&lt;p&gt;Alternative to the Paired T-Test.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Before-and-after studies&lt;/li&gt;
&lt;li&gt;UX improvement evaluations&lt;/li&gt;
&lt;li&gt;Employee performance assessments&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Key Question
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Has a measurable change occurred between paired observations?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Kruskal-Wallis Test
&lt;/h2&gt;

&lt;p&gt;Alternative to ANOVA.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Comparing multiple customer segments&lt;/li&gt;
&lt;li&gt;Ranking-based datasets&lt;/li&gt;
&lt;li&gt;Non-normal distributions&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Key Question
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Are multiple groups significantly different without assuming normality?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  8. Proportion Tests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What They Do
&lt;/h3&gt;

&lt;p&gt;Proportion tests compare percentages between groups.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why They Matter in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Conversion Rate Optimization
&lt;/h3&gt;

&lt;p&gt;Suppose an online store tests two landing pages:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Conversions&lt;/th&gt;
&lt;th&gt;Visitors&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;400&lt;/td&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;520&lt;/td&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A proportion test determines whether the higher conversion rate is statistically significant.&lt;/p&gt;

&lt;h3&gt;
  
  
  Public Health Analytics
&lt;/h3&gt;

&lt;p&gt;Researchers compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vaccination rates&lt;/li&gt;
&lt;li&gt;Disease prevalence&lt;/li&gt;
&lt;li&gt;Adoption rates&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Key Question It Answers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Are differences in proportions statistically significant?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Why Every Data Scientist Should Understand Hypothesis Testing
&lt;/h2&gt;

&lt;p&gt;Hypothesis testing is more than a statistics topic taught in university courses.&lt;/p&gt;

&lt;p&gt;It directly impacts real-world decision-making.&lt;/p&gt;

&lt;h3&gt;
  
  
  It Prevents Costly Mistakes
&lt;/h3&gt;

&lt;p&gt;Without statistical testing, organizations may invest resources based on random fluctuations.&lt;/p&gt;

&lt;h3&gt;
  
  
  It Enables Data-Driven Decisions
&lt;/h3&gt;

&lt;p&gt;Businesses rely on evidence rather than assumptions.&lt;/p&gt;

&lt;h3&gt;
  
  
  It Improves Machine Learning Models
&lt;/h3&gt;

&lt;p&gt;Hypothesis tests help validate relationships between variables and target outcomes.&lt;/p&gt;

&lt;h3&gt;
  
  
  It Powers Experimentation
&lt;/h3&gt;

&lt;p&gt;Modern companies continuously run experiments involving:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product design&lt;/li&gt;
&lt;li&gt;Pricing strategies&lt;/li&gt;
&lt;li&gt;Marketing campaigns&lt;/li&gt;
&lt;li&gt;User experience improvements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hypothesis testing determines whether those experiments produced meaningful results.&lt;/p&gt;

&lt;h3&gt;
  
  
  It Builds Trust
&lt;/h3&gt;

&lt;p&gt;Stakeholders are more likely to trust conclusions backed by statistical evidence than intuition alone.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Data science is often described as the intersection of statistics, programming, and domain expertise. Among these pillars, hypothesis testing serves as the mechanism that transforms raw observations into credible knowledge.&lt;/p&gt;

&lt;p&gt;Each test serves a unique purpose:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Test&lt;/th&gt;
&lt;th&gt;Primary Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Chi-Square&lt;/td&gt;
&lt;td&gt;Analyze relationships between categorical variables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;T-Test&lt;/td&gt;
&lt;td&gt;Compare two means&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ANOVA&lt;/td&gt;
&lt;td&gt;Compare multiple means&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Correlation Test&lt;/td&gt;
&lt;td&gt;Measure relationships between variables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Regression Test&lt;/td&gt;
&lt;td&gt;Evaluate predictor significance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Z-Test&lt;/td&gt;
&lt;td&gt;Compare sample and population statistics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mann-Whitney U&lt;/td&gt;
&lt;td&gt;Compare two non-normal groups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wilcoxon Test&lt;/td&gt;
&lt;td&gt;Compare paired observations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kruskal-Wallis&lt;/td&gt;
&lt;td&gt;Compare multiple non-normal groups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Proportion Test&lt;/td&gt;
&lt;td&gt;Compare percentages between groups&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As data scientists, our goal is not simply to find patterns in data but to determine whether those patterns are meaningful. Hypothesis testing provides the statistical foundation that makes this possible.&lt;/p&gt;

&lt;p&gt;The next time you discover an interesting trend in your dataset, don't just ask &lt;em&gt;"What does the data show?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Is the evidence strong enough to support this conclusion?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's the question hypothesis testing was designed to answer.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>statistics</category>
      <category>beginners</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Understanding Statistical Distributions and Their Impact on Data Science</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Mon, 22 Jun 2026 10:25:18 +0000</pubDate>
      <link>https://dev.to/audrine_m/understanding-statistical-distributions-and-their-impact-on-data-science-13lj</link>
      <guid>https://dev.to/audrine_m/understanding-statistical-distributions-and-their-impact-on-data-science-13lj</guid>
      <description>&lt;p&gt;Data is at the heart of every data science project. Whether you're predicting customer churn, detecting fraud, forecasting sales, or building recommendation systems, understanding how data is distributed can significantly improve your analysis and model performance.&lt;/p&gt;

&lt;p&gt;Yet, distributions are often overlooked by beginners who jump straight into machine learning algorithms. In reality, understanding data distributions is one of the most important statistical foundations in data science.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore what statistical distributions are, the most common distributions used in data science, and how they influence data analysis and machine learning outcomes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Statistical Distribution?
&lt;/h2&gt;

&lt;p&gt;A statistical distribution describes how values in a dataset are spread across different ranges.&lt;/p&gt;

&lt;p&gt;Think of a distribution as a map that shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which values occur most frequently&lt;/li&gt;
&lt;li&gt;Which values are rare&lt;/li&gt;
&lt;li&gt;The overall shape of the data&lt;/li&gt;
&lt;li&gt;The likelihood of observing specific values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, if you collect exam scores from 1,000 students, a distribution can show whether most students scored around 70%, whether scores are evenly spread, or whether there are extreme outliers.&lt;/p&gt;

&lt;p&gt;Understanding this pattern helps data scientists make informed decisions about preprocessing, modeling, and interpretation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Distributions Matter in Data Science
&lt;/h2&gt;

&lt;p&gt;Distributions influence almost every stage of the data science workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Better Understanding of Data
&lt;/h3&gt;

&lt;p&gt;Before building any model, analysts need to understand the characteristics of their data.&lt;/p&gt;

&lt;p&gt;Questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the data normally distributed?&lt;/li&gt;
&lt;li&gt;Are there outliers?&lt;/li&gt;
&lt;li&gt;Is the data skewed?&lt;/li&gt;
&lt;li&gt;Are there multiple peaks?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;can only be answered by examining distributions.&lt;/p&gt;

&lt;p&gt;Visualizations such as histograms, density plots, and box plots help reveal these characteristics.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Improved Feature Engineering
&lt;/h3&gt;

&lt;p&gt;Many machine learning algorithms perform better when features follow certain distribution patterns.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linear Regression assumes normally distributed residuals.&lt;/li&gt;
&lt;li&gt;Logistic Regression performs better with appropriately scaled variables.&lt;/li&gt;
&lt;li&gt;Neural Networks often benefit from normalized inputs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding distributions helps determine whether transformations such as logarithmic scaling, standardization, or normalization are necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Better Model Selection
&lt;/h3&gt;

&lt;p&gt;Different statistical models are designed for different data distributions.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Poisson Regression for count data&lt;/li&gt;
&lt;li&gt;Gaussian Models for normally distributed data&lt;/li&gt;
&lt;li&gt;Exponential Models for waiting-time events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choosing the wrong model for a dataset can lead to poor predictions and unreliable insights.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Outlier Detection
&lt;/h3&gt;

&lt;p&gt;Outliers often indicate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data entry errors&lt;/li&gt;
&lt;li&gt;Fraudulent activities&lt;/li&gt;
&lt;li&gt;Rare but important events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Distribution analysis helps identify these unusual observations before they negatively affect model performance.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Statistical Distributions in Data Science
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Normal Distribution
&lt;/h3&gt;

&lt;p&gt;The Normal Distribution, also known as the Gaussian Distribution, is the most widely used distribution in statistics.&lt;/p&gt;

&lt;p&gt;Characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bell-shaped curve&lt;/li&gt;
&lt;li&gt;Symmetrical around the mean&lt;/li&gt;
&lt;li&gt;Mean, median, and mode are equal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Human heights&lt;/li&gt;
&lt;li&gt;IQ scores&lt;/li&gt;
&lt;li&gt;Measurement errors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why it matters:&lt;/p&gt;

&lt;p&gt;Many statistical techniques assume normality. Understanding whether data approximates a normal distribution can influence the choice of algorithms and evaluation methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           *
         *   *
       *       *
     *           *
   *               *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Uniform Distribution
&lt;/h3&gt;

&lt;p&gt;In a Uniform Distribution, every value has an equal probability of occurring.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rolling a fair die&lt;/li&gt;
&lt;li&gt;Random number generation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why it matters:&lt;/p&gt;

&lt;p&gt;Uniform distributions are commonly used in simulations, random sampling, and initialization procedures in machine learning.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Poisson Distribution
&lt;/h3&gt;

&lt;p&gt;The Poisson Distribution models the number of times an event occurs within a fixed interval.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of website visits per minute&lt;/li&gt;
&lt;li&gt;Number of customer calls per hour&lt;/li&gt;
&lt;li&gt;Number of accidents at a junction per month&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why it matters:&lt;/p&gt;

&lt;p&gt;Many real-world business problems involve counting events, making the Poisson Distribution highly relevant for predictive analytics.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Binomial Distribution
&lt;/h3&gt;

&lt;p&gt;The Binomial Distribution describes the number of successes in a fixed number of independent trials.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email opened or not opened&lt;/li&gt;
&lt;li&gt;Customer purchased or did not purchase&lt;/li&gt;
&lt;li&gt;Coin toss outcomes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why it matters:&lt;/p&gt;

&lt;p&gt;Classification problems often involve concepts rooted in binomial probability.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. Exponential Distribution
&lt;/h3&gt;

&lt;p&gt;The Exponential Distribution models the time between independent events.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time until equipment failure&lt;/li&gt;
&lt;li&gt;Time between customer arrivals&lt;/li&gt;
&lt;li&gt;Waiting time before receiving a call&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why it matters:&lt;/p&gt;

&lt;p&gt;It is commonly used in reliability analysis, operations research, and queueing systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding Skewness
&lt;/h2&gt;

&lt;p&gt;Not all datasets follow a perfect normal distribution.&lt;/p&gt;

&lt;h3&gt;
  
  
  Right-Skewed Distribution
&lt;/h3&gt;

&lt;p&gt;Most values are concentrated on the left, with a long tail extending to the right.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Income distributions&lt;/li&gt;
&lt;li&gt;Property prices&lt;/li&gt;
&lt;li&gt;Online transaction values&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Left-Skewed Distribution
&lt;/h3&gt;

&lt;p&gt;Most values are concentrated on the right, with a long tail extending to the left.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Difficult exam scores where most students perform well&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why it matters:&lt;/p&gt;

&lt;p&gt;Skewed data can affect statistical calculations and machine learning model performance.&lt;/p&gt;

&lt;p&gt;Common solutions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log transformations&lt;/li&gt;
&lt;li&gt;Square root transformations&lt;/li&gt;
&lt;li&gt;Box-Cox transformations&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Impact of Distributions on Machine Learning
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Linear Regression
&lt;/h3&gt;

&lt;p&gt;Linear Regression assumes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Normally distributed residuals&lt;/li&gt;
&lt;li&gt;Constant variance&lt;/li&gt;
&lt;li&gt;Independence of observations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Violating these assumptions may reduce model reliability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Decision Trees
&lt;/h3&gt;

&lt;p&gt;Decision Trees are generally less sensitive to distributions.&lt;/p&gt;

&lt;p&gt;This makes them useful when data contains skewness, outliers, or non-linear relationships.&lt;/p&gt;

&lt;h3&gt;
  
  
  Neural Networks
&lt;/h3&gt;

&lt;p&gt;Neural Networks often perform better when features are normalized or standardized.&lt;/p&gt;

&lt;p&gt;Poorly distributed inputs can slow down learning and reduce accuracy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Clustering Algorithms
&lt;/h3&gt;

&lt;p&gt;Algorithms such as K-Means rely heavily on distance calculations.&lt;/p&gt;

&lt;p&gt;Highly skewed distributions can distort cluster formation and produce misleading results.&lt;/p&gt;




&lt;h2&gt;
  
  
  Practical Example
&lt;/h2&gt;

&lt;p&gt;Imagine you're analyzing monthly customer spending in an e-commerce business.&lt;/p&gt;

&lt;p&gt;A histogram reveals a heavily right-skewed distribution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Most customers spend less than $100.&lt;/li&gt;
&lt;li&gt;A few customers spend thousands of dollars.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use the raw data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The average spending value becomes inflated.&lt;/li&gt;
&lt;li&gt;Models may become biased toward high spenders.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A log transformation can make the distribution more balanced, resulting in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better visualizations&lt;/li&gt;
&lt;li&gt;More accurate predictions&lt;/li&gt;
&lt;li&gt;Improved model stability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This simple adjustment demonstrates how understanding distributions can directly improve business outcomes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tools for Analyzing Distributions
&lt;/h2&gt;

&lt;p&gt;Python provides several libraries for distribution analysis:&lt;/p&gt;

&lt;h3&gt;
  
  
  Matplotlib
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;

&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Seaborn
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;

&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;histplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kde&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SciPy
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;scipy&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;

&lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;normaltest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pandas
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;skew&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;kurtosis&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These tools help data scientists quickly evaluate distribution characteristics before modeling.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Statistical distributions are more than just theoretical concepts taught in statistics classes. They form the foundation of data science and machine learning.&lt;/p&gt;

&lt;p&gt;By understanding distributions, data scientists can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explore data more effectively&lt;/li&gt;
&lt;li&gt;Detect anomalies and outliers&lt;/li&gt;
&lt;li&gt;Select appropriate models&lt;/li&gt;
&lt;li&gt;Improve feature engineering&lt;/li&gt;
&lt;li&gt;Increase prediction accuracy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before building your next machine learning model, spend time understanding how your data is distributed. The insights gained from distribution analysis can often be more valuable than trying a new algorithm.&lt;/p&gt;

&lt;p&gt;Remember: great models begin with a deep understanding of the data behind them.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python for Data Analytics: A Beginner’s Complete Guide</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Sun, 10 May 2026 11:43:32 +0000</pubDate>
      <link>https://dev.to/audrine_m/python-for-data-analytics-a-beginners-complete-guide-4547</link>
      <guid>https://dev.to/audrine_m/python-for-data-analytics-a-beginners-complete-guide-4547</guid>
      <description>&lt;p&gt;In today’s digital world, data has become one of the most valuable resources. Every time we shop online, use social media, stream music, make a mobile payment, or search the internet, data is being created. Businesses and organizations use this information to understand customers, improve services, increase profits, and make smarter decisions.&lt;/p&gt;

&lt;p&gt;However, raw data alone is not useful unless it can be analyzed properly. This is where data analytics comes in. Data analytics helps transform raw information into meaningful insights that organizations can use to solve problems and make informed decisions.&lt;/p&gt;

&lt;p&gt;Among all the tools used in data analytics, Python has become one of the most popular and powerful programming languages in the world. From beginners learning their first programming language to professional data scientists working at major companies, Python is now considered an essential skill in the data industry.&lt;/p&gt;

&lt;p&gt;When I first started learning about data analytics, Python seemed intimidating. I assumed programming was only for software engineers and highly technical professionals. However, after exploring small projects and learning the basics, I realized why so many analysts rely on Python every day. It simplifies complex tasks, automates repetitive work, and makes analyzing data far more efficient.&lt;/p&gt;

&lt;p&gt;This article explains what Python is, why it is widely used in data analytics, the major Python libraries analysts use, how Python helps clean and visualize data, and why beginners should strongly consider learning it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Python?
&lt;/h2&gt;

&lt;p&gt;Python is a high-level programming language created by Guido van Rossum and officially released in 1991. It was designed with simplicity and readability in mind, making it easier to understand compared to many older programming languages.&lt;/p&gt;

&lt;p&gt;Unlike some languages that use complicated syntax and lengthy code structures, Python focuses on writing clean and readable code. This makes it especially beginner-friendly.&lt;/p&gt;

&lt;p&gt;For example, a simple Python program can look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, World!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That single line prints text to the screen.&lt;/p&gt;

&lt;p&gt;One reason Python became so popular is because it allows people to focus on solving problems instead of struggling with difficult syntax rules. Whether someone wants to build websites, automate tasks, develop artificial intelligence systems, or analyze data, Python provides a flexible and accessible starting point.&lt;/p&gt;

&lt;p&gt;Python is also open-source, meaning anyone can use it for free. It works across major operating systems including Windows, Linux, and macOS.&lt;/p&gt;

&lt;p&gt;Today, Python is used in many areas such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web development&lt;/li&gt;
&lt;li&gt;Cybersecurity&lt;/li&gt;
&lt;li&gt;Automation&lt;/li&gt;
&lt;li&gt;Artificial intelligence&lt;/li&gt;
&lt;li&gt;Machine learning&lt;/li&gt;
&lt;li&gt;Data analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Among these areas, data analytics has become one of Python’s strongest and fastest-growing fields.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Data Analytics
&lt;/h2&gt;

&lt;p&gt;Before exploring Python’s role in analytics, it is important to understand what data analytics actually means.&lt;/p&gt;

&lt;p&gt;Data analytics refers to the process of examining data to discover patterns, trends, relationships, and useful insights. Organizations use analytics to make better decisions and improve performance.&lt;/p&gt;

&lt;p&gt;For example, a company may analyze customer purchasing data to answer questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which products sell the most?&lt;/li&gt;
&lt;li&gt;Which customers are likely to stop buying?&lt;/li&gt;
&lt;li&gt;Which marketing campaigns perform best?&lt;/li&gt;
&lt;li&gt;What sales trends appear during different seasons?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Data analytics usually involves several steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Collecting data&lt;/li&gt;
&lt;li&gt;Cleaning and organizing data&lt;/li&gt;
&lt;li&gt;Exploring data&lt;/li&gt;
&lt;li&gt;Analyzing patterns&lt;/li&gt;
&lt;li&gt;Visualizing results&lt;/li&gt;
&lt;li&gt;Reporting insights&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Python can support all these stages efficiently, which is one of the reasons it has become so valuable in the analytics industry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Python Is So Popular in Data Analytics
&lt;/h2&gt;

&lt;p&gt;Python’s popularity in data analytics continues to grow rapidly. Several factors contribute to this success.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Python Is Beginner-Friendly
&lt;/h3&gt;

&lt;p&gt;One of Python’s greatest strengths is its simplicity.&lt;/p&gt;

&lt;p&gt;Compared to programming languages such as Java or C++, Python uses cleaner and more readable syntax. Beginners can often understand Python code even with limited programming experience.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;average&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;average&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even someone new to coding can understand that this program calculates an average.&lt;/p&gt;

&lt;p&gt;Because of its simplicity, many universities and online learning platforms now teach Python as a first programming language.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Python Has a Huge Community
&lt;/h3&gt;

&lt;p&gt;Python has millions of users worldwide. This large community makes learning easier because beginners can quickly find tutorials, videos, forums, and documentation online.&lt;/p&gt;

&lt;p&gt;If a learner encounters an error or problem, chances are high that someone else has already solved it and shared the solution online.&lt;/p&gt;

&lt;p&gt;Popular learning platforms include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.python.org?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Python Official Website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.kaggle.com?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Kaggle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;freeCodeCamp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This strong community support makes Python easier to learn compared to many technical tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Python Has Powerful Data Libraries
&lt;/h3&gt;

&lt;p&gt;One major reason analysts love Python is its collection of specialized libraries.&lt;/p&gt;

&lt;p&gt;Libraries are pre-written collections of code that help programmers complete tasks more efficiently. Instead of writing everything from scratch, analysts can use these libraries to process and analyze data quickly.&lt;/p&gt;

&lt;p&gt;Some important Python libraries include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pandas&lt;/li&gt;
&lt;li&gt;NumPy&lt;/li&gt;
&lt;li&gt;Matplotlib&lt;/li&gt;
&lt;li&gt;Seaborn&lt;/li&gt;
&lt;li&gt;Scikit-learn&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These libraries have transformed Python into one of the most powerful analytics tools available today.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Python Saves Time Through Automation
&lt;/h3&gt;

&lt;p&gt;Many data tasks are repetitive and time-consuming.&lt;/p&gt;

&lt;p&gt;For example, analysts may need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clean datasets daily&lt;/li&gt;
&lt;li&gt;Generate weekly reports&lt;/li&gt;
&lt;li&gt;Update dashboards&lt;/li&gt;
&lt;li&gt;Organize spreadsheets&lt;/li&gt;
&lt;li&gt;Combine multiple files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Doing these tasks manually can waste hours.&lt;/p&gt;

&lt;p&gt;Python helps automate these processes using scripts, reducing human error and improving efficiency.&lt;/p&gt;

&lt;p&gt;Automation is one reason companies increasingly prefer analysts with Python skills.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Python Is Used Across Industries
&lt;/h3&gt;

&lt;p&gt;Python is not limited to one field.&lt;/p&gt;

&lt;p&gt;Industries using Python for analytics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finance&lt;/li&gt;
&lt;li&gt;Healthcare&lt;/li&gt;
&lt;li&gt;E-commerce&lt;/li&gt;
&lt;li&gt;Marketing&lt;/li&gt;
&lt;li&gt;Transportation&lt;/li&gt;
&lt;li&gt;Telecommunications&lt;/li&gt;
&lt;li&gt;Education&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because Python is widely applicable, learning it opens opportunities across many career paths.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Python Libraries for Data Analytics
&lt;/h2&gt;

&lt;p&gt;Python’s true strength in analytics comes from its libraries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pandas
&lt;/h3&gt;

&lt;p&gt;Pandas is one of the most important Python libraries for data analytics.&lt;/p&gt;

&lt;p&gt;It allows analysts to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read CSV and Excel files&lt;/li&gt;
&lt;li&gt;Clean messy data&lt;/li&gt;
&lt;li&gt;Filter rows and columns&lt;/li&gt;
&lt;li&gt;Merge datasets&lt;/li&gt;
&lt;li&gt;Calculate statistics&lt;/li&gt;
&lt;li&gt;Organize information into tables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pandas uses structures called DataFrames, which resemble Excel spreadsheets.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;p7t9q1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Alice&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Brian&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Cynthia&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a simple table of names and ages.&lt;/p&gt;

&lt;p&gt;Pandas is essential for almost every data analytics project.&lt;/p&gt;

&lt;h3&gt;
  
  
  NumPy
&lt;/h3&gt;

&lt;p&gt;NumPy focuses on numerical operations and mathematical calculations.&lt;/p&gt;

&lt;p&gt;It is especially useful when handling large amounts of numerical data efficiently.&lt;/p&gt;

&lt;p&gt;NumPy helps analysts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perform calculations&lt;/li&gt;
&lt;li&gt;Work with arrays&lt;/li&gt;
&lt;li&gt;Calculate statistics&lt;/li&gt;
&lt;li&gt;Handle mathematical functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;f4w2r8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This calculates the average of the numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Matplotlib
&lt;/h3&gt;

&lt;p&gt;Matplotlib is one of the most widely used visualization libraries in Python.&lt;/p&gt;

&lt;p&gt;Data visualization helps convert raw data into understandable charts and graphs.&lt;/p&gt;

&lt;p&gt;Matplotlib can create:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Line charts&lt;/li&gt;
&lt;li&gt;Bar charts&lt;/li&gt;
&lt;li&gt;Pie charts&lt;/li&gt;
&lt;li&gt;Histograms&lt;/li&gt;
&lt;li&gt;Scatter plots&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;l1m9s7&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This generates a simple line graph.&lt;/p&gt;

&lt;p&gt;Visualizations make it easier for businesses and decision-makers to understand data trends.&lt;/p&gt;

&lt;h3&gt;
  
  
  Seaborn
&lt;/h3&gt;

&lt;p&gt;Seaborn is built on top of Matplotlib and provides more advanced and visually appealing charts.&lt;/p&gt;

&lt;p&gt;Analysts use Seaborn for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Correlation heatmaps&lt;/li&gt;
&lt;li&gt;Statistical charts&lt;/li&gt;
&lt;li&gt;Distribution plots&lt;/li&gt;
&lt;li&gt;Comparative visualizations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Seaborn is popular because it creates professional-looking visuals with relatively little code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scikit-learn
&lt;/h3&gt;

&lt;p&gt;Scikit-learn is widely used for machine learning and predictive analytics.&lt;/p&gt;

&lt;p&gt;Although machine learning is more advanced than basic analytics, many analysts eventually use Scikit-learn for predictive tasks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer churn prediction&lt;/li&gt;
&lt;li&gt;Fraud detection&lt;/li&gt;
&lt;li&gt;Sales forecasting&lt;/li&gt;
&lt;li&gt;Recommendation systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scikit-learn simplifies complex machine learning processes for developers and analysts.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Python Is Used in Data Analytics
&lt;/h2&gt;

&lt;p&gt;Python supports analysts throughout the entire analytics workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Collection
&lt;/h3&gt;

&lt;p&gt;The first step in analytics is gathering data.&lt;/p&gt;

&lt;p&gt;Python can collect data from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSV files&lt;/li&gt;
&lt;li&gt;Excel spreadsheets&lt;/li&gt;
&lt;li&gt;Databases&lt;/li&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;Websites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Analysts often use Python for web scraping, which involves extracting information from websites automatically.&lt;/p&gt;

&lt;p&gt;Libraries such as BeautifulSoup and Requests help collect online data efficiently.&lt;/p&gt;

&lt;p&gt;For example, companies may scrape product prices, customer reviews, or market information for analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Cleaning
&lt;/h3&gt;

&lt;p&gt;Real-world data is rarely perfect.&lt;/p&gt;

&lt;p&gt;Datasets often contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing values&lt;/li&gt;
&lt;li&gt;Duplicate records&lt;/li&gt;
&lt;li&gt;Formatting problems&lt;/li&gt;
&lt;li&gt;Incorrect entries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Poor-quality data can produce misleading insights.&lt;/p&gt;

&lt;p&gt;Python makes cleaning easier using Pandas.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;n6r3b5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dropna&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes rows with missing values.&lt;/p&gt;

&lt;p&gt;Another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;u8w2y4&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop_duplicates&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes duplicate records.&lt;/p&gt;

&lt;p&gt;Python helps automate cleaning tasks that would take much longer in spreadsheet software.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Exploration
&lt;/h3&gt;

&lt;p&gt;Once data is cleaned, analysts explore it to understand patterns and trends.&lt;/p&gt;

&lt;p&gt;This stage includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding averages&lt;/li&gt;
&lt;li&gt;Measuring relationships&lt;/li&gt;
&lt;li&gt;Identifying unusual values&lt;/li&gt;
&lt;li&gt;Understanding distributions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Python helps generate quick summaries.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;h5t2e1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This produces statistics such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mean&lt;/li&gt;
&lt;li&gt;Minimum value&lt;/li&gt;
&lt;li&gt;Maximum value&lt;/li&gt;
&lt;li&gt;Standard deviation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exploring data helps analysts understand what the dataset contains before performing deeper analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Visualization
&lt;/h3&gt;

&lt;p&gt;One of the most important parts of analytics is visualization.&lt;/p&gt;

&lt;p&gt;Humans understand visuals faster than raw numbers. Charts and graphs simplify complex information.&lt;/p&gt;

&lt;p&gt;Python allows analysts to create dashboards and visuals showing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sales performance&lt;/li&gt;
&lt;li&gt;Customer behavior&lt;/li&gt;
&lt;li&gt;Market trends&lt;/li&gt;
&lt;li&gt;Financial reports&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, a company may use graphs to identify which products perform best during certain months.&lt;/p&gt;

&lt;p&gt;Good visualizations improve communication and support better business decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Predictive Analytics and Machine Learning
&lt;/h3&gt;

&lt;p&gt;Modern analytics increasingly focuses on predicting future outcomes instead of only analyzing past data.&lt;/p&gt;

&lt;p&gt;Python supports predictive analytics using machine learning.&lt;/p&gt;

&lt;p&gt;Organizations use Python to predict:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer behavior&lt;/li&gt;
&lt;li&gt;Product demand&lt;/li&gt;
&lt;li&gt;Stock trends&lt;/li&gt;
&lt;li&gt;Equipment failures&lt;/li&gt;
&lt;li&gt;Fraudulent transactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows businesses to make proactive decisions instead of reacting after problems occur.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Examples of Python in Data Analytics
&lt;/h2&gt;

&lt;p&gt;Python is used globally across multiple industries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Healthcare Analytics
&lt;/h3&gt;

&lt;p&gt;Hospitals and healthcare organizations analyze patient data using Python.&lt;/p&gt;

&lt;p&gt;Analytics helps healthcare professionals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Predict disease risks&lt;/li&gt;
&lt;li&gt;Monitor patient trends&lt;/li&gt;
&lt;li&gt;Improve hospital efficiency&lt;/li&gt;
&lt;li&gt;Analyze treatment effectiveness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Python played an important role in analyzing health data during global disease outbreaks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finance and Banking
&lt;/h3&gt;

&lt;p&gt;Banks generate massive amounts of financial data daily.&lt;/p&gt;

&lt;p&gt;Python is widely used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fraud detection&lt;/li&gt;
&lt;li&gt;Risk assessment&lt;/li&gt;
&lt;li&gt;Credit scoring&lt;/li&gt;
&lt;li&gt;Investment analysis&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Financial analysts use Python because it processes large datasets efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  E-Commerce
&lt;/h3&gt;

&lt;p&gt;Online shopping platforms rely heavily on analytics.&lt;/p&gt;

&lt;p&gt;Python helps businesses analyze:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer purchasing behavior&lt;/li&gt;
&lt;li&gt;Product recommendations&lt;/li&gt;
&lt;li&gt;Website performance&lt;/li&gt;
&lt;li&gt;Sales trends&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Recommendation systems used by streaming and shopping platforms are often powered by Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  Marketing Analytics
&lt;/h3&gt;

&lt;p&gt;Marketing teams use Python to evaluate campaign performance.&lt;/p&gt;

&lt;p&gt;Analytics helps companies understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Audience engagement&lt;/li&gt;
&lt;li&gt;Advertisement performance&lt;/li&gt;
&lt;li&gt;Customer interests&lt;/li&gt;
&lt;li&gt;Social media trends&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This helps businesses improve their marketing strategies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transportation and Logistics
&lt;/h3&gt;

&lt;p&gt;Transportation companies use Python for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route optimization&lt;/li&gt;
&lt;li&gt;Demand forecasting&lt;/li&gt;
&lt;li&gt;Delivery tracking&lt;/li&gt;
&lt;li&gt;Traffic analysis&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Analytics improves efficiency and reduces operational costs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes Beginners Make When Learning Python
&lt;/h2&gt;

&lt;p&gt;Many beginners struggle because they approach Python the wrong way.&lt;/p&gt;

&lt;p&gt;Some common mistakes include:&lt;/p&gt;

&lt;h3&gt;
  
  
  Trying to Learn Everything at Once
&lt;/h3&gt;

&lt;p&gt;Python is a large language with many areas. Beginners should focus on fundamentals first instead of rushing into advanced topics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Watching Tutorials Without Practicing
&lt;/h3&gt;

&lt;p&gt;Watching videos alone is not enough.&lt;/p&gt;

&lt;p&gt;The best way to learn Python is by writing code regularly and building small projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignoring Real Datasets
&lt;/h3&gt;

&lt;p&gt;Real learning happens when working with messy, real-world data.&lt;/p&gt;

&lt;p&gt;Beginners should practice using datasets from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.kaggle.com/datasets?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Kaggle Datasets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://archive.ics.uci.edu/ml/index.php?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;UCI Machine Learning Repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Focusing Too Much on Syntax
&lt;/h3&gt;

&lt;p&gt;Many beginners try to memorize every command.&lt;/p&gt;

&lt;p&gt;Instead, they should focus on problem-solving and understanding logic.&lt;/p&gt;

&lt;p&gt;Even experienced developers frequently search online for syntax help.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beginner Python Analytics Project Idea
&lt;/h2&gt;

&lt;p&gt;One of the best ways to improve is through projects.&lt;/p&gt;

&lt;p&gt;A simple beginner project could involve analyzing sales data.&lt;/p&gt;

&lt;p&gt;Steps might include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Import a CSV file using Pandas&lt;/li&gt;
&lt;li&gt;Clean missing values&lt;/li&gt;
&lt;li&gt;Calculate total sales&lt;/li&gt;
&lt;li&gt;Identify top-selling products&lt;/li&gt;
&lt;li&gt;Create charts showing trends&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This type of project helps beginners practice real analytics workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Beginners Should Learn Python
&lt;/h2&gt;

&lt;p&gt;Learning Python offers many long-term benefits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Strong Career Opportunities
&lt;/h3&gt;

&lt;p&gt;Many employers actively search for candidates with Python skills.&lt;/p&gt;

&lt;p&gt;Python appears frequently in job descriptions for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data Analysts&lt;/li&gt;
&lt;li&gt;Data Scientists&lt;/li&gt;
&lt;li&gt;Business Analysts&lt;/li&gt;
&lt;li&gt;Machine Learning Engineers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As data continues growing globally, demand for Python skills is expected to remain strong.&lt;/p&gt;

&lt;h3&gt;
  
  
  Easy Entry Into Tech
&lt;/h3&gt;

&lt;p&gt;Python provides a relatively accessible entry point into the technology industry.&lt;/p&gt;

&lt;p&gt;Because it is beginner-friendly, learners can start building useful projects quickly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gateway to Advanced Technologies
&lt;/h3&gt;

&lt;p&gt;Python is heavily used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Artificial intelligence&lt;/li&gt;
&lt;li&gt;Machine learning&lt;/li&gt;
&lt;li&gt;Automation&lt;/li&gt;
&lt;li&gt;Deep learning&lt;/li&gt;
&lt;li&gt;Data science&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Learning Python opens doors to multiple technical career paths.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Future of Python in Data Analytics
&lt;/h2&gt;

&lt;p&gt;Python continues to grow rapidly in popularity.&lt;/p&gt;

&lt;p&gt;As organizations generate more data, the demand for analytical tools increases. Python remains central to this growth because of its flexibility, large community, and extensive library ecosystem.&lt;/p&gt;

&lt;p&gt;Emerging fields such as artificial intelligence, automation, and big data analytics continue relying heavily on Python.&lt;/p&gt;

&lt;p&gt;It is likely that Python will remain one of the dominant programming languages in analytics for many years.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Python has become one of the most important tools in modern data analytics. Its simplicity, flexibility, and powerful libraries make it suitable for both beginners and experienced professionals.&lt;/p&gt;

&lt;p&gt;Through libraries such as Pandas, NumPy, Matplotlib, Seaborn, and Scikit-learn, Python enables analysts to collect, clean, analyze, and visualize data efficiently. Organizations across healthcare, finance, transportation, marketing, and e-commerce rely on Python to make data-driven decisions.&lt;/p&gt;

&lt;p&gt;For beginners interested in analytics, learning Python is one of the best investments they can make. It provides practical problem-solving skills, strong career opportunities, and access to advanced technologies such as machine learning and artificial intelligence.&lt;/p&gt;

&lt;p&gt;Although learning Python requires patience and practice, consistent effort leads to significant growth over time. Starting with small projects, experimenting with real datasets, and practicing regularly can help beginners build confidence and develop valuable analytical skills.&lt;/p&gt;

&lt;p&gt;In a world increasingly driven by data, Python is more than just a programming language. It is a powerful tool that helps transform raw information into meaningful insights that can shape businesses, industries, and society itself.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>python</category>
      <category>datascience</category>
      <category>dataanalytics</category>
    </item>
    <item>
      <title>SQL Subqueries vs CTEs: Types, Differences, Performance, and When to Use Each</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Tue, 21 Apr 2026 11:44:41 +0000</pubDate>
      <link>https://dev.to/audrine_m/sql-subqueries-vs-ctes-types-differences-performance-and-when-to-use-each-4if</link>
      <guid>https://dev.to/audrine_m/sql-subqueries-vs-ctes-types-differences-performance-and-when-to-use-each-4if</guid>
      <description>&lt;p&gt;When working with SQL in analytics, reporting, or data engineering workflows, two powerful tools help structure complex logic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Subqueries&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Common Table Expressions (CTEs)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding when to use each improves &lt;strong&gt;query readability, performance, and maintainability&lt;/strong&gt;—especially when building dashboards or transforming datasets for analysis.&lt;/p&gt;

&lt;p&gt;This article explains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what subqueries are&lt;/li&gt;
&lt;li&gt;types of subqueries&lt;/li&gt;
&lt;li&gt;when to use subqueries&lt;/li&gt;
&lt;li&gt;what CTEs are&lt;/li&gt;
&lt;li&gt;types of CTEs&lt;/li&gt;
&lt;li&gt;performance comparison&lt;/li&gt;
&lt;li&gt;when to choose subqueries vs CTEs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I started paying closer attention to the difference between subqueries and CTEs while working on analytics queries that became harder to debug as they grew more complex.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foksmw0i50mg4m12hht3e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foksmw0i50mg4m12hht3e.png" alt="Subqueries and CTEs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Subquery?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;subquery&lt;/strong&gt; is a query nested inside another SQL query.&lt;/p&gt;

&lt;p&gt;It executes first, and its output becomes input for the outer query.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the inner query calculates the average salary&lt;/li&gt;
&lt;li&gt;the outer query filters employees earning above average&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Subqueries are useful for embedding logic directly inside SQL statements.&lt;/p&gt;




&lt;h2&gt;
  
  
  Types of Subqueries
&lt;/h2&gt;

&lt;p&gt;Subqueries can return different result structures depending on how they are used.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Scalar Subquery
&lt;/h3&gt;

&lt;p&gt;Returns &lt;strong&gt;one value&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use case:&lt;/p&gt;

&lt;p&gt;Comparisons or calculated columns&lt;/p&gt;




&lt;h3&gt;
  
  
  2.  Single-Row Subquery
&lt;/h3&gt;

&lt;p&gt;Returns exactly &lt;strong&gt;one row&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common operators:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=  &amp;gt;  &amp;lt;  &amp;gt;=  &amp;lt;=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Multi-Row Subquery
&lt;/h3&gt;

&lt;p&gt;Returns &lt;strong&gt;multiple rows&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;department_id&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;departments&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;location&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Nairobi'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common operators:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;IN&lt;/span&gt;
&lt;span class="k"&gt;ANY&lt;/span&gt;
&lt;span class="k"&gt;ALL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Correlated Subquery
&lt;/h2&gt;

&lt;p&gt;Runs once &lt;strong&gt;for every row&lt;/strong&gt; in the outer query&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use carefully with large datasets because they may affect performance.&lt;/p&gt;




&lt;h2&gt;
  
  
  When Should You Use Subqueries?
&lt;/h2&gt;

&lt;p&gt;Subqueries are best when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;filtering using aggregated values&lt;/li&gt;
&lt;li&gt;comparing values dynamically&lt;/li&gt;
&lt;li&gt;embedding quick logic inside WHERE clauses&lt;/li&gt;
&lt;li&gt;simplifying small calculations&lt;/li&gt;
&lt;li&gt;avoiding temporary tables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They work especially well when logic is &lt;strong&gt;used once only&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a CTE (Common Table Expression)?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Common Table Expression (CTE)&lt;/strong&gt; is a temporary named result set created using the &lt;code&gt;WITH&lt;/code&gt; clause.&lt;/p&gt;

&lt;p&gt;It improves readability and breaks complex queries into logical steps.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;avg_salary&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;avg_sal&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;avg_salary&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of a CTE as a temporary table that exists during query execution.&lt;/p&gt;




&lt;h2&gt;
  
  
  Types of CTEs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Non-Recursive CTE
&lt;/h3&gt;

&lt;p&gt;Used for simplifying complex logic&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;department_totals&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;department_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;total_salary&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
    &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;department_id&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;department_totals&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Best for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;transformations&lt;/li&gt;
&lt;li&gt;aggregations&lt;/li&gt;
&lt;li&gt;reusable logic&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Recursive CTE
&lt;/h3&gt;

&lt;p&gt;Used for hierarchical datasets&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="k"&gt;RECURSIVE&lt;/span&gt; &lt;span class="n"&gt;employee_hierarchy&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;

    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;manager_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;manager_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;

    &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt;

    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;manager_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
    &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;
    &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;employee_hierarchy&lt;/span&gt; &lt;span class="n"&gt;eh&lt;/span&gt;
    &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;manager_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;eh&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employee_hierarchy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common use cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;organization structures&lt;/li&gt;
&lt;li&gt;category trees&lt;/li&gt;
&lt;li&gt;folder hierarchies&lt;/li&gt;
&lt;li&gt;graph traversal&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Subqueries vs CTEs: Key Differences
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Subqueries&lt;/th&gt;
&lt;th&gt;CTEs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reusability&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debugging&lt;/td&gt;
&lt;td&gt;Harder&lt;/td&gt;
&lt;td&gt;Easier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recursion Support&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best Use Case&lt;/td&gt;
&lt;td&gt;Simple filtering&lt;/td&gt;
&lt;td&gt;Multi-step logic&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Performance Comparison
&lt;/h2&gt;

&lt;p&gt;Performance depends on the database system.&lt;/p&gt;

&lt;p&gt;General guidance:&lt;/p&gt;

&lt;p&gt;Use &lt;strong&gt;subqueries&lt;/strong&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;logic is simple&lt;/li&gt;
&lt;li&gt;result used once&lt;/li&gt;
&lt;li&gt;query is short&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use &lt;strong&gt;CTEs&lt;/strong&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;logic reused multiple times&lt;/li&gt;
&lt;li&gt;queries become complex&lt;/li&gt;
&lt;li&gt;building layered transformations&lt;/li&gt;
&lt;li&gt;working with hierarchies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Test performance using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;EXPLAIN&lt;/span&gt; &lt;span class="k"&gt;ANALYZE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps evaluate execution plans.&lt;/p&gt;




&lt;h2&gt;
  
  
  When Should You Choose Each?
&lt;/h2&gt;

&lt;p&gt;Choose a &lt;strong&gt;subquery&lt;/strong&gt; if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;quick filtering needed&lt;/li&gt;
&lt;li&gt;used inside WHERE clause&lt;/li&gt;
&lt;li&gt;logic simple&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choose a &lt;strong&gt;CTE&lt;/strong&gt; if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;readability matters&lt;/li&gt;
&lt;li&gt;transformation steps needed&lt;/li&gt;
&lt;li&gt;recursion required&lt;/li&gt;
&lt;li&gt;logic reused multiple times&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Both subqueries and CTEs are essential SQL tools for analysts and BI professionals.&lt;/p&gt;

&lt;p&gt;Subqueries help embed quick logic inside statements.&lt;/p&gt;

&lt;p&gt;CTEs improve structure, readability, and scalability—especially in analytics pipelines and dashboards.&lt;/p&gt;

&lt;p&gt;Knowing when to use each makes your SQL cleaner, faster to debug, and easier to maintain.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>datascience</category>
      <category>beginners</category>
      <category>database</category>
    </item>
    <item>
      <title>How to publish a Power BI report and embed it into a website.</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Sun, 05 Apr 2026 15:58:02 +0000</pubDate>
      <link>https://dev.to/audrine_m/how-to-publish-a-power-bi-report-and-embed-it-into-a-website-4lb9</link>
      <guid>https://dev.to/audrine_m/how-to-publish-a-power-bi-report-and-embed-it-into-a-website-4lb9</guid>
      <description>&lt;p&gt;Microsoft Power BI is a powerful business intelligence tool that enables users to transform raw data into interactive dashboards and reports. One of its most useful features is the ability to publish reports to the Power BI Service and embed them into websites for sharing insights with a wider audience.&lt;/p&gt;

&lt;p&gt;This guide walks through the full process step by step: creating a workspace, publishing a report, generating embed code, and embedding the report into a website.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Create a Workspace in Power BI Service
&lt;/h2&gt;

&lt;p&gt;A workspace is a collaborative environment where reports, dashboards, and datasets are stored before publishing or sharing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Sign in to &lt;strong&gt;Power BI Service&lt;/strong&gt; (&lt;a href="https://app.powerbi.com" rel="noopener noreferrer"&gt;https://app.powerbi.com&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;From the left navigation panel, select &lt;strong&gt;Workspaces&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;New workspace&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a workspace name and description.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq89u4512hp3umcrchc7o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq89u4512hp3umcrchc7o.png" alt="My Workspaces" width="800" height="364"&gt;&lt;/a&gt; &lt;br&gt;
Then proceed to add New Workspace&lt;/p&gt;

&lt;p&gt;Why this matters:&lt;br&gt;
Workspaces help organize reports and control access permissions for collaboration and publishing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Upload and Publish Your Report
&lt;/h2&gt;

&lt;p&gt;Once your workspace is ready, the next step is publishing your Power BI Desktop report.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open your report in &lt;strong&gt;Power BI Desktop&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;File → Publish&lt;/strong&gt; or select &lt;strong&gt;Publish&lt;/strong&gt; from the Home ribbon.&lt;/li&gt;
&lt;li&gt;Choose your created workspace.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Select&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Wait for the confirmation message indicating successful publishing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4tnjytk6h3c6l2d3van.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4tnjytk6h3c6l2d3van.png" alt="Publish Button" width="800" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why this matters:&lt;br&gt;
Publishing moves your report from local development to the cloud where it can be shared and embedded.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Generate the Embed Code
&lt;/h2&gt;

&lt;p&gt;After publishing the report, you can generate embed code from Power BI Service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Power BI Service&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Navigate to your workspace.&lt;/li&gt;
&lt;li&gt;Select your report.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;File → Embed report → Publish to web (public)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Confirm the security warning.&lt;/li&gt;
&lt;li&gt;Copy the generated HTML iframe embed code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9exb2ek1n41oydlnfcr9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9exb2ek1n41oydlnfcr9.png" alt="Embed Report" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rs86zn917fmgy3jq7v3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rs86zn917fmgy3jq7v3.png" alt="iFrame" width="778" height="121"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why this matters:&lt;br&gt;
The iframe embed code allows your report to be displayed inside a webpage.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Embed the Report on a Website
&lt;/h2&gt;

&lt;p&gt;Once the embed code is generated, you can place it inside your website's HTML.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example HTML Code:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;iframe&lt;/span&gt;
    &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"800"&lt;/span&gt;
    &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"600"&lt;/span&gt;
    &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://app.powerbi.com/view?r=YOUR_EMBED_LINK"&lt;/span&gt;
    &lt;span class="na"&gt;frameborder=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt;
    &lt;span class="na"&gt;allowFullScreen=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/iframe&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open your website HTML file.&lt;/li&gt;
&lt;li&gt;Paste the iframe code where the report should appear.&lt;/li&gt;
&lt;li&gt;Save changes.&lt;/li&gt;
&lt;li&gt;Refresh your webpage.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd6j983dkrzgvqljmu7ol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd6j983dkrzgvqljmu7ol.png" alt="Web Example" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why this matters:&lt;br&gt;
Embedding enables stakeholders and users to interact with dashboards without logging into Power BI.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Insights and Best Practices
&lt;/h2&gt;

&lt;p&gt;Publishing and embedding Power BI reports makes insights accessible to a broader audience. However, it is important to understand visibility settings before sharing.&lt;/p&gt;

&lt;p&gt;Key takeaways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Workspaces help manage report access and organization.&lt;/li&gt;
&lt;li&gt;Publishing moves reports from Desktop to Power BI Service.&lt;/li&gt;
&lt;li&gt;Embed codes allow reports to be integrated into websites.&lt;/li&gt;
&lt;li&gt;"Publish to web" makes reports publicly accessible, so sensitive data should not be included.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Publishing and embedding Power BI reports is a straightforward process that significantly enhances data accessibility and collaboration. By following these steps, you can successfully move your report from Power BI Desktop to a live website and share insights interactively with your audience.&lt;/p&gt;

&lt;p&gt;Adding screenshots at each step improves clarity and helps users follow the workflow more easily.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>analytics</category>
    </item>
    <item>
      <title>Understanding Data Modeling in Power BI: Joins, Relationships, and Schemas Explained</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Sun, 29 Mar 2026 20:30:09 +0000</pubDate>
      <link>https://dev.to/audrine_m/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-5h02</link>
      <guid>https://dev.to/audrine_m/understanding-data-modeling-in-power-bi-joins-relationships-and-schemas-explained-5h02</guid>
      <description>&lt;p&gt;Data modeling is the backbone of every effective Power BI report. If dashboards feel slow, filters behave incorrectly, or numbers don’t match expectations, the issue is often the data model not the visuals.&lt;/p&gt;

&lt;p&gt;This guide explains how data modeling works in Power BI step‑by‑step. You’ll learn SQL joins, relationships, schemas, fact vs dimension tables, role‑playing dimensions, and how everything is created inside Power BI itself.&lt;/p&gt;

&lt;p&gt;This article is beginner‑friendly but structured like a professional BI reference.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Data Modeling?
&lt;/h2&gt;

&lt;p&gt;Data modeling is the process of organizing tables and defining how they relate so reports are accurate, scalable, and fast.&lt;/p&gt;

&lt;p&gt;In Power BI, good data modeling helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;connect multiple datasets&lt;/li&gt;
&lt;li&gt;control filter behavior&lt;/li&gt;
&lt;li&gt;improve performance&lt;/li&gt;
&lt;li&gt;enable time intelligence&lt;/li&gt;
&lt;li&gt;prevent duplicate counting&lt;/li&gt;
&lt;li&gt;support executive‑level reporting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Power BI primarily uses &lt;strong&gt;relationships instead of joins&lt;/strong&gt; during analysis.&lt;/p&gt;




&lt;h2&gt;
  
  
  SQL Joins Explained (With Real Examples)
&lt;/h2&gt;

&lt;p&gt;SQL joins combine tables physically in &lt;strong&gt;Power Query&lt;/strong&gt; before loading data into the model.&lt;/p&gt;

&lt;p&gt;Location in Power BI:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Transform Data → Merge Queries&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furf8lswibpdw45gkyf5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furf8lswibpdw45gkyf5b.png" alt="Power BI Merge Queries window showing how SQL joins are created in Power Query" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  INNER JOIN
&lt;/h3&gt;

&lt;p&gt;Returns only matching records in both tables.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Customers Table&lt;br&gt;&lt;br&gt;
Orders Table  &lt;/p&gt;

&lt;p&gt;Result: Only customers who placed orders appear.&lt;/p&gt;

&lt;p&gt;Real‑life analytics use case:&lt;br&gt;&lt;br&gt;
Analyzing purchasing customers only.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmefu463mf5k8o3vt9i66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmefu463mf5k8o3vt9i66.png" alt="inner join" width="783" height="409"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  LEFT JOIN (LEFT OUTER JOIN)
&lt;/h3&gt;

&lt;p&gt;Returns all rows from the left table and matching rows from the right.&lt;/p&gt;

&lt;p&gt;Use case:&lt;br&gt;&lt;br&gt;
Customer engagement analysis including inactive customers&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxliae9q3pcvk8l2kquno.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxliae9q3pcvk8l2kquno.png" alt="left join" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  RIGHT JOIN (RIGHT OUTER JOIN)
&lt;/h3&gt;

&lt;p&gt;Returns all rows from the right table and matching rows from the left.&lt;/p&gt;

&lt;p&gt;Use case:&lt;br&gt;&lt;br&gt;
Transaction completeness audits&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fafedizmfk2zlscijtzng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fafedizmfk2zlscijtzng.png" alt="Right Join" width="340" height="309"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  FULL OUTER JOIN
&lt;/h3&gt;

&lt;p&gt;Returns all rows from both tables.&lt;/p&gt;

&lt;p&gt;Use case:&lt;br&gt;&lt;br&gt;
Data reconciliation between systems&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqinwdn10lfrvxx0wcqp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqinwdn10lfrvxx0wcqp.png" alt="Full Outer Join" width="246" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F961xqltvxbnel78t7hux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F961xqltvxbnel78t7hux.png" alt="Full Outer Join" width="148" height="106"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  LEFT ANTI JOIN
&lt;/h3&gt;

&lt;p&gt;Returns rows from the left table with &lt;strong&gt;no matches&lt;/strong&gt; in the right table.&lt;/p&gt;

&lt;p&gt;Use case:&lt;br&gt;&lt;br&gt;
Customer churn targeting&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwz52zuxcvx2uc25lq0pj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwz52zuxcvx2uc25lq0pj.png" alt="Left Anti Join" width="366" height="423"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  RIGHT ANTI JOIN
&lt;/h3&gt;

&lt;p&gt;Returns rows from the right table with &lt;strong&gt;no matches&lt;/strong&gt; in the left table.&lt;/p&gt;

&lt;p&gt;Use case:&lt;br&gt;&lt;br&gt;
Data quality audits&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3n0s21fj52wg5j8pt77y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3n0s21fj52wg5j8pt77y.png" alt="Right Anti Join" width="373" height="415"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Relationships in Power BI
&lt;/h2&gt;

&lt;p&gt;Relationships connect tables &lt;strong&gt;logically instead of physically merging them&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Location:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Model View → Drag column between tables&lt;/code&gt;&lt;br&gt;&lt;br&gt;
OR&lt;br&gt;&lt;br&gt;
&lt;code&gt;Home → Manage Relationships → New&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2gjqf6x79f96qagzvgn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2gjqf6x79f96qagzvgn.png" alt="Power BI Model View showing relationships between fact and dimension tables" width="748" height="337"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Types of Relationships
&lt;/h2&gt;

&lt;h3&gt;
  
  
  One‑to‑Many (1:M)
&lt;/h3&gt;

&lt;p&gt;Most common relationship type.&lt;br&gt;&lt;br&gt;
Example: DimCustomer → FactSales&lt;/p&gt;

&lt;p&gt;DimCustomer (1)&lt;br&gt;
┌──────────────┐&lt;br&gt;
│ Customer ID  │&lt;br&gt;
│ Customer Name│&lt;br&gt;
│ Region       │&lt;br&gt;
└──────┬───────┘&lt;br&gt;
       │&lt;br&gt;
       │&lt;br&gt;
       │&lt;br&gt;
       ▼&lt;br&gt;
FactSales (Many)&lt;br&gt;
┌──────────────┐&lt;br&gt;
│ Order ID     │&lt;br&gt;
│ Customer ID  │&lt;br&gt;
│ Sales Amount │&lt;br&gt;
│ Quantity     │&lt;br&gt;
└──────────────┘&lt;br&gt;
One-to-Many relationship: One customer can appear multiple times in the sales table.&lt;/p&gt;




&lt;h3&gt;
  
  
  Many‑to‑Many (M:M)
&lt;/h3&gt;

&lt;p&gt;Occurs when both tables contain duplicate keys.&lt;br&gt;&lt;br&gt;
Example: Students ↔ Courses&lt;/p&gt;

&lt;p&gt;Students&lt;br&gt;
┌──────────────┐&lt;br&gt;
│ Student ID   │&lt;br&gt;
│ Student Name │&lt;br&gt;
└──────┬───────┘&lt;br&gt;
       │&lt;br&gt;
       │&lt;br&gt;
       ▼&lt;br&gt;
Enrollment (Bridge Table)&lt;br&gt;
┌──────────────┐&lt;br&gt;
│ Student ID   │&lt;br&gt;
│ Course ID    │&lt;br&gt;
└──────┬───────┘&lt;br&gt;
       │&lt;br&gt;
       │&lt;br&gt;
       ▼&lt;br&gt;
Courses&lt;br&gt;
┌──────────────┐&lt;br&gt;
│ Course ID    │&lt;br&gt;
│ Course Name  │&lt;br&gt;
└──────────────┘&lt;br&gt;
Many-to-Many relationship resolved using a bridge table between Students and Courses.&lt;/p&gt;




&lt;h3&gt;
  
  
  One‑to‑One (1:1)
&lt;/h3&gt;

&lt;p&gt;Rare but useful.&lt;br&gt;&lt;br&gt;
Example: Employee table ↔ Employee security table&lt;br&gt;
Employees&lt;br&gt;
┌──────────────┐&lt;br&gt;
│ Employee ID  │&lt;br&gt;
│ Name         │&lt;br&gt;
│ Department   │&lt;br&gt;
└──────┬───────┘&lt;br&gt;
       │&lt;br&gt;
       │&lt;br&gt;
       ▼&lt;br&gt;
EmployeeSecurity&lt;br&gt;
┌──────────────┐&lt;br&gt;
│ Employee ID  │&lt;br&gt;
│ Access Level │&lt;br&gt;
│ Login Role   │&lt;br&gt;
└──────────────┘&lt;br&gt;
One-to-One relationship: Each employee record matches exactly one security profile.&lt;/p&gt;




&lt;h2&gt;
  
  
  Active vs Inactive Relationships
&lt;/h2&gt;

&lt;p&gt;Power BI allows multiple relationships between tables but only one active at a time.&lt;br&gt;
                DimDate&lt;br&gt;
            ┌──────────────┐&lt;br&gt;
            │ Date         │&lt;br&gt;
            └──────┬───────┘&lt;br&gt;
                   │&lt;br&gt;
        (Active) ──┼──────── OrderDate&lt;br&gt;
                   │&lt;br&gt;
     (Inactive) ─ ─┼──────── ShipDate&lt;br&gt;
                   │&lt;br&gt;
     (Inactive) ─ ─┼──────── DeliveryDate&lt;br&gt;
                   │&lt;br&gt;
               FactSales&lt;/p&gt;

&lt;p&gt;Active relationship (solid line) filters visuals automatically, while inactive relationships (dashed lines) require USERELATIONSHIP() in DAX.&lt;/p&gt;




&lt;h2&gt;
  
  
  Cardinality Explained
&lt;/h2&gt;

&lt;p&gt;Cardinality describes table relationship structure:&lt;br&gt;&lt;br&gt;
One‑to‑Many, Many‑to‑One, Many‑to‑Many, One‑to‑One&lt;/p&gt;

&lt;p&gt;Location:&lt;br&gt;&lt;br&gt;
&lt;code&gt;Manage Relationships → Cardinality dropdown&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Cross Filter Direction
&lt;/h2&gt;

&lt;p&gt;Controls how filters move between tables.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Single Direction (recommended) vs Bi‑Directional
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Difference Between Joins and Relationships
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Power Query Joins:&lt;/strong&gt; Combine tables physically, run before loading, increase table size
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relationships:&lt;/strong&gt; Connect tables logically, run after loading, improve performance
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Fact vs Dimension Tables
&lt;/h2&gt;

&lt;p&gt;Fact Tables contain numeric values (Sales Amount, Revenue, Quantity)&lt;br&gt;&lt;br&gt;
Dimension Tables contain descriptive attributes (Customer Name, Product Category, Region)&lt;/p&gt;




&lt;h2&gt;
  
  
  Star Schema (Recommended Model)
&lt;/h2&gt;

&lt;p&gt;Fact table at center, dimension tables surrounding.&lt;br&gt;&lt;br&gt;
Fast performance, simple relationships, scalable dashboards.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2eonqumsxstkxm8r80ub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2eonqumsxstkxm8r80ub.png" alt="Star schema example with FactSales connected to dimension tables Customer, Product, and Date" width="544" height="711"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Snowflake Schema
&lt;/h2&gt;

&lt;p&gt;Dimensions split into multiple related tables.&lt;br&gt;&lt;br&gt;
Reduced redundancy but more complex filtering.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                DimDepartment
              ┌──────────────┐
              │ Dept ID      │
              │ Dept Name    │
              └──────┬───────┘
                     │
                     │
                DimCategory
              ┌──────────────┐
              │ Category ID  │
              │ Category Name│
              └──────┬───────┘
                     │
                     │
                DimProduct
              ┌──────────────┐
              │ Product ID   │
              │ Product Name │
              └──────┬───────┘
                     │
                     │
             ┌───────▼────────┐
             │    FactSales   │
             │ Sales Amount   │
             │ Quantity       │
             │ Revenue        │
             │ Order ID       │
             └───────┬────────┘
                     │
                     │
                DimCustomer
              ┌──────────────┐
              │ Customer ID  │
              │ Customer Name│
              │ Region       │
              └──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h2&gt;
  
  
  Flat Table (Denormalized / DLAT Model)
&lt;/h2&gt;

&lt;p&gt;All fields stored inside one table.&lt;br&gt;&lt;br&gt;
Simple setup but poor scalability.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Flat Table (Sales Dataset)
        ┌───────────────────────────────┐
        │ Order ID                      │
        │ Order Date                    │
        │ Customer ID                   │
        │ Customer Name                 │
        │ Region                        │
        │ Product ID                    │
        │ Product Name                  │
        │ Category                      │
        │ Department                    │
        │ Sales Amount                  │
        │ Quantity                      │
        │ Revenue                       │
        └───────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Example Flat Table (DLAT Model): All descriptive and transactional fields stored inside a single table without relationships between dimensions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Role‑Playing Dimensions
&lt;/h2&gt;

&lt;p&gt;One dimension reused multiple times (e.g., Date table as Order Date, Ship Date, Delivery Date).&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Data Modeling Mistakes in Power BI
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Circular relationships
&lt;/li&gt;
&lt;li&gt;Duplicate keys
&lt;/li&gt;
&lt;li&gt;Many‑to‑many misuse
&lt;/li&gt;
&lt;li&gt;Too many bi‑directional filters
&lt;/li&gt;
&lt;li&gt;Over‑joining tables in Power Query
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step‑by‑Step Modeling Workflow in Power BI
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Home → Get Data
&lt;/li&gt;
&lt;li&gt;Transform Data → Power Query
&lt;/li&gt;
&lt;li&gt;Merge tables if required
&lt;/li&gt;
&lt;li&gt;Create relationships
&lt;/li&gt;
&lt;li&gt;Validate cardinality
&lt;/li&gt;
&lt;li&gt;Test filter flow
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3n2djhg8uksiq9jkihh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3n2djhg8uksiq9jkihh.png" alt="Step‑by‑Step Modeling Workflow in Power BI" width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Generally
&lt;/h2&gt;

&lt;p&gt;Strong data modeling transforms dashboards into decision systems.&lt;br&gt;&lt;br&gt;
Master joins, schemas, and relationships to move from report builder to analytics engineer.&lt;/p&gt;

</description>
      <category>powerbi</category>
      <category>dataanalytics</category>
      <category>businessintelligence</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How Excel is Used in Real-World Data Analysis</title>
      <dc:creator>Audrine Marion</dc:creator>
      <pubDate>Mon, 23 Mar 2026 16:17:18 +0000</pubDate>
      <link>https://dev.to/audrine_m/how-excel-is-used-in-real-world-data-analysis-4m66</link>
      <guid>https://dev.to/audrine_m/how-excel-is-used-in-real-world-data-analysis-4m66</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Excel is one of the most widely used tools for data analysis across industries. Although newer technologies like Python, SQL, and Power BI are becoming more common, Excel remains a foundational skill for anyone working with data. It allows analysts to organize information, clean datasets, perform calculations, explore patterns, and present insights in a structured and accessible way.&lt;/p&gt;

&lt;p&gt;Because of its flexibility and ease of use, Excel is often the first tool professionals rely on when working with raw data before moving into more advanced analytics environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Excel?
&lt;/h2&gt;

&lt;p&gt;Excel is a spreadsheet application developed by Microsoft that allows users to store, organize, calculate, and analyze data using rows and columns. It provides built-in formulas, visualization tools, Pivot Tables, and automation features that help transform raw numbers into meaningful insights.&lt;/p&gt;

&lt;p&gt;In real-world data analysis, Excel is commonly used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cleaning messy datasets&lt;/li&gt;
&lt;li&gt;Performing calculations&lt;/li&gt;
&lt;li&gt;Summarizing large datasets&lt;/li&gt;
&lt;li&gt;Identifying trends and patterns&lt;/li&gt;
&lt;li&gt;Creating dashboards and reports&lt;/li&gt;
&lt;li&gt;Supporting business decision-making&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Real-World Applications of Excel in Data Analysis
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Data Cleaning
&lt;/h3&gt;

&lt;p&gt;Before analysis begins, datasets often contain missing values, duplicates, or formatting issues. Excel helps analysts prepare datasets using tools such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove Duplicates&lt;/li&gt;
&lt;li&gt;Find and Replace&lt;/li&gt;
&lt;li&gt;Text-to-Columns&lt;/li&gt;
&lt;li&gt;Sorting and Filtering&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These features ensure that data is accurate and ready for analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Data Summarization Using Pivot Tables
&lt;/h2&gt;

&lt;p&gt;Pivot Tables are one of Excel’s most powerful tools. They allow analysts to quickly summarize large datasets and answer important questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which product generated the highest revenue?&lt;/li&gt;
&lt;li&gt;Which region had the most customers?&lt;/li&gt;
&lt;li&gt;Which month recorded the highest sales?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of manually calculating totals, Pivot Tables automatically group and summarize information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm50re12oj67hnittjt41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm50re12oj67hnittjt41.png" alt="Excel Pivot Table summarizing sales data by region and product category"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;example of pivot table showing the sum of bonus by location&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pivot Tables help analysts transform raw datasets into structured summaries within seconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Using Formulas for Analysis
&lt;/h2&gt;

&lt;p&gt;Excel formulas help analysts perform calculations efficiently and accurately.&lt;/p&gt;

&lt;h3&gt;
  
  
  SUM Function
&lt;/h3&gt;

&lt;p&gt;Used to calculate totals such as total sales or expenses.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=SUM(B2:B100)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Used in scenarios like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;calculating monthly expenses&lt;/li&gt;
&lt;li&gt;total company revenue&lt;/li&gt;
&lt;li&gt;inventory totals&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  IF Function
&lt;/h3&gt;

&lt;p&gt;Used to apply logical conditions to categorize data.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=IF(B2&amp;gt;50,"Pass","Fail")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real-world uses include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;grading systems&lt;/li&gt;
&lt;li&gt;customer segmentation&lt;/li&gt;
&lt;li&gt;performance classification&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  VLOOKUP Function
&lt;/h3&gt;

&lt;p&gt;Used to retrieve matching values from another table.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=VLOOKUP(A2,Sheet2!A:B,2,FALSE)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Analysts commonly use this when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;merging customer records&lt;/li&gt;
&lt;li&gt;matching product IDs&lt;/li&gt;
&lt;li&gt;combining datasets from multiple sheets&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Data Visualization
&lt;/h2&gt;

&lt;p&gt;Excel allows analysts to create charts such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bar charts&lt;/li&gt;
&lt;li&gt;Line charts&lt;/li&gt;
&lt;li&gt;Pie charts&lt;/li&gt;
&lt;li&gt;Column charts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These visualizations make it easier to communicate findings clearly to stakeholders who may not have technical backgrounds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzdbsgk6kgnfx9onxr1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzdbsgk6kgnfx9onxr1r.png" alt="Excel column chart showing monthly sales trends across three months"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Example Excel line chart showing average salary across month of hire.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  5. Conditional Formatting for Insight Discovery
&lt;/h2&gt;

&lt;p&gt;Conditional formatting highlights important values automatically.&lt;/p&gt;

&lt;p&gt;Example uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;highlighting top-performing regions&lt;/li&gt;
&lt;li&gt;identifying missing values&lt;/li&gt;
&lt;li&gt;detecting unusually high expenses&lt;/li&gt;
&lt;li&gt;spotting declining performance trends&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2irljn0zj97odxzjhfr8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2irljn0zj97odxzjhfr8.png" alt="Excel dataset using conditional formatting to highlight high and low values"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Example of conditional formatting that highlights performance score greater than 5&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This improves readability and makes patterns visible immediately.&lt;/p&gt;




&lt;h2&gt;
  
  
  Features I Have Learned and Applied When Working with Data
&lt;/h2&gt;

&lt;p&gt;While learning Excel, I gained experience using several important features that support data analysis workflows.&lt;/p&gt;

&lt;p&gt;Pivot Tables helped me summarize datasets quickly and identify trends without writing complex formulas.&lt;/p&gt;

&lt;p&gt;The IF function allowed me to categorize data into meaningful groups, making it easier to interpret results.&lt;/p&gt;

&lt;p&gt;VLOOKUP helped me combine information from multiple tables, which is especially useful when working with relational datasets.&lt;/p&gt;

&lt;p&gt;Conditional formatting helped highlight important values such as high-performing regions or missing data points, making datasets easier to understand visually.&lt;/p&gt;

&lt;h2&gt;
  
  
  These tools significantly improved my ability to explore and interpret datasets efficiently.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Personal Reflection
&lt;/h2&gt;

&lt;p&gt;Learning Excel has changed the way I approach data. Previously, I mainly viewed data as numbers arranged in tables, but Excel helped me understand how structured analysis can reveal meaningful insights and patterns.&lt;/p&gt;

&lt;p&gt;Through practicing formulas, Pivot Tables, and visualization techniques, I became more confident in cleaning datasets, summarizing information, and presenting findings clearly. Excel also strengthened my problem-solving skills by teaching me how to break down datasets into manageable steps during analysis.&lt;/p&gt;

&lt;p&gt;As someone building a career in data analytics and data science, learning Excel has been an important step in developing my analytical thinking. It has helped me move from simply observing data to actively exploring it and using it to support informed decisions.&lt;/p&gt;

&lt;p&gt;Overall, Excel has become a valuable foundation in my data analysis journey, and it continues to support my growth as I expand my skills into more advanced tools and technologies.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>analytics</category>
      <category>analyst</category>
    </item>
  </channel>
</rss>
