Analyst Dojo
Lesson 2 of 4 11–14% of the exam

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.

7 min cram, 28 min full read. Based on the 2027 CFA® Program Level I curriculum, Quantitative Methods, Learning Module 11. Sitting in November 2026? The 2026 version of this lesson is still available.

Tailor this to you: take the self-assessment

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.

Cram mode: the one-screen version of this lesson. Switch to Full for the explanations, worked examples and interactives.

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.

The three datasets
Available data
  • 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.

DatasetTrainingValidationTest
Standard60–80%10–20%10–20%
Larger datasets70–80%10–15%10–15%
Smaller datasets60–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.

Splitting a time series
Splitting a time series
  • 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?

Approaches to machine learning
Machine learningfind the pattern, apply the pattern
  • 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
ApproachLearns fromFinance exampleStrengthsLimits
Supervisedlabeled inputs and outputspredict whether a market index will be up, down or flat tomorrow; predict bond downgrades from past bonds with known outcomesaccurate with enough data; well understoodneeds lots of labeled data; may not generalize to entirely new situations
Unsupervisedunlabeled datagroup 2,000 companies into peer groups by their financial ratios instead of sector labels; flag unusual transactionsfinds hidden groups; can reduce the number of variables (dimensionality); good for exploringresults hard to interpret; patterns may not be meaningful; judging results is subjective
Reinforcementrewards 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 lossessuits step-by-step decisions in changing settings; learns from experiencesensitive to a badly designed reward; needs heavy computing and long training
Deep learningmany-layered neural networks; supervised, unsupervised or semi-supervisedread text, recognize objects in satellite imagesmodels complex, non-linear patterns; extracts features from raw dataneeds 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

InteractiveHow complex should the model be?

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

−20246Next-quarter return (%)0246810Sentiment score
  • Training
  • Test (unseen)
  • Model

Error against complexity

0.00.30.60.91.2Mean squared error136912Complexity (degree)UnderfitAbout rightOverfit

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).

ModelDegree 2 curve
Training error0.063
Test error0.149
VerdictAbout right
The model
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.

A model that memorizes the past predicts the future badly.

How can ML go wrong?

Getting the fit right
Model fit
  • 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: Errortrain≪Errortest\text{Error}_{train} \ll \text{Error}_{test}. 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.

Training a neural network
Training a neural networkrepeated over many epochs
  • Forward pass predict
  • Loss calculation measure the error
  • Backpropagation find each weight’s effect
  • Gradient descent step against the gradient

Training repeats four steps:

  1. Forward pass. Data flow through the layers to a prediction.
  2. Loss. The error between the prediction and the actual value is measured.
  3. Backpropagation . The loss gradients show how each weight affects the error.
  4. 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.

MethodPurposeStructureType
Backpropagationtrain (optimize) a networkone networksupervised
GANgenerate realistic datagenerator + discriminatoradversarial
VAElearn a compact representationencoder–decoderprobabilistic generative

Generative AI builds on GANs and VAEs; the last lesson of this module covers it.

Memorize this

MemorizeFour approaches to machine learning

ApproachLearns fromPlusMinus
Supervisedlabeled dataaccurate, well understoodneeds labels; may not generalize to new situations
Unsupervisedno labelshidden groups; reduces the number of variableshard to interpret; evaluation is subjective
Reinforcementrewards and penaltiessuits sequential decisionsreward design; heavy computing
Deep learningmany-layered networks (supervised, unsupervised or semi-supervised)complex non-linear patternsdata 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

OverfittedUnderfitted
What it didlearned the data too precisely, noise as signaltreated real patterns as noise
Model istoo complextoo simple
In-sampleexcellentpoor
New datapoorpoor

Memory hook Over = memorized the past (cannot generalize). Under = never learned it. Compare training score with test score.

Know it cold Overfit: Errortrain≪Errortest\text{Error}_{train} \ll \text{Error}_{test}. Black box = complexity, not data bias.

MemorizeSplitting the data

DatasetTrainingValidationTest
Standard60–80%10–20%10–20%
Larger70–80%10–15%10–15%
Smaller60–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.

The three datasets
Available data
  • Training dataset Memorize learn; the largest
  • Validation dataset Memorize tune
  • Test dataset Memorize judge on unseen data
Splitting a time series
Splitting a time series
  • Random shuffle breaks time order; leaks the future
  • Time-based split Memorize earlier trains, later tests
  • Rolling-window validation Memorize fixed window, moved forward
Approaches to machine learning
Machine learningfind the pattern, apply the pattern
  • 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
Getting the fit right
Model fit
  • Underfitted Memorize too simple; misses real patterns
  • Well fitted captures signal; generalizes
  • Overfitted Memorize too complex; learns noise; fails on new data
Training a neural network
Training a neural networkrepeated over many epochs
  • Forward pass predict
  • Loss calculation measure the error
  • Backpropagation find each weight’s effect
  • Gradient descent step against the gradient

How it is asked

  1. 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.

  2. 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").

  3. Group without categories

    Stocks are grouped by similarity without predefined categories. Which approach?

    Unsupervised learning. Trap: supervised or natural language processing (NLP).

  4. Deep learning

    Which describes deep learning?

    Neural networks with many hidden layers, usable with supervised, unsupervised or semi-supervised approaches.

  5. Rewards, no labels

    A program learns when to buy, sell or hold from rewards tied to portfolio performance.

    Reinforcement learning. Trap: supervised.

  6. Largest dataset

    Which subset is usually the largest?

    Training (60–80%). Trap: test.

  7. 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).

  8. 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.

  1. 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:

  2. 2A model fits its training data almost perfectly but predicts poorly on new data. It is most likely:

  3. 3Grouping stocks by similarity without using any predefined categories is best described as:

  4. 4Which statement about deep learning is most accurate?

  5. 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:

  6. 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.

All Quantitative Methods formulas, every lesson

Practice exam-style questions on Financial Data Science

Questions about this lesson?

Where this comes back

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.

  1. Big data, the four Vs and alternative data
  2. AI and machine learning: supervised, unsupervised, reinforcement, deep
  3. Data science: processing, visualization and text analytics
  4. Large language models and generative AI in finance

Ask Sensei Listen instead

Questions on AI and machine learning: supervised, unsupervised, reinforcement, deep

Learn with Sensei, out loud The voice tutor, in early access

Sensei teaches the lesson aloud and stops when you interrupt: "wait, why is the geometric mean lower?" It answers with the lesson's own example, then quizzes you by voice. Every account can try Sensei on one module, with one voice question.

USD 149 a month founding price (regular USD 199), kept for as long as you stay subscribed. Everything in Plus included.

In active development and improving every day. Send feedback · Plans and pricing

Analyst Dojo Plus

Your free review list holds 10 items.

Plus keeps everything you save, for USD 19 a month. To make room on the free plan, remove something from your review list.

See Plus

Lessons, checkpoints and the lesson questions in practice stay free. Compare plans