In our introduction to machine learning, we saw that there are three main types of ML: supervised, unsupervised and reinforcement learning. Supervised learning is by far the most widely used. It powers spam filters, fraud detection, medical diagnosis tools, price predictions and much more. In this article, we’ll explain what supervised learning is, how it works, the main algorithms, and how to build your first model.
What Is Supervised Learning?
Supervised learning is a type of machine learning where a model learns from labelled data, meaning examples where the correct answer is already known. After training, the model can predict the answer for new examples it has never seen before.
It’s called “supervised” because the learning process is guided by these correct answers, much like a student learning with a teacher. The teacher gives practice questions along with the answers. The student studies them, makes mistakes, gets corrected, and gradually learns to solve new questions alone.
Key Terms to Know
| Term | Meaning | Example (house prices) |
|---|---|---|
| Features | The input information the model uses | Size, location, number of bedrooms |
| Label | The correct answer the model should predict | The sale price |
| Training data | Labelled examples used to teach the model | 10,000 past house sales |
| Test data | Labelled examples held back to check the model | 2,000 sales the model never saw during training |
| Model | What the algorithm produces after learning | A function that estimates price from features |
How Supervised Learning Works
Supervised learning happens in two phases: training and prediction.

- Collect labelled data. Gather examples where you know both the inputs and the correct output.
- Split the data. Keep most of it (typically 70–80%) for training and set the rest aside for testing.
- Train the model. The algorithm makes predictions on the training data, compares them to the correct labels, measures the error, and adjusts itself to reduce that error. This loop repeats many times.
- Evaluate. Test the model on the held-back data to see how well it handles examples it has never seen.
- Predict. Once you’re happy with the performance, use the model on new, real-world data where the answer is unknown.
The Two Types of Supervised Learning
Supervised learning problems fall into two categories, depending on what you want to predict.

1. Classification: Predicting a Category
The output is a class or label from a fixed set of options. The model learns a boundary that separates the classes.
- Is this email spam or not spam?
- Is this transaction fraudulent or legitimate?
- Which digit (0–9) is in this handwritten image?
- Will this customer churn or stay?
When there are only two possible classes it’s called binary classification. When there are more, it’s multi-class classification.
2. Regression: Predicting a Number
The output is a continuous value. The model learns a line or curve that fits the trend in the data.
- What will this house sell for?
- How many units will we sell next month?
- What will the temperature be tomorrow?
- How long will this delivery take?
Quick tip: If the answer is a name or group, it’s classification. If the answer is an amount or quantity, it’s regression.
Popular Supervised Learning Algorithms
| Algorithm | Type | How it works (in simple terms) | Good for |
|---|---|---|---|
| Linear Regression | Regression | Fits a straight line through the data | Price and sales forecasting |
| Logistic Regression | Classification | Estimates the probability of belonging to a class | Spam detection, credit approval |
| Decision Tree | Both | Asks a series of yes/no questions to reach an answer | Easy-to-explain decisions |
| Random Forest | Both | Combines many decision trees and takes a vote | Strong all-round performance |
| Support Vector Machine (SVM) | Mostly classification | Finds the widest possible gap between classes | Text and image classification |
| K-Nearest Neighbours (KNN) | Both | Looks at the most similar past examples | Recommendations, simple baselines |
| Neural Networks | Both | Layers of connected units that learn complex patterns | Images, speech, language |
There’s no single “best” algorithm. It’s common to try a simple one first (like linear or logistic regression) as a baseline, then test more powerful options such as random forests or gradient boosting.
How Do We Measure a Model’s Performance?
A model is only useful if it performs well on data it hasn’t seen. That’s why we always evaluate it on the separate test set.
Metrics for classification
- Accuracy: The percentage of predictions that were correct.
- Precision: Of everything the model flagged as positive (e.g. spam), how much really was positive?
- Recall: Of all the real positives, how many did the model catch?
- F1 score: A balance between precision and recall.
Accuracy alone can be misleading. If only 1% of transactions are fraudulent, a model that says “not fraud” every time is 99% accurate but completely useless. Precision and recall reveal this.
Metrics for regression
- Mean Absolute Error (MAE): On average, how far off are the predictions?
- Root Mean Squared Error (RMSE): Like MAE, but penalises large errors more heavily.
- R² (R-squared): How much of the variation in the data the model explains (closer to 1 is better).
Overfitting and Underfitting
Two common problems to watch out for:
- Overfitting: The model memorises the training data, including its noise, instead of learning the general pattern. It scores very well in training but poorly on new data, like a student who memorised past exam answers but can’t handle a new question.
- Underfitting: The model is too simple to capture the pattern, so it performs poorly on both training and test data.
The goal is a model that generalises well. Common remedies include getting more data, simplifying or regularising the model, and using cross-validation to test performance more reliably.
Build Your First Supervised Learning Model
Here’s a complete example in Python using scikit-learn. It trains a decision tree to classify iris flowers into three species based on petal and sepal measurements.
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
# 1. Load labelled data: flower measurements (features) and species (labels)
X, y = load_iris(return_X_y=True)
# 2. Split into training data and test data
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42
)
# 3. Train the model
model = DecisionTreeClassifier(random_state=42)
model.fit(X_train, y_train)
# 4. Predict on unseen data and evaluate
predictions = model.predict(X_test)
print(f"Accuracy: {accuracy_score(y_test, predictions):.2f}")
In just a few lines, this follows the full supervised learning process: load labelled data, split it, train, predict and evaluate. On this classic beginner dataset, accuracy is usually above 90%.
Real-World Applications
- Banking & Finance: Fraud detection, credit scoring, loan default prediction.
- Healthcare: Detecting diseases from medical images, predicting patient readmission.
- E-commerce: Predicting customer churn, demand forecasting, product categorisation.
- Email & Security: Spam filtering, phishing detection.
- Real Estate: Property price estimation.
- Customer Service: Classifying support tickets and routing them to the right team.
Advantages and Limitations
Advantages
- Clear goal and measurable results, since you know the correct answers.
- High accuracy when good-quality labelled data is available.
- Well-established algorithms and tools that are easy to get started with.
Limitations
- Labelled data is expensive. Someone has to label thousands of examples, which can take a lot of time and money, often needing domain experts.
- Label quality matters. Wrong or biased labels lead to wrong or biased predictions.
- Limited to what it has seen. A model may struggle with situations that are very different from its training data.
Conclusion
Supervised learning is the foundation of most practical machine learning today. The idea is simple: show the model many examples with the right answers, and it learns to predict answers for new cases. Understanding features and labels, the difference between classification and regression, and how to evaluate a model will give you a solid base for almost any ML project.
In our next article, we’ll look at unsupervised learning, where models find patterns in data without any labels at all.
At SciAiLabs, we build machine learning and AI solutions that turn your data into accurate predictions and smarter decisions. Get in touch to discuss your project.
[…] our guide to supervised learning, we saw how models learn from labelled data, meaning examples where the correct answer is already […]