---
title: "Financial Machine Learning: Labels, Purging, Trials"
description: "Why market data is hard for machine learning, and the method that matters: labels, overlap, purged validation, trial counts, bet size and the Indian rules."
source_url: "https://www.rupeecase.com/learn/path-19/module-19-14-financial-machine-learning"
---

[Path 19 14 of 16](/learn/path-19/)Financial machine learning done carefully[Next 19.15](/learn/path-19/module-19-15-expiry-day-market-integrity)

On 15 Sep 2026 the twenty session realised volatility of the Nifty was 7.3% a year. Across the 300 sessions in the NSE file that ends that day, the same measure ran from 5.2% to 29.5%. A model fitted inside one of those regimes has learned that regime, and nothing in its score says so. Machine learning works well where data carries a lot of signal. Market data carries little, comes as one history and keeps changing, so most of the work sits in the method around the model. This module is about that method. It is education: it names no strategy, promises no result and makes no call on any contract.

3By the end you can

1. Build a label and a validation split that respect overlap, with purging and an embargo.
2. Work out the effective sample, the noise in a hit rate and the chance a lucky variant passes.
3. Turn a model probability into a size with ruin in view, inside the Indian algo framework.

## The idea, plainly

### Why is market data hard for machine learning?

Four facts do the damage, and a good algorithm cannot remove any of them.

* **Small signal.** Daily returns are mostly noise, so a model can fit noise and look skilful.

* **One history.** The past cannot be re-run, so each idea is tested on the same data again and again.

* **A moving process.** Volatility, correlations, lot sizes, tax rates and settlement rules change.

* **Overlapping labels.** A label that looks ahead several days shares most of its days with its neighbours, so the sample is smaller than the row count.

The regime moves: twenty session volatility ran from 5.2% to 29.5%

Percent a year, close to close over twenty sessions. A model fitted on the low stretch has never seen the high one, and the reverse. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
A fit that is good inside one stretch can be poor in the next, and a single train and test split cannot tell the two cases apart. That is why the checks below are about how the data is cut, not about which model is used.

### What does a careful pipeline look like?

Each stage can fail without any error message, and a later stage cannot repair an earlier one. The map is a method, not a result.

A model passes seven checks before its score is worth reading

A method map, with no market figures. The ledger and the cost stage are the ones most often skipped. Source: RupeeCase method map, no market data. As of 17 Oct 2026.

* **Data:** each value as it was known on its date, not as later revised.

* **Features:** only what was known when the trade would have been placed.

* **Labels:** what a trade could earn after costs, not an arbitrary next day sign.

* **Ledger:** a count of every variant tried, kept even for the ones that failed.

### How should a label be built?

A fixed horizon label asks whether the price is higher in a set number of days. A triple barrier label is closer to a trade. It sets a profit barrier, a loss barrier and a time barrier, each scaled to recent volatility, and records which was touched first. Barriers wide in quiet markets and narrow in noisy ones keep the label comparable across regimes.

Meta-labelling splits the job. A simple rule decides the side of a trade, and a second model decides whether to take it and how large. The second model sees fewer, more selective rows, which is where overfitting waits.

### Why does overlap shrink the sample?

Label each day with the return of the next three. Today's label and the next day's label share two of their three days, so they are not independent rows. Counting them as independent overstates the evidence by about the horizon, and a fit on overlapping rows looks sharper than the data supports.

The maths: effective sample size
Uniqueness of a label =
average of 1 over the
number of labels sharing
each of its days
Effective N = sum of
uniqueness over all labels

With a horizon of h days and one label a day, each interior label shares its days with up to h minus one neighbours on each side, and its average uniqueness is close to one over h. The effective sample size is then about N over h. Sample weights equal to uniqueness give each stretch of time a fair say, and a weight can also scale with the size of the return, so large moves do not swamp the fit. The standard error of a hit rate p over N independent rows is the root of p times (1 minus p) over N, which at p of one half is one half over the root of N.

The term this section turns on: Effective sample size

From the module glossary; every term is in the Learn glossary too. Source: Module 19.14, Financial machine learning done carefully.

### What do purging and an embargo do?

