AI and machine learning: supervised, unsupervised, reinforcement, deep
Machine learning (ML), a branch of artificial intelligence (AI), learns patterns from data instead of following written rules. Supervised learning uses labeled data, unsupervised finds structure without labels, reinforcement learns from rewards, and deep learning uses many-layered neural networks. Separate training, validation and test data catch overfitting.
Before this: Big data, the four Vs and alternative data
On the exam
- Describe how big data, machine learning, and artificial intelligence are used in financial data science, fintech, and investment management
Describe how machine learning and AI are used in finance. Expect: which approach fits labeled data, no labels or rewards; an advantage or limitation of each approach; which dataset is largest (training); how to split time-series data; overfitting versus underfitting; why ML can be a black box. No calculations.
How deeply to learn each part
- Know the idea
- Understand it in general. It frames other topics, but you will not calculate with it.
- Use it
- Understand it well enough to solve a question with it. Recognize when it applies.
- Memorize
- Learn it by heart. The exam will not give it to you.
You know this one. The full lesson is folded away. The takeaways, formulas and checkpoint below are your quick refresher, and the checkpoint is a fair test of whether you still do.
You tested strong here. The full lesson is folded away. The takeaways, formulas and checkpoint below are your quick refresher, and the checkpoint is a fair test of whether you still know it.
What are AI and machine learning?
Artificial intelligence (AI) is computer systems performing tasks that traditionally needed human intelligence, such as recognizing patterns and making decisions. In some limited settings, AI systems now match or outperform people. An early form was the expert system : hand-coded “if–then” rules written by human experts.
Machine learning (ML) takes a different route. Nobody writes the rules. The algorithm is given data and learns how inputs relate to outputs, or how the data are structured. The slogan is find the pattern, apply the pattern. ML is used across finance, from fraud detection and transaction pricing to optimizing trading strategies.
ML needs a lot of data to train on. Big data supplied it, while computing power grew and storage got cheaper. A robo-adviser is one result: it builds a diversified portfolio from a client’s goals and risk tolerance and keeps rebalancing it automatically.
How is the data split?
The algorithm gets inputs and, sometimes, outputs (targets). The data are split into three sets.
- Training dataset Memorize learn; the largest
- Validation dataset Memorize tune
- Test dataset Memorize judge on unseen data
- The training dataset is where the model learns input–output relationships. It is typically the largest.
- The validation dataset checks those relationships and is used to tune the model.
- The test dataset (also called the testing dataset) judges how well the model predicts on data it has never seen.
A model is judged on the test set, not on how well it explains its own training data. How big each set should be depends on how much data there is. These are rules of thumb.
| Dataset | Training | Validation | Test |
|---|---|---|---|
| Standard | 60–80% | 10–20% | 10–20% |
| Larger datasets | 70–80% | 10–15% | 10–15% |
| Smaller datasets | 60–70% | 15–20% | 15–20% |
Bigger datasets can spare a larger share for training; small ones keep more back to check the model.
For most data, the rows are shuffled before splitting, so each set is representative and any ordering in the file cannot bias the model. Shuffling also helps prevent data leakage : information from outside the training data slipping into what the model learns, which makes test results look better than real-world performance.
Why not shuffle a time series?
In financial time series, order matters: today depends on yesterday. Shuffling breaks that order, creates relationships that do not exist, and can put future data in the training set while earlier data sit in the test set. That is data leakage. Use one of two methods that keep the order.
- Random shuffle breaks time order; leaks the future
- Time-based split Memorize earlier trains, later tests
- Rolling-window validation Memorize fixed window, moved forward
- A time-based split uses earlier data to train and later data to validate and test.
- Rolling-window validation trains on a fixed-length window, validates on the period right after it, then moves the window forward and repeats.
Exam tip Validation and test sets should be at least as long as the forecast horizon. To forecast 12 months ahead, test on at least 12 months. (In the example, 18 months is enough.)
A trained model can be used on other datasets only if they are similar enough. Even a model trained on one group of shares may need further training (fine-tuning) before it predicts another group well. Human judgment stays essential: understanding the data, cleaning it, choosing the method and the model structure, handling outliers and volatility shifts, and controlling bias. Small datasets need extra care.
What are the four approaches to ML?
- Supervised learning Memorize labeled inputs and outputs; predicts or classifies
- Unsupervised learning Memorize unlabeled data; finds structure and groups
- Reinforcement learning Memorize rewards and penalties; trial and error
- Deep learning Memorize neural networks with many layers
- Supervised
- Unsupervised
- Semi-supervised
-
| Approach | Learns from | Finance example | Strengths | Limits |
|---|---|---|---|---|
| Supervised | labeled inputs and outputs | predict whether a market index will be up, down or flat tomorrow; predict bond downgrades from past bonds with known outcomes | accurate with enough data; well understood | needs lots of labeled data; may not generalize to entirely new situations |
| Unsupervised | unlabeled data | group 2,000 companies into peer groups by their financial ratios instead of sector labels; flag unusual transactions | finds hidden groups; can reduce the number of variables (dimensionality); good for exploring | results hard to interpret; patterns may not be meaningful; judging results is subjective |
| Reinforcement | rewards and penalties from interacting with an environment (trial and error) | a trading agent rewarded when its buy, sell or hold decisions raise risk-adjusted return, penalized when they cause losses | suits step-by-step decisions in changing settings; learns from experience | sensitive to a badly designed reward; needs heavy computing and long training |
| Deep learning | many-layered neural networks; supervised, unsupervised or semi-supervised | read text, recognize objects in satellite images | models complex, non-linear patterns; extracts features from raw data | needs large data and computing; black box; can overfit unless regularized |
In supervised learning , the training data carry labels, so the algorithm learns the link between inputs and a known answer, then predicts for new data. In unsupervised learning no answer is provided; the algorithm describes the data and finds groups. In reinforcement learning a program learns by trial and error, acting in an environment and receiving rewards and penalties. Deep learning uses neural networks with many hidden layers to process data in stages, building simple concepts into complex ones. It can be supervised, unsupervised or semi-supervised.
Exam tip Some summaries list only three main types (supervised, unsupervised, deep). Learn all four: reinforcement learning is the one that learns from rewards, with no labels.
Memorize
Try this 0 of 3
- Find the complexity with the lowest test error.
- Push training error below 0.01, then read the test error.
- Go back to a straight line and compare the two errors.
Degree 2 curve: training error 0.063, test error 0.149, about right. About right: the model catches the hump. Test error is 0.149; degree 3 does slightly better (0.101). A model that memorizes the past predicts the future badly.
The data and the fitted model
- Training
- Test (unseen)
- Model
Error against complexity
Drag the marker, or tap a degree, to change the model.
- Training error
- Test error
About right: the model catches the hump. Test error is 0.149; degree 3 does slightly better (0.101).
Show working
Training error = average of (actual − fitted)² over the 14 training points = 0.063.
Test error = the same average over the 6 test points the model never saw = 0.149.
Training error only falls as complexity rises (0.843 at degree 1, 0.003 at degree 12), so it cannot tell you when to stop.
Test error is lowest at degree 3 (0.101). At degree 12 it is 1.044, worse than the straight line's 0.924.
How can ML go wrong?
- Underfitted Memorize too simple; misses real patterns
- Well fitted captures signal; generalizes
- Overfitted Memorize too complex; learns noise; fails on new data
Overfitting happens when the model learns the training data too precisely. It is overtrained: noise is treated as signal, so it discovers false relationships. The model is too complex, scores brilliantly in-sample and predicts poorly on a different dataset. In symbols, an overfit model has a training error far below its test error: . A model that shows underfitting does the reverse: it treats real patterns as noise, is too simple, and does badly even on its training data.
Exam tip Great training score, poor test score means overfit. Poor everywhere means underfit.
Because nobody programs the rules, ML models can be black box models: their results are hard to explain. The label comes from their complexity and lack of interpretability, not from bias in the data.
Data mining is a subset of data science that searches large datasets for patterns with algorithms, for example ones built on Bayes’ theorem. Mining without real-world context finds patterns that are only noise, so domain expertise must confirm that a pattern makes sense.
Go deeper Overfitting, data mining and p-hacking
Overfitting is the machine-learning cousin of p-hacking in hypothesis testing. Try enough models or patterns on the same history and one will look good by chance. Both fail the same test: the result is not replicated on new data. That is why ML keeps a test set aside.
Go deeper Explainability and model risk
A black-box model can predict well and still be hard to defend. Regulated firms must be able to explain why a decision was made, and an unexplained model can break quietly when markets change. Human oversight of the data, the method and the output remains part of the process. The last lesson of this module covers how regulators and firms handle model risk.
How does a neural network learn?
A neural network is layers of connected nodes (neurons). The input layer has one neuron per feature, for example one per financial ratio. One or more hidden layers transform the data step by step (many hidden layers make the network “deep”). The output layer gives a classification (downgrade or not) or a number (a forecast return). Each connection has a weight. Neural networks date from 1958 and have been used for forecasting and pattern recognition since the early 1990s.
- Forward pass predict
- Loss calculation measure the error
- Backpropagation find each weight’s effect
- Gradient descent step against the gradient
Training repeats four steps:
- Forward pass. Data flow through the layers to a prediction.
- Loss. The error between the prediction and the actual value is measured.
- Backpropagation . The loss gradients show how each weight affects the error.
- Gradient descent . Each weight is moved a little in the direction opposite to the gradient, which lowers the loss.
One full pass over the training data is an epoch . Training runs many epochs until accuracy is good enough.
Generative adversarial networks and variational autoencoders
A generative adversarial network (GAN) pairs a generator network, which makes synthetic data, with a discriminator network, which tries to tell the synthetic data from real data. In finance it is used to create realistic synthetic data for training and for stress-testing strategies. A variational autoencoder (VAE) is an encoder–decoder network that compresses data and reconstructs it. It is used to reduce dimensionality and to detect anomalies.
| Method | Purpose | Structure | Type |
|---|---|---|---|
| Backpropagation | train (optimize) a network | one network | supervised |
| GAN | generate realistic data | generator + discriminator | adversarial |
| VAE | learn a compact representation | encoder–decoder | probabilistic generative |
Generative AI builds on GANs and VAEs; the last lesson of this module covers it.
Memorize this
MemorizeFour approaches to machine learning
| Approach | Learns from | Plus | Minus |
|---|---|---|---|
| Supervised | labeled data | accurate, well understood | needs labels; may not generalize to new situations |
| Unsupervised | no labels | hidden groups; reduces the number of variables | hard to interpret; evaluation is subjective |
| Reinforcement | rewards and penalties | suits sequential decisions | reward design; heavy computing |
| Deep learning | many-layered networks (supervised, unsupervised or semi-supervised) | complex non-linear patterns | data hungry; black box; overfits unless regularized |
Memory hook Supervised has a teacher (labels), unsupervised has none, reinforcement has a coach (rewards), deep learning is the engine (layers), not a kind of data.
Know it cold ML = "find the pattern, apply the pattern".
MemorizeOverfitting vs underfitting
| Overfitted | Underfitted | |
|---|---|---|
| What it did | learned the data too precisely, noise as signal | treated real patterns as noise |
| Model is | too complex | too simple |
| In-sample | excellent | poor |
| New data | poor | poor |
Memory hook Over = memorized the past (cannot generalize). Under = never learned it. Compare training score with test score.
Know it cold Overfit: . Black box = complexity, not data bias.
MemorizeSplitting the data
| Dataset | Training | Validation | Test |
|---|---|---|---|
| Standard | 60–80% | 10–20% | 10–20% |
| Larger | 70–80% | 10–15% | 10–15% |
| Smaller | 60–70% | 15–20% | 15–20% |
Memory hook Training always gets the most. More data → more for training.
Know it cold Time series: split by time (or rolling window), never shuffle; test period ≥ forecast horizon.
- Training dataset Memorize learn; the largest
- Validation dataset Memorize tune
- Test dataset Memorize judge on unseen data
- Random shuffle breaks time order; leaks the future
- Time-based split Memorize earlier trains, later tests
- Rolling-window validation Memorize fixed window, moved forward
- Supervised learning Memorize labeled inputs and outputs; predicts or classifies
- Unsupervised learning Memorize unlabeled data; finds structure and groups
- Reinforcement learning Memorize rewards and penalties; trial and error
- Deep learning Memorize neural networks with many layers
- Supervised
- Unsupervised
- Semi-supervised
-
- Underfitted Memorize too simple; misses real patterns
- Well fitted captures signal; generalizes
- Overfitted Memorize too complex; learns noise; fails on new data
- Forward pass predict
- Loss calculation measure the error
- Backpropagation find each weight’s effect
- Gradient descent step against the gradient
How it is asked
-
Labeled data, which type?
A model learns from bonds each marked "defaulted" or "did not default". Which type of learning?
Labeled outcomes make it supervised. Trap: unsupervised.
-
Perfect in-sample, poor out-of-sample
A model fits its training data almost perfectly but predicts poorly on new data. What is it?
Overfitted. Trap: underfitted ("too simple").
-
Group without categories
Stocks are grouped by similarity without predefined categories. Which approach?
Unsupervised learning. Trap: supervised or natural language processing (NLP).
-
Deep learning
Which describes deep learning?
Neural networks with many hidden layers, usable with supervised, unsupervised or semi-supervised approaches.
-
Rewards, no labels
A program learns when to buy, sell or hold from rewards tied to portfolio performance.
Reinforcement learning. Trap: supervised.
-
Largest dataset
Which subset is usually the largest?
Training (60–80%). Trap: test.
-
Time-series split
Ten years of daily returns: how to split?
By time: earlier data train, later data test. Trap: random shuffle (breaks order, leaks the future).
-
Limitation of an approach
Subjective evaluation of results is a limitation of which approach?
Unsupervised. Supervised: may not generalize to entirely new situations.
Exam traps
- Saying unsupervised learning uses labeled data. Labels are what make learning supervised.
- Calling an overfit model too simple. That is underfitting; overfit models are too complex.
- Treating deep learning as a kind of data. It is a technique, and it can be supervised, unsupervised or semi-supervised.
- Judging a model by its in-sample fit. The test is performance on data it has not seen.
- Shuffling a time series before splitting it. Use a time-based split or rolling window to keep the order and avoid data leakage.
- Saying ML is a black box because of biased data. It is a black box because it is complex and hard to interpret.
- Saying there are only three types of ML. Reinforcement learning is the fourth approach.
Checkpoint
6 exam-style questions. About 90 seconds each.
1A model is trained on 10 years of past bond data in which each bond is marked "defaulted" or "did not default". This is an example of:
2A model fits its training data almost perfectly but predicts poorly on new data. It is most likely:
3Grouping stocks by similarity without using any predefined categories is best described as:
4Which statement about deep learning is most accurate?
5An asset manager's program learns when to buy, sell or hold by acting in a simulated market. It earns a reward when the portfolio's risk-adjusted return improves and a penalty when losses grow. This approach is best described as:
6An analyst builds a model to forecast next month's index return from 12 years of daily data. Which way of dividing the data into training, validation and test sets is most appropriate?
Key takeaways
- ML, a branch of AI, learns patterns from data instead of following written rules.
- Supervised (labels), unsupervised (no labels), reinforcement (rewards), deep learning (layered neural networks).
- Train on the largest share (60–80%), tune on validation, judge on test; for time series, split by time.
- Overfit = learned the noise (training error far below test error); underfit = missed the pattern.
- Neural networks learn by forward pass, loss, backpropagation and gradient descent, repeated over epochs.
Questions about this lesson?
Where this comes back
- Data science: processing, visualization and text analytics Financial Data Science
Questions candidates ask
What is the difference between supervised and unsupervised learning?
Supervised learning is given labeled inputs and outputs and learns to predict the output for new data. Unsupervised learning is given data without labels and looks for structure, such as groups of similar companies.
What is overfitting in machine learning?
Overfitting occurs when a model learns its training data too precisely and treats noise as real patterns. It looks excellent in-sample but predicts poorly on new data. Underfitting is the opposite problem: a model too simple to find real patterns.
What is deep learning?
Deep learning uses neural networks with many hidden layers to find complex, non-linear patterns in stages. It can be supervised, unsupervised or semi-supervised and is strong at image, speech and pattern recognition.
What is reinforcement learning in finance?
An ML approach in which a program learns by acting in an environment and receiving rewards or penalties, with no labeled data. In finance it can learn a trading or portfolio strategy, rewarded when risk-adjusted returns improve. Its weak points are a badly designed reward and heavy computing needs.
Why should time-series data not be split at random?
Shuffling breaks the time order that financial data depend on and can put future observations in the training set, so the model is tested on data it has effectively seen (data leakage). Use a time-based split or rolling-window validation instead.
Spotted an error? Tell us and we will fix it.