From Rules to Learning: A Beginner’s Guide to How Machine Learning Really Works
Source: Canva

From Rules to Learning: A Beginner’s Guide to How Machine Learning Really Works

Have you ever wondered how your email knows what’s spam and what’s not or how Netflix seems to know exactly what you’ll enjoy next?

That’s not magic, it’s machine learning.

In this article, we’ll strip away the technical fog and walk through what machine learning really means, how it differs from traditional programming, and how computers actually “learn” from data all explained in plain, human language.

 From Rules to Learning (The Old vs. New Way)

Before machine learning, programmers relied on rule-based systems a world of if-else statements.

Let’s imagine you’re building a spam filter. You might start with rules like:

  • If the subject contains “lottery,” mark as spam.
  • If the sender ends with “@promo.com,” mark as spam.

At first, it works fine. But soon, spammers change tactics. They use new words, different domains, and clever tricks. You keep adding more rules until the system becomes messy, fragile, and impossible to maintain.

That’s the hamster wheel of rule-based systems. You’re stuck chasing data instead of learning from it.

How Does Machine Learning Really Work?

“Ever wondered how machines actually learn patterns without being told what to do?”

Instead of defining endless rules, machine learning lets the computer learn patterns from data itself.

Here’s the new approach:

  1. Collect data — collect examples of spam and non-spam emails.
  2. Extract features — identify measurable traits, like subject length or specific words.
  3. Train the model — let the machine find patterns between the features and the correct labels (spam = 1, not spam = 0).
  4. Apply the model — use it to predict whether new emails are spam, based on what it has learned.

With enough examples, the machine starts recognizing spam better than your old rule-based code ever could.

How Machines Learn (Training vs. Using a Model)

To understand machine learning better, we have to distinguish between three important terms feature, target and model.

Features are the clues. They are the individual bits of information we know about something. For a car, the features could be its brand, color, engine size, and mileage.

The target is the answer. It's the specific thing we want to predict or find out. For example, if we want to predict a car's price, the price is our target. In training, we use data where the answer (the target) is already known.

A model is the recipe. It's a program that learns from the clues and answers in your training data to find a hidden pattern. Once trained, you can give the model the clues for a new object (a new car's features) and it will use its recipe to predict the answer (its price).

Think of machine learning as a two-step process: training and using.

Training a Model:

When you train a model, you feed it examples that contain both features (inputs) and targets (correct answers).

In our spam filter example:

  • Features could be: the sender’s address, subject line, and number of links.
  • Target: whether the email is spam (1) or not (0).

The model studies thousands of these examples to discover the relationship between the features and the target. You can think of this as teaching a student: “Here are the questions and their correct answers now learn the pattern.”

After training, you now have a model a mathematical representation of all those learned patterns.

Using a Model:

When a new email arrives, the model looks at its features and predicts a probability say, 0.9 (very likely spam) or 0.2 (probably not spam). We then set a threshold for example, 0.5 to decide whether to mark it as spam.

That’s the essence of using a trained machine learning model.

Types of Machine Learning

Machine Learning comes in different flavors depending on how the computer learns from data.

At a high level, there are three main types you’ll often encounter:

  1. Supervised Learning: This is the most common type and the easiest to grasp. Here, the machine learns from labeled data examples where both the input and the correct output are known. Think of it like a student learning with an answer key: “Here’s the question (input), and here’s the correct answer (label).” Example: Predicting whether an email is spam or not where each example is labeled “spam” or “not spam.” We’ll dive deeper into this type shortly.
  2. Unsupervised Learning: Here, the machine is given unlabeled data it has no answers, just raw information. Its job is to find patterns or group similar data points together. Think of it as exploring a new city with no map just noticing which neighborhoods feel alike. Examples: Clustering: Grouping customers with similar buying behavior. Association: Finding items that are often bought together (like “people who bought X also bought Y”).
  3. Reinforcement Learning: This is learning by trial and error just like how humans or animals learn through experience. The model (called an agent) interacts with an environment, takes actions, and receives rewards or penalties. Over time, it learns to make better decisions to maximize its total reward. Examples: Self-driving cars learning to stay on track, Robots learning to walk, Game AI learning to beat human players.

Now that we’ve met the main types of ML, let’s take a closer look at the one you’ll encounter most often, Supervised Learning.

What is Supervised Machine Learning?

Machine learning has many flavors, but one of the most common and beginner-friendly is Supervised Learning.

“Supervised” means we act as teachers showing the model both the examples and the correct answers during training.

In simple terms:

Supervised learning is about finding a function that maps input data (X) to output labels (y).

  • X → the features (what we know)
  • y → the target (what we want to predict)
  • g(X) → the model (what learns the pattern)

Formally, the model tries to find a function g such that g(X) ≈ y.

Of course, it won’t be perfect but the goal is to be as close as possible.

Types of Supervised Learning

  1. Regression: Used when you’re predicting continuous values. Example: Predicting the price of a car or house. The output is a number
  2. Classification: Used when you’re predicting categories or labels. Example: Deciding whether an email is spam or not. → The output is a class (0 or 1, cat or dog, etc.). Binary classification – two possible outcomes. Multiclass classification – more than two outcomes.
  3. Ranking: Used when you want to rank or prioritize items like assigning scores to items so we can sort them. Example: Google search results or e-commerce product recommendations. → The model gives each item a score, and the top ones appear first.

At its heart, machine learning is about discovering patterns in data so that computers can make predictions not by following hard-coded rules, but by learning from experience.

When we move from writing rules to teaching machines, we create systems that can adapt, scale, and even surprise us.

That’s the beauty of ML. It’s not about replacing humans, but about learning how to teach computers to think a little more like us.

Note: If you remember one thing from this article, let it be this;

“Machine learning doesn’t mean programming every decision it means programming the ability to learn.”

Further Reading & References

ML Zoomcamp by Alexey Grigorev - a fantastic free course for beginners.

Google Machine Learning Crash Course - interactive lessons with visual explanations.

  • Machine Learning Yearning by Andrew Ng (Free PDF online)
  • Python Machine Learning by Sebastian Raschka & Vahid Mirjalili
  • Deep Learning with Python by François Chollet


To view or add a comment, sign in

Others also viewed

Explore content categories