Machine Learning (ML) is the engine behind most modern AI. It's the set of techniques that allow computers to learn from data — without being explicitly programmed with rules for every situation.

Core idea

Traditional programming: you write rules → the computer applies them to data.
Machine learning: you give examples → the computer figures out the rules itself.

The traditional approach vs ML

Imagine building a spam filter the traditional way. You'd write rules: "if the email contains the word 'prize', mark as spam." But spammers adapt. Your rules become an endless game of whack-a-mole. The ML approach: show the system thousands of emails already labelled as spam or not spam. Let it find its own patterns — subtle combinations no human would think to hard-code.

Traditional vs ML side by side

Traditional: IF email contains "free money" THEN spam = true

ML: Train on 100,000 labelled emails → model learns patterns → handles new spam variations automatically

The three types of machine learning

What does "learning" actually mean?

When an ML model learns, it's adjusting millions of internal numbers (parameters) to minimise the gap between its predictions and the correct answers — through an algorithm called gradient descent. You don't need to understand the maths; just know that training = repeated error correction.

# A complete ML example in 8 lines (scikit-learn)
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = DecisionTreeClassifier()
model.fit(X_train, y_train) # training happens here
print(model.score(X_test, y_test)) # accuracy on unseen data

ML vs AI vs Deep Learning

AI is the broad field. ML is a data-driven subset of AI. Deep learning is a subset of ML using multi-layer neural networks. Most modern breakthroughs — LLMs, image generation, speech recognition — are specifically deep learning.

Key takeaways

  • ML lets computers learn patterns from data instead of following hand-coded rules
  • Three main types: supervised, unsupervised, and reinforcement learning
  • Training means repeatedly adjusting parameters to reduce prediction error
  • Deep learning is a powerful subset of ML using multi-layer neural networks