Lesson 2 Β· Foundations

What is Machine Learning?

Machine Learning (ML) is a way to build systems that learn patterns from examples and use those patterns to make predictions or decisions on new data.

The simple idea: Instead of writing every rule by hand, we give a machine examples and let an algorithm learn a useful pattern from those examples.

Why do we need Machine Learning?

Many real-world problems contain too many patterns to describe with a fixed list of rules. Consider an email spam filter. A message can be spam because of its words, sender, links, formatting, timing, and many combinations of these signals.

We could manually write hundreds or thousands of rules, but those rules would be difficult to maintain. Machine learning takes a different approach: learn from examples of messages that people have already labeled as spam or not spam.

EXAMPLE 1 Β· EMAIL SPAM

Traditional rules vs machine learning

A rule-based system might say: β€œIf the message contains this word, mark it as spam.” An ML system can learn that many signals together are associated with spam.

EXAMPLE 2 Β· ONLINE STORE

Predicting whether a customer may buy

An online store can learn from historical customer behavior. The model may use signals such as pages viewed, products added to a cart, previous purchases, and time spent on a product page to predict purchase likelihood.

How Machine Learning works

At a high level, an ML system follows a simple loop: collect examples, represent the examples as data, train a model to find patterns, then use the trained model to make predictions on data it has not seen before.

ExamplesPast data
β†’
LearningFind patterns
β†’
ModelLearned rules
β†’
PredictionNew data

A concrete example

Imagine that we want to predict whether a support ticket should go to the billing team. We start with historical tickets that have already been routed. The examples teach the model which words and patterns are associated with billing requests.

Python
# A tiny rule-based example to understand the idea

def route_ticket(message):
    text = message.lower()

    if "payment" in text or "refund" in text:
        return "Billing"

    if "password" in text or "login" in text:
        return "Account Support"

    return "General Support"


ticket = "I need a refund for my payment"

print(route_ticket(ticket))
OUTPUTBilling

This first example is intentionally rule-based, not machine learning. That distinction is important. We wrote the conditions ourselves. ML changes the learning step: instead of manually specifying every condition, an algorithm learns parameters from training examples.

From rules to learning

Here is the key difference. In a traditional program, a developer writes the rules and the computer applies them. In machine learning, we provide data and a learning algorithm; the resulting model captures patterns that can be applied to new inputs.

TraditionalRules + Data β†’ Output
vs
Machine LearningData + Answers β†’ Model
β†’
New dataModel β†’ Prediction

Training data, model, and prediction

1. Training data

Training data is the collection of examples used to teach a model. In supervised learning, each example usually includes an input and a known answer called a label.

2. Model

A model is the learned mathematical representation of patterns in the training data. Different algorithms learn different kinds of patterns.

3. Prediction

After training, we pass new input into the model. The model produces a prediction, classification, score, or another useful output.

Three common types of Machine Learning

SUPERVISED LEARNING

Learn from labeled examples. Example: predict whether an email is spam or not spam.

UNSUPERVISED LEARNING

Find structure in data without provided labels. Example: group customers into behavior-based segments.

REINFORCEMENT LEARNING

Learn through actions and feedback. Example: an agent learns a strategy by receiving rewards or penalties.

PRACTICE Β· UNDERSTAND

Change the support-ticket example

Add a third category called Shipping Support. Make tickets containing β€œdelivery” or β€œtracking” return that category. Then test three different messages.

Open a Python notebook in Google Colab β†—
PRACTICE Β· BUILD

Think like an ML engineer

Write down five historical support messages and label each one as Billing, Account Support, or Shipping Support. Ask yourself: what information would a model need to learn this classification automatically?

Quick check: What is the biggest difference between traditional programming and machine learning?

Recap

  • Machine learning lets systems learn useful patterns from data.
  • Training examples are used to create a model.
  • The trained model can make predictions on new data.
  • Supervised, unsupervised, and reinforcement learning are three major ML approaches.
  • Machine learning is one important part of the broader field of AI.
Next: In the next lesson, we will see how Deep Learning uses neural networks to learn much more complex patterns from data.