Machine learning is the part of AI that learns from data. Understanding how it works, even at a high level, will help you judge whether your idea is realistic and what you would need to build it.
Learning from examples
Machine learning (ML) is a way of building software that improves at a task by finding patterns in examples, rather than by following rules written line by line.
Imagine you want to predict whether a customer will repay a small business loan. Instead of writing hundreds of rules, you give the system thousands of past loans: what was known at the start (income, loan size, repayment history) and what happened in the end (repaid or not). The system finds patterns that link the two, and uses them to make predictions for new applicants.
Features and labels
- Features are the pieces of information the model looks at, such as income, rainfall or the pixels of an image.
- Labels are the answers you want the model to learn to predict, such as "repaid", "diseased" or "spam".
Three main ways machines learn
| Type | How it learns | Example |
|---|---|---|
| Supervised learning | From examples that come with the correct answer (labelled data). | Emails marked "spam" or "not spam" train a spam filter. |
| Unsupervised learning | Finds structure in data that has no labels. | Grouping shoppers with similar buying habits. |
| Reinforcement learning | Learns by trial and error, guided by rewards and penalties. | A system learning to control traffic signals to reduce waiting time. |
Training and inference
Building an ML system has two phases:
- Training - the model studies historical examples and adjusts itself to make better predictions. This can take a lot of data and computing power.
- Inference - the trained model is used on new, unseen data to make a prediction or decision. This is what users experience.
How do we know a model is good?
A model must be tested on data it did not see during training. Otherwise we cannot tell whether it has learned real patterns or simply memorised the examples.
Watch out: overfitting
A model that performs brilliantly on its training data but poorly on new data is overfitting. It has memorised the examples, including their noise, instead of learning patterns that generalise.
Common measures include accuracy (how often the model is right) and, for important decisions, how often it misses real cases or raises false alarms. A disease-screening tool that misses sick patients can be dangerous even if its overall accuracy looks high.
Key takeaways
- Machine learning finds patterns in examples to make predictions on new data.
- Supervised learning uses labelled data; unsupervised finds hidden groups; reinforcement learns from rewards.
- Training builds the model; inference uses it.
- Always test on unseen data to avoid overfitting.