How Machine Learning Works

Beginner
7 min read· Modern Technology

Machine learning is a method of teaching computers to learn from examples rather than explicit instructions. Instead of programming rules by hand, you feed a model thousands or millions of examples, and it adjusts its internal parameters until it can reliably predict outcomes on new data it has never seen. The model doesn't understand anything — it is optimising mathematical functions until patterns in the data are captured in numerical weights.

Think of machine learning like learning to recognise dogs

A child learns what a "dog" is not by memorising a definition, but by seeing thousands of examples — golden retrievers, chihuahuas, huskies — with the label "dog", and also cats, chairs, and cars labelled "not dog". After enough examples, the child's brain builds internal representations that generalise to new dogs it has never seen. Machine learning models do the exact same thing — except the "brain" is a mathematical function and the "representations" are millions of floating point numbers.

Step by Step

1 / 7

Key Concepts

Supervised Learning

Training a model on labelled examples (input → correct output pairs). The model learns to map inputs to outputs. Examples: email spam detection, image classification, house price prediction. The most common type of ML in production.

Unsupervised Learning

Finding patterns in unlabelled data — no correct answers provided. Clustering (grouping similar items), dimensionality reduction (compressing data while preserving structure), and anomaly detection are unsupervised tasks. Used when labelling data is expensive or impossible.

Overfitting

When a model learns the training data too well — including noise and random variation — and performs poorly on new data. Like a student who memorises past exam questions but cannot solve novel problems. Prevented by regularisation, dropout, early stopping, or collecting more training data.

Feature

An individual measurable property used as input to a model. For house price prediction: square footage, location, number of bedrooms. Feature engineering — creating new features from raw data — is often the most impactful part of the ML workflow.

Gradient Descent

The optimisation algorithm that adjusts model parameters to minimise the loss function. Iteratively updates parameters in the direction of the steepest descent of the loss landscape. Stochastic Gradient Descent (SGD) and Adam are the most common variants.

Cross-Validation

A technique to estimate model performance on unseen data by training and evaluating on different subsets of the training data. K-fold cross-validation splits data into K subsets, trains K models each using a different subset for validation, and averages the results.

Hyperparameter

Settings that control how a model is trained — not learned from data but set by the engineer. Examples: learning rate, number of layers, regularisation strength. Hyperparameter tuning (trying many combinations) often significantly improves model performance.

Key Facts

  • ImageNet, the dataset that triggered the deep learning revolution, contains 14 million images across 20,000 categories — it took 25,000 workers annotating labels to create.
  • AlexNet in 2012 won the ImageNet challenge with 15.3% error rate vs. 26.2% for the runner-up — a shocking improvement that marked the start of the deep learning era.
  • GPT-4 was trained on an estimated 13 trillion tokens of text — roughly 10,000 times more data than a human reads in a lifetime.
  • The global machine learning market is projected to exceed $500 billion by 2030, up from about $20 billion in 2022.
  • Netflix estimated its recommendation algorithm saves $1 billion per year in customer retention by reducing churn — making ML ROI directly measurable.
  • A decision tree model trained in seconds on a laptop can outperform complex neural networks on structured tabular data — bigger models are not always better.

Real-World Applications

Fraud Detection

Banks and payment companies train ML models on millions of labelled transactions (fraud/legitimate) to flag suspicious activity in real time. Models can spot patterns invisible to human analysts — unusual merchant categories, abnormal spending velocity, or atypical geolocation.

Medical Diagnosis

ML models trained on millions of medical images (X-rays, MRIs, pathology slides) can detect cancers, diabetic retinopathy, and COVID-19 with accuracy matching or exceeding specialist doctors — and can screen at far greater scale.

Recommendation Systems

YouTube, Spotify, Netflix, and Amazon use ML to predict what you'll want to watch, listen to, or buy next. Collaborative filtering models learn from millions of users' behaviour patterns to personalise every feed.

Natural Language Processing

ML models power autocomplete, sentiment analysis, translation, spam filtering, and language generation. Every time your phone suggests the next word or Google Translate converts a sentence, an ML model runs in milliseconds.

Predictive Maintenance

Industrial sensors generate terabytes of data from machinery. ML models trained on historical failure patterns can predict equipment failures days or weeks in advance, preventing costly breakdowns in factories, power plants, and aircraft engines.

Frequently Asked Questions

What is the difference between AI, machine learning, and deep learning?

These are nested concepts. AI (Artificial Intelligence) is the broad field of making machines exhibit intelligent behaviour. Machine Learning is a subset of AI — machines learning from data rather than explicit rules. Deep Learning is a subset of ML — using neural networks with many layers. All deep learning is ML; all ML is AI; not all AI is ML.

How much data do you need to train a model?

It depends entirely on the complexity of the problem and model. A simple linear regression might work with 100 data points. A custom image classifier might need 10,000-100,000 images per class. GPT-4 needed trillions of tokens. Transfer learning — taking a pre-trained large model and fine-tuning it — can achieve excellent results with just hundreds of examples for specialised tasks.

Can a machine learning model be wrong?

Absolutely, and frequently. Models are probabilistic — they predict the most likely outcome based on training patterns, but they can be wrong, especially on inputs that differ from the training distribution. This is why model evaluation, monitoring in production, human oversight, and uncertainty quantification are critical. Never deploy an ML model without measuring and communicating its error rates.

What is the difference between ML and traditional programming?

Traditional programming: engineer writes explicit rules → machine follows them (if email contains "winner" AND "million dollars" → spam). Machine learning: engineer provides examples of spam and non-spam → model infers the rules itself. ML is powerful when rules are too complex to write manually or when they need to adapt to changing patterns.

Related Topics