Ordinary k fold validation shuffles rows into folds. With overlapping labels, a training row just before a test fold has a label window that reaches into it, so the model has seen part of its own answer. Purging deletes training rows whose label windows overlap the test period. An embargo also skips a short stretch after the test fold, because serial correlation lets information leak forward.

* Purge: drop training rows whose window crosses into the test fold.

* Embargo: drop a further slice, often a small share of the sample, after it.

* Walk forward testing, in module [A29](/learn/path-19/module-19-7-walk-forward-testing), never trains on the future by construction, but gives one path only.

The maths: combinatorial purged paths
Split the sample into N groups
Test k groups at a time
Splits = N choose k
Paths = splits times k over N

Each group appears in the test set in a share k over N of the splits, so the test results can be stitched into several full length paths instead of one. With six groups and two tested at a time that is 15 splits and 5 paths. A strategy then has a spread of results to read, not one number. Purging and an embargo apply to every split.

### How many tries did it take?

Every variant tried on the same history is a draw from the same noise. The honest question is not whether a model scored well but how many were tried to find it. The bars show the chance that at least one of n useless variants clears two standard errors above a coin flip by luck, each with a 2.3% chance on its own.

Twenty tries on one history clear a lucky bar more than a third of the time

Arithmetic of one minus the chance of no hit, with each variant independent and useless. Real variants are correlated, so the true figure is smaller but still grows with every try. Not market data. Source: RupeeCase arithmetic, not market data. As of 17 Oct 2026.
This is why the ledger matters. Module [E16](/learn/path-19/module-19-13-backtest-overfitting) turns the count of trials into a deflated Sharpe ratio. Until the count is known, a good score is a number without a denominator.

### Which features leak?

* **Revised data.** A figure restated later was not available on its date.

* **Look ahead in code.** A rolling window centred on the day, or a scaler fitted on the whole sample, uses the future.

* **Survivorship.** An index list as it stands today leaves out the names that dropped out.

* **Corporate actions.** A split or a bonus looks like a crash. The realised correlation file used in this course leaves out any name with a one day move above a quarter in a window, for that reason.

* **Rule changes.** Lot sizes, STT and settlement methods differ by date, and a model fitted across them mixes two products.

The relationship between stocks moves too. The twenty session realised correlation among the fifty Nifty names, on a fixed weight set, ran from 0.04 to 0.60 between 24 Sep 2025 and 15 Sep 2026, and stood at 0.10 on the last day.

The link between the names moves: correlation ran from 0.04 to 0.60

Realised correlation implied by the Nifty's variance and the weighted volatilities of its fifty names, twenty session window, weights of 10 Jun 2026 held fixed. A feature built on it inherits this drift. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.

### Which features matter, and how would anyone know?

Importance scores from a fitted model mislead when features are correlated: the score of one is split or stolen by its neighbours. Two checks help. Shuffle one feature at a time in a purged test fold and see how much the score falls, which is permutation importance. And test whether the features carry information in a fresh period, not only in the one used to rank them.

* A feature that ranks high in training and low in a later period was fitting that period.

* A cluster of related features is better judged as one group than one by one.

* Fewer, simpler features are easier to audit and cheaper to retest.

### How does a probability become a size?

A classifier outputs a probability, and a position size turns it into rupees. The Kelly fraction of an edge is the size that grows an account fastest if the edge is known exactly, and it is not known exactly. Sizes near or above it ruin accounts that have a real edge. The model below takes a rule that wins 52% of trades with equal wins and losses, so Kelly is 4% of the account.

Model, not market data

The same edge ruins few paths at a small size and most paths at twice Kelly

A model of one assumed rule, not a strategy and not market data. Only the risk per trade changes between the bars, from one to eight percent; the two percent named in the inputs is the base case, the second bar. Inputs: win rate 52%, average win 1.00 times the average loss, 2% of the account risked on each trade, ruin at a 50% loss of the starting account, 250 trades, 2,000 simulated paths, seed 1. Source: RupeeCase model, seeded simulation. As of 17 Oct 2026.
Read one more paragraph, 48 words
At 4% of the account per trade, the size equal to Kelly, 19% of paths still lose half. At 8%, twice Kelly, 57% do. A model that scores well is not a size. Fractions of Kelly, set from a fixed risk budget, sit in module [A31](/learn/path-17/module-17-22-kelly-sizing).

