Machine Learning Introduction

What machine learning is, and supervised, unsupervised and reinforcement learning explained with concrete examples.

What machine learning is

Machine learning (ML) is the practice of building systems that learn patterns from data instead of being explicitly programmed with rules for every case. Instead of a developer writing if email contains "free money" then mark as spam, you show an algorithm thousands of emails that are already labeled spam or not-spam, and it learns for itself which patterns — words, sender characteristics, formatting — correlate with spam. The resulting model can then make predictions on emails it has never seen before.

This shift, from hand-coded logic to logic inferred from data, is what makes ML useful for problems where the underlying rules are too fuzzy, too numerous, or too poorly understood for a human to write down directly. Nobody can write an explicit rule for "what does a fraudulent transaction look like" that covers every case, but a model can learn a good approximation from historical examples of fraud.

ML problems are usually grouped into three broad categories, based on what kind of feedback the algorithm learns from.

Supervised learning

The algorithm learns from labeled examples — each training input comes paired with the correct output.

Example: predicting house prices. You give the model thousands of past sales, each with features (square footage, location, number of bedrooms) and the known sale price. The model learns the relationship between features and price, so it can predict a price for a new house it's never seen.

Supervised learning covers both classification (predicting a category, like spam/not-spam) and regression (predicting a number, like a price).

Unsupervised learning

The algorithm gets no labels at all — just raw data — and has to find structure in it on its own.

Example: customer segmentation. You give the model your entire customer base's purchase history, with no predefined "type" of customer labeled anywhere. The model groups customers into clusters based on similarity in their behavior (for example, "frequent small purchases" vs. "infrequent large purchases"), and a human interprets what each discovered cluster represents afterward.

Reinforcement learning

The algorithm — usually called an agent — learns by acting in an environment and receiving a reward signal, rather than from a fixed dataset of labeled examples at all.

Example: an agent learning to play a video game. It doesn't get told the "correct" move for every screen. It tries actions, receives a score (reward) for outcomes like clearing a level or losing a life, and over many attempts learns a strategy (a "policy") that maximizes its total reward over time.

Type Learns from Example
Supervised Labeled input/output pairs Predicting house prices from labeled past sales
Unsupervised Unlabeled data, looking for structure Grouping customers into behavioral segments
Reinforcement Reward signal from acting in an environment An agent learning to play a game through trial and reward

Common mistakes

  • Assuming "machine learning" always means "neural network" — plenty of ML (linear regression, decision trees, k-means) has nothing to do with deep learning.
  • Confusing unsupervised learning with "no correct answer exists" — there may well be a real underlying structure (real customer segments); it's just that no one hand-labeled it in the training data.
  • Applying reinforcement learning to problems that are really supervised learning in disguise — if you already have a large dataset of labeled correct answers, use it directly rather than building a reward signal and an environment to rediscover what you already know.