Last updated: 06 December 2026
Machine learning simplified comes down to one idea: instead of writing rules by hand, you show a program many examples and let it find the pattern itself. This guide builds that understanding step by step, from the core concept to a small exercise you can try yourself.
What machine learning actually is
Traditional software follows rules a programmer wrote. A spam filter built that way might say “if the message contains this phrase, mark it as spam.” The rules break as soon as spammers change their wording.
Machine learning (ML) flips the process. You give the system examples, such as thousands of emails already labelled spam or not spam. A learning algorithm adjusts a mathematical function until it separates the two groups well. The result is called a model. You can then give the model a new email and it returns a prediction.
A useful one-line definition: ML is a way of building software whose behaviour comes from data rather than from hand-written rules.
The key vocabulary
- Data set: the collection of examples you learn from.
- Feature: an input measurement, such as a house’s floor area or the number of links in an email.
- Label (or target): the answer you want to predict, such as the sale price or “spam”.
- Model: the learned function that maps features to a prediction.
- Parameters: the internal numbers the model adjusts during learning.
- Training: the process of adjusting parameters to reduce error on examples.
- Inference: using a trained model to predict on new data.
- Loss: a number that measures how wrong the predictions are. Training tries to make it smaller.
How a model learns, in plain terms
Imagine fitting a straight line through points that show house size against price. The line has two parameters: its slope and where it starts. At first they are guesses. The algorithm measures how far the line is from the real prices, which is the loss. It then nudges the slope and start point in the direction that lowers the loss. It repeats this many times.
Most modern methods, including neural networks, follow the same loop with far more parameters. The common technique for the nudging step is gradient descent, which moves each parameter a small amount in the direction that reduces loss.
The main types of machine learning
Supervised learning
You have labelled examples. The model learns to predict the label. Two common tasks are classification (pick a category, such as spam or not spam) and regression (predict a number, such as a price).
Unsupervised learning
There are no labels. The model looks for structure, for instance grouping customers with similar behaviour (clustering) or compressing data to fewer dimensions.
Reinforcement learning
An agent takes actions in an environment and receives rewards or penalties. It learns a strategy that earns more reward over time. This is used for game playing and some control problems.
Self-supervised learning
The labels come from the data itself. Large language models, for example, are trained to predict missing or next pieces of text. This approach lets them learn from very large amounts of unlabelled material.
Comparison of approaches
| Type | Data needed | Typical goal | Example |
|---|---|---|---|
| Supervised | Labelled examples | Predict a label or number | Predicting loan default |
| Unsupervised | Unlabelled data | Find groups or structure | Customer segments |
| Reinforcement | An environment with rewards | Learn a good sequence of actions | Game-playing agent |
| Self-supervised | Large unlabelled data | Learn general representations | Language model pretraining |
The standard ML workflow
Real projects follow a similar loop, whatever the algorithm.

- Define the problem. Decide what you predict and how success is measured. A vague goal produces a useless model.
- Collect and clean data. Fix missing values, duplicates and obvious errors. This step often takes most of the effort.
- Create features. Turn raw data into useful inputs, for example converting dates into day of week.
- Split the data. Keep part of it aside as a test set that the model never sees during training.
- Train a simple baseline first. A basic model gives you a reference point.
- Evaluate. Measure performance on the held-out data with a metric that fits the problem.
- Improve, deploy and monitor. Data changes over time, so a model that worked last year may decay.
Overfitting: the central problem
A model that memorises its training examples can score perfectly on them and still fail on new data. This is overfitting. The opposite, underfitting, happens when the model is too simple to capture the pattern.
You detect overfitting by comparing performance on training data with performance on held-out data. A large gap is a warning sign. Common remedies include collecting more data, using a simpler model, adding regularisation, and using cross-validation to get a more reliable estimate.
Choosing a metric
Accuracy, the share of correct predictions, can mislead. If only 1 percent of transactions are fraud, a model that always says “not fraud” is 99 percent accurate and useless. In that case, look at precision (how many flagged cases were truly positive) and recall (how many true cases you caught). For regression, mean absolute error is easy to interpret because it is in the same units as the target.
Hands-on exercise: your first classifier
This short Python example uses the scikit-learn library and its built-in iris data set. The code has not been tested here, so run it in a clean environment and adjust if your setup differs.
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
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, random_state=42, stratify=y
)
model = LogisticRegression(max_iter=200)
model.fit(X_train, y_train)
pred = model.predict(X_test)
print("Test accuracy:", accuracy_score(y_test, pred))
To install the library you would typically run the following command.
pip install scikit-learn
Things to try next
- Print the accuracy on the training set too and compare it with the test accuracy.
- Swap in a decision tree (
DecisionTreeClassifier) and set a very large depth. Watch whether the gap between training and test scores grows. - Change
random_stateand note how much the score moves. Small data sets give noisy results.
Common mistakes
- Data leakage. Information from the test set, or from the future, slips into training. Scores look great and then collapse in real use. Fit scaling and other preprocessing on training data only.
- Skipping the baseline. Without a simple reference you cannot tell whether a complex model is worth its cost.
- Trusting biased data. A model learns the patterns in its data, including unfair ones. Check how performance differs across groups.
- Tuning on the test set. If you keep adjusting until the test score rises, the test set stops being an honest check. Use a separate validation set or cross-validation for tuning.
- Using ML when rules would do. If a few clear rules solve the problem, they are cheaper and easier to explain.
Troubleshooting poor results
| Symptom | Likely cause | What to try |
|---|---|---|
| Low score on training and test data | Underfitting or weak features | Better features, a more flexible model |
| High training score, low test score | Overfitting | More data, regularisation, simpler model |
| Great test score, poor real-world results | Leakage or data drift | Audit the pipeline, test on fresh data |
| Good accuracy but misses rare cases | Class imbalance | Use recall and precision, rebalance classes |
How machine learning relates to AI and deep learning
Artificial intelligence is the broad goal of building systems that perform tasks associated with human intelligence. Machine learning is one way to achieve it. Deep learning is a branch of ML that uses neural networks with many layers. It tends to shine on images, audio and text, while simpler methods such as linear models and tree ensembles are often strong choices for tables of business data.
A sensible learning path
- Learn basic Python and how to handle tabular data.
- Understand a few core ideas: averages, variance, probability and the idea of a derivative.
- Build small projects with scikit-learn on public data sets.
- Study evaluation carefully before moving to neural networks.
- Move to a deep learning framework once the basics feel natural.
FAQ
Do I need advanced maths to start?
No. You can build and evaluate useful models with modest maths. Deeper understanding of why methods work benefits from linear algebra, probability and calculus, which you can learn gradually.
How much data do I need?
It depends on the problem and the model. Simple models can work with hundreds of examples. Complex ones such as deep networks usually need far more. Data quality matters as much as quantity.
Is machine learning the same as AI?
Not exactly. ML is a subset of AI focused on learning from data. Some AI systems use hand-written logic instead.
Can a model be wrong even with high accuracy?
Yes. It may be wrong on rare but important cases, or the data it sees later may differ from what it trained on. Choose metrics that match the real cost of errors and keep monitoring.
What is the best algorithm?
There is no single best one. The right choice depends on your data, your constraints and how much you need to explain the results. Start simple and compare.
Key takeaways
- ML learns patterns from examples rather than following hand-written rules.
- Training adjusts parameters to reduce a measure of error called loss.
- Always judge a model on data it has not seen.
- Start with a baseline, watch for overfitting and leakage, and pick metrics that fit the problem.