### What happens after it goes live?

A model keeps being tested after launch, because the world it was fitted on keeps moving. A written plan for that, fixed before the first order, is part of the method.

* **Drift checks.** Compare the live spread of features and of outcomes with the spread in training, on a schedule.

* **Stop rules.** A drawdown or a run of misses that pauses the program, set in advance and not by feel.

* **Retraining.** Each refit is a new variant. It goes in the ledger with its date and its data window.

### What do the Indian rules add?

* A program that sends orders through a broker's API is an algo order under SEBI's framework, whatever the model inside it (module [A27](/learn/path-19/module-19-5-building-a-compliant-algo)).

* Giving the model's signals or the algo to others is a different route, with its own registration and claims rules.

* Past performance may be shown only as verified figures by firms permitted to do so. A chart of a backtest is not that.

* SEBI's Aug 2026 study found 87.7% of individual F&O traders lost money in FY26. Costs and size decide many outcomes before any model does.

Watch in the terminal: which numbers am I looking at? A short tutorial on sample data.

## Worked example: a three day label on the sessions in the file

The NSE file behind the volatility chart has 300 Nifty closes. Take a label that looks three sessions ahead and one row a day, and read what the sample can support.

1. **Rows.** 300 closes give one row a day, before the last three rows lose their label.

2. **Overlap.** Neighbouring labels share two of three days, so the effective sample is about 300 over three: 100 independent rows.

3. **Noise.** The standard error of a hit rate over 100 independent rows is one half over ten: 5.0%.

4. **A bar.** Two standard errors above a coin flip is a hit rate of 60%, before any cost, to be seen as unusual on this sample.

5. **Purge and embargo.** With a three session label, drop 2 rows before a test fold, and an embargo of one percent of the sample is 3 rows after it.

6. **Trials.** If ten variants were tried, the chance that one clears the bar by luck is 21%. If twenty, it is 37%.

Read one more paragraph, 59 words
The same arithmetic shows the limit of the exercise. A hit rate in the high fifties on this sample is within the noise, and a model with a hundred features has far more freedom than a hundred rows can pin down. More history and a smaller set of ideas are the cures. Neither is a feature of the model.

## The common mistake

The claim: The model scored 70% accuracy on the test set, so it has an edge. A score says little until three things are known: how many variants were tried, whether the test rows overlapped the training rows, and what the trades earn after STT, charges and slippage. A hit rate does not give a payoff either, since a rule can win most trades and still lose money. Read a score as a hypothesis, test it on a later period it never touched, with costs charged, and quote the number of trials with it. The short answer is on [the machine learning question page](/learn/questions/does-machine-learning-work-for-trading).

Two terms to hold on to from 19.14

From the module glossary. Source: Module 19.14, Financial machine learning done carefully.

## Key takeaways

* Market data has little signal, one history and changing rules.
* Overlapping labels shrink a sample to about N over the horizon.
* Purge training rows that overlap the test fold, then embargo what follows.
* Count every variant tried: twenty tries clear a lucky bar often.
* A probability is not a size. Kelly is a limit, not a target.
* Test later data with costs charged, and quote the trial count.

Where this section sits in module 19.14

Sections 1 to 4 of 4; the highlighted one is next. Source: Module 19.14, Financial machine learning done carefully.
**Before you trade.** Derivatives trading carries a high risk of loss. SEBI's study "Profitability of Individual Traders in the Equity Derivatives Segment (FY25 to FY26)" (August 2026) found that 87.7% of individual traders in equity F&O made net losses in FY26, with aggregate net losses of Rs 91,685 crore. [Read the SEBI study](https://www.sebi.gov.in/reports-and-statistics/research/aug-2026/study-profitability-of-individual-traders-in-the-equity-derivatives-segment-fy25-fy26-_103835.html)

What does Financial machine learning done carefully cover?The model is rarely the weak point. The labels, the cuts of the data and the count of tries are. It works through The idea, plainly, Worked example: a three day label on the sessions in the file, The common mistake, Key takeaways. It is module 19.14 of Path 19, Algo, HFT and Backtesting, about 12 minutes of reading, free.

TTry it

