What is Machine Learning?
Machine learning is how AI learns from data instead of following programmed rules. Plain-English explanation of supervised, unsupervised, and reinforcement learning.

The old way: explicit rules
Traditional software follows rules that programmers write by hand:
# A programmer had to think of every rule manually
def is_spam(email):
if "click here to claim your prize" in email.lower():
return True
if "nigerian prince" in email.lower():
return True
# ... hundreds more rules
return FalseThis breaks immediately when spammers change their wording. The programmer must constantly update rules.
The machine learning way: learn from examples
Instead of writing rules, you provide labelled examples and let the system find the pattern:
# You provide training data: emails with correct labels
training_data = [
("Click here to claim your prize!", "spam"),
("Hi, the meeting is at 3pm", "not_spam"),
("Get rich quick guaranteed!", "spam"),
("Invoice attached as discussed", "not_spam"),
# ... thousands more examples
]
# The model learns what makes an email spam
model = train(training_data)
# Now it classifies new emails it has never seen
model.predict("Limited time offer! Act now!!") # → "spam"The key shift: the programmer no longer writes rules. The programmer curates data and the algorithm writes its own rules internally.
The three main types of machine learning
Supervised learning: learning with a teacher
The most common type. You provide labelled training data: inputs paired with correct outputs.
Examples:
- Image classification: 10,000 photos each labelled “cat” or “dog”. The model learns visual features that distinguish them.
- Price prediction: 50,000 property listings with sale prices. The model learns which features (size, location, age) predict price.
- Sentiment analysis: 100,000 product reviews each labelled positive or negative. The model learns language patterns associated with sentiment.
Unsupervised learning: finding hidden structure
No labels required. The model finds patterns in unlabelled data.
Examples:
- Customer segmentation: Group customers by purchasing behaviour without pre-defining what the groups are.
- Anomaly detection: Learn what normal transaction patterns look like, then flag unusual transactions as potential fraud.
- Topic modelling: Process 10,000 articles and automatically discover they cluster into topics like “finance”, “sports”, and “technology”.
Reinforcement learning: learning by doing
An agent takes actions, receives rewards or penalties, and learns which actions maximise reward over time.
Examples:
- Game-playing AI (AlphaGo) learning to win by playing millions of games against itself
- Language model alignment via RLHF (Reinforcement Learning from Human Feedback): humans rate responses and the model learns to produce responses humans prefer
The machine learning workflow
Common ML algorithms at a glance
| Algorithm | Best for | Requires |
|---|---|---|
| Linear regression | Predicting a continuous value (price, temperature) | Small dataset, interpretability |
| Logistic regression | Binary classification (yes/no) | Small dataset, interpretability |
| Decision tree | Rules-based classification, explainability | Structured tabular data |
| Random forest | High accuracy on tabular data | More compute than single tree |
| Gradient boosting (XGBoost) | Structured data competitions, fraud detection | Careful hyperparameter tuning |
| Neural network / deep learning | Images, text, audio, complex patterns | Large datasets, significant compute |
| k-means clustering | Customer segmentation, grouping | Unlabelled data |
When machine learning is not the right choice
When you have explicit rules that work: If a simple if/else logic covers 99% of cases reliably, ML adds complexity without benefit. Use rules first.
When you have too little data: Training a deep learning model on 100 labelled examples will not work. You need at minimum hundreds, usually thousands of examples.
When you need full explainability: If a regulatory requirement demands that every decision be explainable step by step (common in credit decisions, medical diagnosis), black-box ML models present legal and compliance challenges.
When the domain is rapidly changing: A model trained on last year’s data may degrade quickly if the real-world patterns shift. Some domains require continuous retraining to stay accurate.
What’s next
- What is a Neural Network? : The deep learning architecture inside modern AI
- What is Generative AI? : How ML powers content creation
- What is Fine-tuning? : Adapting a pre-trained model to a specific task
- MLOps: Getting Started : How engineering teams manage ML models in production
Further reading
- Google: Introduction to Machine Learning : Structured course from Google’s developer education team
- Fast.ai Practical Deep Learning : Top-rated free course, starts with code before theory
- Scikit-learn documentation : Python library covering all classical ML algorithms with examples
- What is AI? : Broader context for how machine learning fits into artificial intelligence
Frequently asked questions
