What are the types of machine learning?
Machine learning is a way of building programs that learn patterns from data instead of following rules a person typed in. The main types of machine learning are sorted by one simple question: what kind of feedback does the algorithm get while it learns?
If every training example comes with the correct answer, it is supervised learning. If there are no answers at all and the algorithm has to find structure by itself, it is unsupervised learning. If an agent learns by trying actions and receiving rewards or penalties, it is reinforcement learning. Two newer types sit between these: semi-supervised learning, which mixes a few labels with lots of unlabelled data, and self-supervised learning, which creates its own labels from the raw data.
These categories are also what people mean when they search for the types of learning in AI, the forms of learning in artificial intelligence, or the main machine learning techniques. Many AI textbooks, including Russell and Norvig's Artificial Intelligence: A Modern Approach, describe the forms of learning by exactly this idea of feedback.
Types of machine learning at a glance
| Type | What the data looks like | What it learns | Common algorithms | Real examples |
|---|---|---|---|---|
| Supervised learning | Inputs with a known correct answer (label) | A mapping from inputs to the label | Linear and logistic regression, decision trees, random forest, XGBoost, SVM | Spam filters, loan default prediction, house prices, delivery time estimates |
| Unsupervised learning | Inputs only, no labels | Groups, patterns or a simpler view of the data | K-means, DBSCAN, hierarchical clustering, PCA, Isolation Forest | Customer segments, anomaly detection, topic grouping, data compression |
| Reinforcement learning | An environment, actions and rewards | A policy: which action to take in each situation | Q-learning, Deep Q-Networks, policy gradient methods, PPO | Game-playing agents, robot control, some ad bidding and recommendation systems |
| Semi-supervised learning | A small labelled set plus a large unlabelled set | The same as supervised, using unlabelled data to help | Self-training, label propagation, label spreading | Classifying medical scans or documents when expert labels are costly |
| Self-supervised learning | Raw data where part of it is hidden and used as the target | General-purpose representations of text, images or audio | Masked language modelling, next-token prediction, contrastive learning | Pretraining large language models like GPT and BERT, image encoders |
Supervised learning: learning from labelled examples
In supervised learning you give the algorithm a table of past examples. Each row has features (the inputs, often called X) and a label (the answer, often called y). The algorithm adjusts itself until its predictions on those rows are as close as possible to the real labels, then you use it on new rows where the label is unknown.
Supervised learning splits into two tasks. Regression predicts a number, such as a flat's rent or tomorrow's demand for a product. Classification predicts a category, such as fraud or not fraud, or which of ten digits a handwritten image shows. Most machine learning work in companies is supervised, because businesses usually have historical records with known outcomes: which customers left, which loans defaulted, which orders arrived late.
The catch is that labels cost time and money. Someone has to mark emails as spam, tag images or wait months to see whether a loan was repaid. The quality of those labels sets an upper limit on how good the model can get. Phases 7 and 8 of this roadmap cover supervised regression and classification in depth.
Unsupervised learning: finding structure without labels
Unsupervised learning works with data that has no answer column. Instead of predicting a known target, the algorithm looks for structure: rows that are similar to each other, directions in which the data varies most, or points that do not fit the usual pattern.
- Clustering groups similar rows. K-means might split shoppers into budget buyers, festive-season buyers and frequent premium buyers, which a marketing team can then name and target.
- Dimensionality reduction squeezes many columns into a few while keeping most of the information. PCA is the classic method, and t-SNE and UMAP are popular for drawing high-dimensional data in 2D.
- Anomaly detection flags rare, unusual rows, such as a card payment that looks nothing like a customer's normal spending.
- Association rules find items that often appear together, like the 'frequently bought together' suggestions on shopping sites.
Reinforcement learning: learning from rewards
Reinforcement learning (RL) is different from both. There is no fixed dataset at the start. An agent acts inside an environment, sees the result, and gets a reward signal that says how good that outcome was. Over many attempts it learns a policy, which is a strategy for choosing actions that collect the most reward over time.
A simple way to picture it is teaching a dog a trick: you do not show it a labelled dataset, you give a treat when it does the right thing. RL is behind famous game-playing systems such as DeepMind's AlphaGo, and it is used in robotics and some control problems. A form of it, reinforcement learning from human feedback (RLHF), is also used to fine-tune chat models so their answers match what people prefer.
RL is powerful but harder to apply than supervised learning. It needs a safe environment or simulator to practise in, rewards that are carefully designed, and often a very large number of trials. That is why most beginners, and most industry teams, start with supervised learning.
Semi-supervised and self-supervised learning
Semi-supervised learning is useful when labelling is expensive but raw data is cheap. Imagine you have a million product reviews but only two thousand are tagged as positive or negative. A semi-supervised method trains on the labelled reviews, uses the model to guess labels for confident unlabelled ones, and retrains. scikit-learn includes SelfTrainingClassifier, LabelPropagation and LabelSpreading for this.
Self-supervised learning removes the need for human labels during pretraining. The model is given raw data with part of it hidden and is asked to fill in the gap. BERT learns by predicting masked words in a sentence, and GPT-style models learn by predicting the next token. Image models can learn by matching two altered views of the same photo. The labels come from the data itself, which is why these models can learn from huge collections of text and images. The pretrained model is then fine-tuned on a smaller labelled dataset, which is a supervised step.
Supervised vs unsupervised learning in scikit-learn
The clearest way to see the difference is in code. Both models below use the same iris flower measurements. The classifier is given the species labels, while k-means only sees the measurements and has to discover groups on its own.
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.cluster import KMeans
X, y = load_iris(return_X_y=True)
# Supervised: learn from features AND labels
clf = LogisticRegression(max_iter=1000).fit(X, y)
print(clf.predict(X[:3])) # predicted species for 3 flowers
# Unsupervised: features only, no labels
km = KMeans(n_clusters=3, n_init=10, random_state=0).fit(X)
print(km.labels_[:3]) # cluster number for the same flowersHow to tell which type of machine learning you need
Other machine learning techniques you will hear about describe how a model is trained rather than what feedback it gets. Batch learning trains on the full dataset at once, while online learning updates the model as new data streams in. Transfer learning reuses a model trained on one task as the starting point for another. Active learning picks the most useful unlabelled examples for a human to label next. These ideas combine with the five types above rather than replace them.
| If your situation is... | Use |
|---|---|
| You have past examples with the correct answer and want to predict it for new cases | Supervised learning (regression for numbers, classification for categories) |
| You have data but no answer column and want to discover groups or oddities | Unsupervised learning |
| An agent must make a sequence of decisions and you can score the outcomes | Reinforcement learning |
| Labels exist for only a small part of a large dataset | Semi-supervised learning |
| You want a general model of text, images or audio before solving a specific task | Self-supervised pretraining, then supervised fine-tuning |