## Risk of ruin, on the same example.
Win rate, payoff and size, simulated to the chance of losing the account. Dated NSE end of day data, nothing live, no orders.

**Risk of ruin**.

[Open the risk of ruin](/learn/tools/risk-of-ruin?preset=edge-big-size)

  AF&O on RupeeCase

## Hedging only, in development
F&O at RupeeCase will do one job: protect a portfolio you already own, by a rule published before it runs. No speculation, no naked option selling, no leveraged bets. It is not available yet.

  [How hedging will work](/hedging)[Sign up for RupeeCase](https://invest.rupeecase.com/signup)

  [No hedgeFalls with the marketWith a putA floor, for a premiumIllustration with made up numbers, not a product and not a recommendation.](/hedging)

QQuick check

## 10 questions, 7 to pass.
Each attempt draws 10 of the 15 questions in this module's bank, and a retake draws a fresh set. A pass gives this module's Certificate of Completion. Your result stays on this device and counts towards the Path 19 certificate.

7 of 10 correct passes module 19.14

Every answer is explained when you check; a retake is always free. Source: RupeeCase Learn quiz rules (70% to pass).

  Passed

###

  Certificate ID

Download PNGPrint or save as PDF[Check the ID](/learn/certificates/verify)
Self paced and unproctored. A record of completing free education by RupeeCase; not a NISM certificate and not endorsed by NISM, NSE, BSE or SEBI. It qualifies no one to deal, advise or publish research.

CCheck yourself

## Path 19 so far.
Your quick check results on this device, stop by stop.

Stop 14 of 16 on Path 19

Algo, HFT and Backtesting: every live stop, this module ringed. Source: RupeeCase Learn, Path 19.

1. [19.1What a backtest is, and five biases that ruin itNot yet](/learn/path-19/module-19-1-backtest-biases)
2. [19.2Strategy metrics: CAGR, Sharpe, Sortino, drawdown and expectancyNot yet](/learn/path-19/module-19-2-strategy-metrics)
3. [19.3HFT, MFT and LFT comparedNot yet](/learn/path-19/module-19-3-hft-mft-lft)
4. [19.4Colocation, latency and fairness: NSE's historyNot yet](/learn/path-19/module-19-4-colocation-and-latency)
5. [19.5Building a compliant retail algoNot yet](/learn/path-19/module-19-5-building-a-compliant-algo)
6. [19.6Backtesting options on Indian dataNot yet](/learn/path-19/module-19-6-backtesting-options)
7. [19.7Walk forward and out of sample testingNot yet](/learn/path-19/module-19-7-walk-forward-testing)
8. [19.8Monte Carlo and bootstrap of trade resultsNot yet](/learn/path-19/module-19-8-monte-carlo-and-bootstrap)
9. [19.9Microstructure models: spreads, informed trading and price impactNot yet](/learn/path-19/module-19-9-microstructure-models)
10. [19.10Market making: inventory and quotingNot yet](/learn/path-19/module-19-10-market-making)
11. [19.11Optimal execution and market impactNot yet](/learn/path-19/module-19-11-optimal-execution)
12. [19.12HFT economics and the latency raceNot yet](/learn/path-19/module-19-12-hft-economics)
13. [19.13Backtest overfitting: deflated Sharpe, PBO and multiple testingNot yet](/learn/path-19/module-19-13-backtest-overfitting)
14. [19.14Financial machine learning done carefullyNot yet](/learn/path-19/module-19-14-financial-machine-learning#quiz)
15. [19.15Expiry day market integrity: a SEBI interim order, FutEq limits and surveillanceNot yet](/learn/path-19/module-19-15-expiry-day-market-integrity)
16. [19.16Capstone: a research note on an Indian derivatives questionNot yet](/learn/path-19/module-19-16-capstone-research-note)
17. [TPath test, 30 questionsNot yet](/learn/path-19/module-19-16-capstone-research-note#pathTestSection)

Path 19 in reading time: 172 minutes over 16 modules

Minutes of reading per module, this one in amber. Source: RupeeCase Learn, Path 19.

    Explore next

## Put the module to work.

* [ToolOption payoff builderLegs on a dated Nifty chain, breakevens and charges](/learn/tools/payoff-builder)
* [Free module 19.1What a backtest is, and five biases that ruin it9 min read](/learn/path-19/module-19-1-backtest-biases)
* [Free module 19.5Building a compliant retail algo10 min read](/learn/path-19/module-19-5-building-a-compliant-algo)
* [Free module 19.6Backtesting options on Indian data11 min read](/learn/path-19/module-19-6-backtesting-options)
* [Free module 19.7Walk forward and out of sample testing10 min read](/learn/path-19/module-19-7-walk-forward-testing)
* [Free module 19.8Monte Carlo and bootstrap of trade results10 min read](/learn/path-19/module-19-8-monte-carlo-and-bootstrap)

      Community

## Join my WhatsApp group.

      Scan the code, fillFill one short form, and join my WhatsApp group. Slides, sources, factsheets and the rebalance logs live there, and members join a daily Google Meet with me.

      New to RupeeCase? [Getting started](/getting-started) [See the terminal](/terminal)

        [Sign up for RupeeCase](https://invest.rupeecase.com/signup)
        [Join the WhatsApp group](https://forms.gle/C6HMtM1Z2GfeocQV7)

      [One form, one group](https://forms.gle/C6HMtM1Z2GfeocQV7)Scan with your phone camera

SSources

## Go to the source.
6 sources, SEBI the most cited

The publisher of each source listed below. Source: Module 19.14 source list.
1. [SEBI circular SEBI/HO/MIRSD/MIRSD-PoD/P/CIR/2025/0000013, Safer participation of retail investors in algorithmic trading (4 February 2025)](https://www.sebi.gov.in/legal/circulars/feb-2025/safer-participation-of-retail-investors-in-algorithmic-trading_91614.html) SEBI
2. [SEBI, Profitability of Individual Traders in the Equity Derivatives Segment, FY25 to FY26 (August 2026)](https://www.sebi.gov.in/sebi_data/attachdocs/aug-2026/1787233506209.pdf) SEBI
3. [SEBI, norms for sharing and usage of price data for educational purposes (8 May 2026)](https://www.sebi.gov.in/legal/circulars/may-2026/norms-for-sharing-and-usage-of-price-data-for-educational-purposes_101293.html) SEBI
4. [NSE, derivatives reports and daily end of day files](https://www.nseindia.com/all-reports-derivatives) NSE
5. Lopez de Prado, M., Advances in Financial Machine Learning, Wiley, 2018 (labels, sample weights, purged cross validation) Book
6. [Bailey, D., Borwein, J., Lopez de Prado, M. and Zhu, Q., The Probability of Backtest Overfitting, Journal of Computational Finance, 2017](https://doi.org/10.21314/JCF.2016.322) Paper

GTerms

## 5 terms from this module.
Triple barrier labelA label that records which of three barriers a trade touches first: a profit barrier, a loss barrier or a time limit, each scaled to recent volatility.
Meta-labellingA second model that decides whether to take the trade a simple rule proposes, and how large to make it. The rule sets the side, the model sets the take or skip and the size.
PurgingDeleting training rows whose label windows overlap the test period, so the model is never trained on part of its own answer.
EmbargoA short stretch after a test fold that is also dropped from training, because serial correlation lets information leak forward.
Effective sample sizeThe number of independent rows a sample is worth once overlapping labels are accounted for. With a label horizon of h days and one row a day it is about N over h.
[All 230 terms in the glossary](/learn/glossary)

[Question people askDoes machine learning work for trading?A short answer with a dated chart](/learn/questions/does-machine-learning-work-for-trading)[Related module19.1 What a backtest is, and five biases that ruin it9 min, Intermediate](/learn/path-19/module-19-1-backtest-biases)[Related module19.5 Building a compliant retail algo10 min, Advanced](/learn/path-19/module-19-5-building-a-compliant-algo)[Pillar guideDerivatives and Quant115 modules across paths 12 to 19](/learn/derivatives)

Education only, not investment advice, a research report or a recommendation to buy, sell or hold any security. RupeeCase (QC Alpha Technologies Pvt Ltd) is not registered with SEBI as an investment adviser or research analyst. Contracts and prices shown are for illustration only, come from NSE end of day files at least 30 days old, and are not recommendatory. Derivatives trading carries a high risk of loss.
