Fin Maverick
Foundations VocabularyAccounting & ReportingEconomics & MacroQuant Methods & ProgrammingBusiness & Company AnalysisCorporate Finance & ValuationBehavioural Finance
Banking & Market InfrastructureFixed Income & RatesDerivatives & Structured ProductsPublic EquitiesTransactions & DealsPortfolio ConstructionFunds & AMCs
Private Markets & AlternativesRisk, Treasury & ControlAI & Digital FinanceStochastic Calculus & PricingWealth & Personal FinanceIndian Markets & RegulationProfessional Practice
CalculatorComparison
Frameworks
Explore Bootcamps
Equity ResearchPortfolio ManagementMutual Fund MasteryFinancial LiteracyInvestment Banking Analyst
Private Equity AnalystHedge Funds AnalystBreaking Into VCBreaking Into QuantsAI For Finance
Financial Analyst ProgramRisk Management ProgramPrivate Wealth ManagementDebt Capital MarketsDerivatives Foundation
Explore Internships
Equity Research InternMutual Fund Intern
Portfolio Management InternFinancial Literacy Intern
Explore Micro Courses

Equity Research6

Writing an Investment ThesisBuilding a Discounted Cash FlowReading an Annual Report FastReading a Sector Before a CompanySpotting Quality of Earnings Red FlagsBuilding a Revenue Forecast From Drivers

Portfolio Management3

Rebalancing: When, Why and What It CostsStrategic and Tactical Asset AllocationMeasuring Risk in a Portfolio

Mutual Fund Mastery3

Comparing Funds Without Being FooledHow a NAV Is Struck and Which Day You GetReading a Fund Factsheet Properly

Derivatives Unlocked4

Hedging a Real ExposureThe Greeks, PracticallyFutures, the Basis and What Moves ItReading an Option Payoff

AI For Finance2

Retrieval and Grounding for FinanceDocument Extraction in Finance

Breaking Into Quants4

Backtesting a StrategyHypothesis TestingCleaning Financial DataRegression for Finance

Breaking Into VC3

Sizing a MarketReading a Term Sheet as a FounderHow a Venture Round Actually Works

Financial Analyst Program4

Common Size and Trend AnalysisReading a Cash Flow StatementRatio Analysis That Says SomethingBuilding a Working Capital Schedule

Risk Management Program2

Credit Exposure and How It Is ReducedValue at Risk and What It Hides

Investment Banking Analyst3

Precedent Transactions and Why They DifferReading a Term Sheet StructurallyBuilding a Comparable Companies Table

Private Wealth Management3

Tax Aware Portfolio DecisionsBuilding a Client Risk ProfileGoal Based Planning Arithmetic

Debt Capital Markets3

Analysing an Issuer's CreditDuration and What It Does Not Tell YouBond Pricing and Yield Mechanics

Private Equity Analyst2

Fund Waterfalls and CarryThe LBO in Structure

Hedge Funds Analyst2

Short Selling MechanicsLong Short Mechanics
Courses
Explore Career Roadmaps
Investment Banking AnalystEquity Research AnalystVC AnalystPrivate Equity AnalystHedge Funds Analyst
Quant AnalystAI For FinanceFinancial Analyst ProgramPrivate Wealth ManagementDebt Capital Markets
Risk Management ProgramDerivatives FoundationPortfolio ManagementMutual Fund Mastery
PartnershipsShowdown
Log inSign up
Quant Analyst · CoreTrack
1Quantitative Methods, Financial Data & Programming
iProbability
Probability in FinanceRandom VariableProbability DistributionsThe Normal DistributionNormal Distribution ProbabilityThe Lognormal DistributionRandomness vs Uncertainty
iiStatistics and Inference
Population and SampleMean, Median and ModePrecision and AccuracyVariable TypesVariance, Standard Deviation and…Dispersion MeasuresStatistical BiasEffect SizeHypothesis TestingThe Sampling DistributionSkewnessKurtosisCovarianceConfidence IntervalArithmetic Mean vs Geometric MeanStatistical Significance vs Economic…Confidence Interval vs Prediction IntervalHow to Summarise a…
iiiCorrelation and Regression
RegressionCorrelation and CausationOrdinary Least SquaresInteraction TermsRegression CoefficientsRegression vs ClassificationHow to Build a…Spurious CorrelationRegression, Correlation and FitResidualsMulticollinearityAutocorrelation and Partial Autocorrelation
ivTime Series
Time Series in FinanceSimple, Weighted and Exponential…Moving Average CalculatorPrice, Return and Level SeriesHow to Prepare Time-Series…LagFrequencySeasonalityTimestampsTrendStationarity and the Unit RootHeteroskedasticityLeadRolling WindowsDifferencing
vSimulation and Numerical Methods
SimulationMonte Carlo SimulationHow to Run a…Numerical MethodsIterationResampling and the BootstrapPseudorandom Numbers and the SeedConvergence and ToleranceNumerical Stability
viOptimisation
OptimisationLocal and Global OptimaConstraintsConvex OptimisationThe SolverLinear ProgrammingThe Objective FunctionConstraint ViolationThe Feasible SetLagrange MultipliersQuadratic Programming
viiModelling Practice
Linear, Logistic, Ridge and…Training, Validation and Test…The ModelModel ErrorDependent and Independent VariablesThe ROC Curve and AUCWhat a Model HoldsMSE, RMSE, MAE and MAPEPrecision and RecallCross Validation and RegularisationOverfitting and UnderfittingReturn Series MeasuresSimple, Compound and Log Return
viiiBacktesting and Research Integrity
BacktestingBacktest vs Live PerformanceHow to Document a…How to Prevent Backtest…Out-of-Sample TestingWalk-Forward AnalysisMultiple TestingP-HackingData Snooping
ixData Quality and Structure
Data QualityThe DatasetSelection and Survivorship BiasVersioned DatasetsData Structures in FinanceData CleaningMissing Data and Null ValuesStructured Data vs Unstructured DataMissing Data vs ZeroData Validation vs Data CleaningOutliersDuplicate Records
xProgramming for Finance
Data PipelinesAPIs for Financial DataAPI vs CSV FileDatabases in FinancePython for FinanceJoinsSQL for FinanceThe Analysis Workflow
xiQuantitative Research
Research DesignThe Data Generating ProcessReproducibilityPeer Review in Analytical WorkThe Research HypothesisRobustness and Sensitivity
2Stochastic Calculus & Derivative Pricing Theory
iProbability Foundations
The Probability SpaceRandom VectorsSigma-AlgebraExpectationSample Space and EventsDensity and Distribution FunctionsRisk-Neutral ProbabilityState Price Density vs…
iiStochastic Processes and Jumps
Properties of a Stochastic ProcessMartingaleBrownian Motion and Its PropertiesBrownian Motion vs Geometric…Stopping TimeThe Markov PropertyState VariablesTransition ProbabilityQuadratic VariationQuadratic Variation vs Ordinary…Submartingale and SupermartingaleMartingale RepresentationMarkov Process vs MartingaleOptional StoppingFiltrationJump ProcessesThe Poisson ProcessLevy ProcessesJump Diffusion
iiiIto Calculus
The Ito IntegralThe Ito Integral vs the Riemann IntegralInfinitesimals in Stochastic CalculusQuadratic CovariationIto's LemmaHow to Apply Ito's…The Infinitesimal GeneratorIto Calculus vs Ordinary Calculus
ivStochastic Differential Equations
Stochastic Differential EquationsStochastic Differential Equation vs…Drift and DiffusionStrong and Weak Solutions ComparedDiscretisationGeometric Brownian Motion
vPricing Theory and No-Arbitrage
No-ArbitrageGirsanov, Radon-Nikodym and Change…Physical and Risk-Neutral Measures…The Fundamental Theorems of…The Law of One PriceThe Pricing KernelDiscount Factors and Zero-Coupon PricesReplication vs HedgingComplete Market vs Incomplete MarketClearing Margin Architecture
viOption Pricing Theory
European and American OptionsMonte Carlo European OptionThe Black-Scholes PDEBlack Scholes and the GreeksThe Payoff FunctionThe Binomial ModelBinomial Option PricingDelta Hedging in TheoryBoundary, Initial and Terminal ConditionsThe Exercise BoundaryHow to Check Put-Call…
viiVolatility Models
Constant, Local and Stochastic…Vasicek Model vs CIR ModelThe Heston ModelThe SABR ModelThe Volatility ProcessImplied VolatilityVolatility Smile vs Skew vs Surface
viiiInterest Rate Models
Interest-Rate DerivativesMean ReversionThe Zero-Coupon BondThe Ornstein-Uhlenbeck ProcessThe Discount CurveZero RatesShort-Rate Model vs Market Model
ixNumerical Pricing
Closed Form and Numerical…Monte Carlo PricingEuler and Milstein Schemes ComparedTree MethodsFinite Difference MethodsNumerical Error and StabilityVariance Reduction
xCalibration and Model Risk
Model OverrideMarket Price and Model PriceCalibrationHow to Document a Pricing ModelThe Educational Illustration LabelMarket ConventionsModel Uncertainty and LimitationsBacktesting a Pricing ModelIdentifiabilityCalibrated ParametersThe Calibration Loss Function

Cross Validation and Regularisation: Testing Honestly, and Penalising Complexity on Purpose

Three things are taken as already settled: how a straight line gets fitted to a record, what cutting a record into parts is for, and why two columns saying almost the same thing hand back a wobbly pair of numbers. The ten paired months are the same ten months set out under fitting a straight line to a record, decimal for decimal.

What problem is cross validation actually solving?

Without the problem in front of you, cross validation looks like extra work for no reason. So the problem comes first. Holding two of the ten paired months of the Nakshatra unit and the Vasant unit back, fitting a straight line on the rest, and scoring the line on the two months it never saw gives one number. A different pair held back gives a different number. Across all 1,260 ways of cutting ten months into six for fitting, two for checking and two for scoring, the score on the held outKept aside and not shown to the fitting step, so the model has to produce an answer for it blind. What the parts of a split are called and what each is for is worked through separately. months lands anywhere between 0.1865 and 16.5680.

The range from 0.1865 to 16.5680 is not a sign that somebody chose badly, and no amount of care in choosing one cut will close it. The same ten months, the same shape of model, the same arithmetic every time. All that moved was which two months got held back. When a record is short, the answer from one split is mostly a statement about the split.

The everyday version: judging how good a cook somebody is by tasting one dish. If the dish is their best one the verdict is impressed; if it is the one they were making for the first time the verdict is unfairly unimpressed. The fix is not to choose the dish more carefully. Nobody is in a position to choose well. Which dishes are which is not yet known. The fix is to taste several, and then to look at the whole set rather than at any one of them.

Two more numbers from those 1,260 cuts stop a very common overstatement, and are worth holding on to. Across all of them, the average miss on the months used to fit was 4.1784 and the average miss on the held-out months was 5.7340. So held-out months are worse on average. But the held-out months were worse in only 797 of the 1,260 cuts, or 63.25 per cent, and better in the other 463. A model does not always do worse on data it has not seen, and on this record it does better nearly two times in five.

ONE CUT OF TEN MONTHS IS A LOTTERY TICKET, AND HERE IS THE WHOLE PRIZE TABLE the root mean squared miss on the held-out months, over every one of the 1,260 cuts. All figures invented. 4.1784 average on the months used to fit 5.7340 average on the months held out 0.1865 at the luckiest of the 1,260 cuts 16.5680 at the unluckiest and the honest counterweight, cut by cut: 797 cuts, worse on the held-out months 463 cuts, better Held-out months are worse 63.25 per cent of the time on this record, which is not the same as always.
Across all 1,260 ways of cutting these ten months the score on the held-out months runs from 0.1865 to 16.5680 on one unchanged model, and those months came out worse in 797 cuts and better in 463.
Try it out

What problem is cross validation solving?

Breaking Into Quants Bootcamp — Fin Maverick

How does leaving one month out at a time work?

Leaving one out is the purest version of the idea, and it is easier to describe than almost anything else in modelling. Fit the straight line on nine of the ten paired months. Ask it for the tenth. Write down how far it missed. Then put that month back, take a different one out, and do the whole thing again. Ten months means ten fits and ten predictions.

Every month gets a turn at being the one nobody trained on, and no month ever helps predict itself. That second half is the property that makes the resulting figure worth anything at all. In each of the ten rounds the model was built by a fitting step that had never seen the month it was about to be asked about, so the miss it records is a genuine miss rather than a memory.

The ten squared misses come out as 1.2346, 121.4494, 95.9600, 0.0000, 30.8642, 0.0000, 13.4944, 11.1111, 5.9975 and 30.8642. Their average is a mean squared missTake how far the rule was wrong in each period, square each of those, and average them. Squaring is what makes a big miss count for much more than a small one. How this measure compares with three other ways of scoring the same misses is taken up separately. of 31.0975, whose square root is 5.5765 and which sits back in the units the Vasant unit is measured in.

Two of those ten are exactly nought, and they deserve a second look: they carry the sharpest warning cross validation has to offer. Month 4 and month 6 are the two months the fitted line misses by nothing at all. With either of them taken out the line does not move, so when it is asked about the month it just dropped it hits it perfectly. A perfect score arrived at that way says nothing whatsoever about the model, and anybody quoting month 4 alone as evidence has quoted an accident.

TEN FITS, AND EVERY MONTH SITS OUT EXACTLY ONCE a lime cell is the month held back from that fit. All ten months and all figures invented. MONTH 1 2 3 4 5 6 7 8 9 10 SQUARED MISS Month 4 and month 6 read 0.0000 because the line already misses them by nothing, so dropping either one leaves it unmoved.
Leaving one month out fits the straight line ten separate times so that every one of the ten paired months is predicted once by a model that never saw it, and two of those predictions land exactly on the outcome for a reason that carries no credit.
Try it out

In leaving one month out on a ten month record, how many times is each month used to fit the model?

How far out is the figure a fitting routine prints by itself?

Try it out

The in-sample mean squared miss on these ten paired months is 21.8000. What does leaving one month out give?

Fit the straight line on all ten paired months of the Nakshatra unit and the Vasant unit, then score it on those same ten months, and the mean squared miss is 21.8000. A fitting routine reports 21.8000 as the in sampleScored on the very records the fitting step was given. The opposite of scoring on records kept aside. What the parts of a split are called is worked through separately. figure, printed in the summary the moment the fit finishes, without anybody asking for it.

The honest figure, from leaving one month out, is 31.0975. The in-sample figure sits 29.90 per cent below the honest one, and the honest one sits 42.65 per cent above it. Those two percentages describe the same gap read from opposite ends, and both are worth quoting because people reach for whichever one flatters the model.

Why does the gap exist at all? Because the fitting step had those ten months in front of it while it chose the slope and the intercept, and it chose them to make the misses on exactly those ten months small. Some of what it fitted was the relationship. Some of it was the particular wobble of these particular months. When the model is then scored on the same months, it gets credit for both. Score it on a month it has not seen and only the first part still helps. An in-sample figure is optimisticBetter than the truth, and biased in one direction rather than simply uncertain. An optimistic figure is not a wrong guess that could have gone either way. It leans the same way every time. by construction, not by accident, and on a record this short it is optimistic by a lot.

Five folds of two months gives 34.2305, higher still. The reason is worth stating plainly. Each of those five fits gets only eight months to learn from. Each leave-one-out fit gets nine. Less to learn from means a worse model, and a worse model misses further. The trade between months to learn from and months to test on sits behind every choice of how many folds to use.

THE SAME TEN MONTHS, SCORED THREE WAYS mean squared miss, in squared percentage points. All figures invented. 21.8000 31.0975 34.2305 every month used to fit, then scored leave one month out, ten separate fits five folds of two, cut in time order The first figure sits 29.90 per cent below the second one. Read the other way, the second sits 42.65 per cent above the first. Five folds is higher again because each of its fits gets eight months, not nine.
On these ten paired months the in-sample mean squared miss is 21.8000 against 31.0975 for leaving one month out and 34.2305 across five folds, so the figure a fitting routine prints by itself understates the honest one by 29.90 per cent.
AI For Finance Bootcamp — Fin Maverick

What do the individual folds look like when they are opened up?

Cut the ten paired months into five folds of two, keeping the time order intact, so fold one is months 1 and 2, fold two is months 3 and 4, and so on to fold five with months 9 and 10. Each fold is scored by a model fitted on the other eight months. Five folds, five fits, five numbers.

The five come out as 66.7652, 49.5921, 16.5556, 15.7551 and 22.4846. Average them and the answer is 34.2305, the figure a summary would report. Now look at what that average is standing in for. The worst fold is 4.24 times the best, on one record, one shape of model and one unchanged run of arithmetic.

The five fitted slopes are just as restless: 1.3115, 1.7036, 1.4667, 1.5690 and 1.4471, against 1.5000 when all ten months are used. Drop two months from a ten month record and the line tilts noticeably. The shortness of the record is showing up in a second place.

Averaging several folds is the method itself, not a tidying-up step at the end. One fold is one split, and one split has already been shown to be a lottery ticket. Five of them do not make the noise vanish, but they do stop any single unlucky pair of months from deciding the whole answer. An average of five folds is worth quoting; any one of the five is not.

FIVE FOLDS, AND THE AVERAGE DESCRIBES NONE OF THEM WELL mean squared miss inside each fold. All ten months and all figures invented. 66.7652 49.5921 16.5556 15.7551 22.4846 the average, 34.2305 The worst fold is 4.24 times the best, on one record and one unchanged model. fold 1 months 1 and 2 fold 2 months 3 and 4 fold 3 months 5 and 6 fold 4 months 7 and 8 fold 5 months 9 and 10
The five fold misses of 66.7652, 49.5921, 16.5556, 15.7551 and 22.4846 average to 34.2305, and that average sits close to none of them because the worst fold is 4.24 times the best.
Try it out

The five fold misses are 66.7652, 49.5921, 16.5556, 15.7551 and 22.4846. What does their average of 34.2305 describe?

Play with it

Move the number of folds and watch the answer move with it.

One control cuts the same ten paired months into two folds, five folds or ten. The strip at the top redraws with the fold boundaries in their new places, a bar for each fold rescales against a fixed axis so the settings can be compared honestly, and the sentence underneath restates the number of folds, the average and the spread. Nothing else moves: the ten months, the time order and the straight line are all held still. Left alone, the control rests at five folds, where the average miss is 34.2305 and the folds run from 15.7551 to 66.7652, reproducing the worked example above exactly.

Jump straight to:
Months each fit learns from
8
Average miss across the folds
34.2305
Best fold
15.7551
Worst fold
66.7652
Held still at every setting: the ten paired months, their time order, the shape of the model, and the rule that each fold is scored by a fit built on every month outside it. Only the number of folds moves.

Educational illustration. One quantity moves and one only: the number of folds. Watch what becomes of the tested figure, and of the spread sitting behind it, as that number changes. A tested figure says how far a model missed on months it had not seen; it never says what the model would be good for.

Try it out

At ten folds each fit learns from nine months, and at two folds each fit learns from five. Why does the average miss come out lower at ten folds than at two?

What is regularisation, and how is it different from cross validation?

Cross validation and regularisation get run together constantly, and running them together is the single commonest confusion about both. The line between them comes before anything else. Cross validation measures. Cross validation leaves the model exactly as it found it and changes only how the model gets scored. Regularisation changes the model. Regularisation adds a charge to the fitting step that grows as the fitted coefficients grow, so the fitting can no longer chase the smallest possible miss without paying for the size of the numbers it uses to get there.

Only one of the two ever touches the model, and it is regularisation. A cross validated figure and an unvalidated figure describe the same model. A penalised fit and an unpenalised fit are two different models that happen to have been built from the same record.

The everyday version is a shop deciding tomorrow's prices. Cross validation is checking last month's price decisions against what actually sold, in five separate weeks rather than one, so the verdict does not rest on the week the weather was strange. Regularisation is a house rule, imposed before any pricing happens, that no single cost may swing the price by more than a certain amount. The shopkeeper has learned that letting one item dominate produces prices that look clever and behave badly.

So why do the two turn up together in nearly every description? Because a penalty has to have a size, and nothing in the record says what that size should be. Somebody has to choose it, and the sensible way to choose is to try several sizes and see which one holds up on months the fitting did not see. Cross validation is how the size of a penalty gets chosen, and that is the entire connection between the two ideas. Beyond it they have nothing to do with each other.

THE QUESTION CROSS VALIDATION REGULARISATION What does it change? how the model is scored and nothing else at all the fitting step itself so the fitted answer changes What does it measure? the miss on months kept back 31.0975, or 34.2305 in five folds nothing whatsoever it is not a measurement Does it touch the model? no, never it is untouched either way yes, always the coefficients move What must be chosen? a scheme, and how many folds two, five or ten on this record the size of the penalty and the record gives no answer The one link between the two columns: a penalty needs a size, and cross validation is how that size gets chosen.
Cross validation changes only how a model is scored while regularisation changes the fitting step itself, and the single thread joining them is that a penalty needs a size and cross validation is how that size gets settled.
Try it out

What is the difference between cross validation and regularisation?

What does a penalty buy, and what does it cost?

A penalty described in words sounds either obviously good or obviously arbitrary, and it is neither. So put a number on it. Bring in a third invented column, the Chandana unit. The Chandana unit nudges each Nakshatra reading by five hundredths of a percentage point in eight of the ten months and leaves it untouched in the other two. The two columns correlate at 0.999967. The two columns are, to any practical purpose, one body of evidence entered twice, and their variance inflation factorA score saying how much less confidently a coefficient can be pinned down because another input carries almost the same information. A value near one is untroubled; a very large value means two columns are close to interchangeable. It was built and explained in earlier reading. is 15001.

Fit the Vasant unit on both of them at once with no penalty and the pair of coefficientsThe numbers a fitted rule multiplies each input by before adding everything up. Settled by the fitting step, never chosen by hand. comes out as minus 1.0000 and 2.5000. Look at what that says. One of two nearly identical columns is being subtracted. The other is being added at two and a half times its size. The two together still add to 1.5000, the slope the Nakshatra unit alone would have carried. The fit could barely tell the two columns apart, so it produced an enormous pair that happens to cancel out.

Now add a penalty of one on the size of the coefficients and refit. The pair reads 0.7314 and 0.7661. The two numbers have closed from 3.5000 apart to 0.0347 apart, and the fitting step is no longer claiming that one column matters negatively and the other enormously. That is what a penalty buys: stability, and a pair of numbers a reader can look at without being misled.

The cost is measurable too, and a lot of writing on the subject overstates it. The R squaredHow much of an outcome's movement a fitted rule managed to track, put on a scale from nought to one. Where the measure comes from is settled in earlier reading and simply used here. falls from 0.756019 to 0.755950. It falls. The fit really does move, by 0.000069, and any account calling it unchanged has said something slightly false. The proportion is the honest way to put it: the coefficient moved 1.7314 and the fit moved 0.000069, roughly 24,974 times as far, so the honest claim is that a penalty buys stability at almost no cost in fit rather than at no cost at all.

A PENALTY OF ONE CLOSES THE PAIR AND BARELY TOUCHES THE FIT the two coefficients on the Nakshatra unit and the Chandana unit, on one shared scale. All figures invented. WITH NO PENALTY the pair sits 3.5000 apart, and R squared is 0.756019 3.5000 apart minus 1.0000 2.5000 WITH A PENALTY OF ONE the pair sits 0.0347 apart, and R squared is 0.755950 0.7314 and 0.7661 one mark at this scale minus 1 0 1 2 3 The fit moved by 0.000069. The coefficient moved 1.7314, which is about 24,974 times as far.
Charging one unit for the size of the coefficients pulls the two numbers together, from a gap of 3.5000 down to a gap of 0.0347, at a cost of 0.000069 in R squared: the coefficient shifts roughly 24,974 times the distance R squared does.
Try it out

Adding a penalty of one pulls the coefficient pair from a gap of 3.5000 down to a gap of 0.0347, and R squared reads 0.756019 before and 0.755950 after. Did the fit change?

Risk Management Program Bootcamp — Fin Maverick Reading an Option Payoff — free micro-course from Fin Maverick

What is the leak that makes a cross validated figure lie?

Everything above assumes one thing that nobody states, and stating it is the difference between a tested figure and a number wearing a costume. The assumption is that each fold's model learned from the months outside that fold and nothing else. Break that assumption and every figure above becomes decoration.

Here is how it breaks, and it almost never breaks on purpose. Somebody looks at all ten months, notices that the Nakshatra unit tracks the Vasant unit better than the alternatives, and picks it as the input. Then they run five fold cross validation on the model built from that input and report 34.2305 as a tested figure. But the choice of input was made with all ten months in view, including the two months sitting inside every fold. Each fold was scored by a model whose most important decision had already been made using the very months it was about to be tested on.

The same thing happens with a penalty. Choose the penalty size once, by looking at how the whole record responds, then run cross validation at that setting, and the folds are testing a model that was shaped by them. The size of a penalty is a decision about the model exactly as much as the choice of input is.

What makes the leak dangerous rather than merely wrong is that nothing looks different. The arithmetic completes. A number comes out. The number has the same shape, the same decimals and the same air of having been checked as an honest one, and it is optimistic by an amount that cannot be worked out from the output. The only defence is to do the choosing inside each fold instead of once before the folds begin. Each fold's model then rests on that fold's own outside months and nothing else.

WHERE THE DECISION WAS MADE IS THE WHOLE DIFFERENCE CHOSEN ONCE, BEFORE THE FOLDS CHOSEN AGAIN INSIDE EACH FOLD nothing at all is decided above the folds on this side one choice, made on all ten months fold 1, already shaped by the choice fold 2, already shaped by the choice fold 3, already shaped by the choice fold 4, already shaped by the choice fold 5, already shaped by the choice its own choice its own choice its own choice its own choice its own choice fold 1, sees nothing else fold 2, sees nothing else fold 3, sees nothing else fold 4, sees nothing else fold 5, sees nothing else Both sides finish, and both print a number carrying the same decimals. Only the left one is optimistic, by an amount nobody can work out from the output.
A penalty or an input chosen by looking at the whole record has already seen every fold, so the tested figure that comes out is optimistic by an amount nobody can estimate from the output alone.

The number that looks tested and is not

Somebody sifts the available columns, picks the one that tracks the outcome best over all ten months, builds a model on it, cross validates that model and reports the result as an honest out-of-sample figure. Every step is standard. Every step is done carefully. And every fold was scored by a model whose most important decision had already been made using the months inside that fold, so the figure is optimistic by an amount that cannot be recovered from anything in the output.

The same failure arrives wearing a second costume when a penalty size is settled once, on the whole record, and cross validation is then run at that setting. The penalty is a decision about the model, so choosing it on all ten months and testing on subsets of the same ten months is the identical mistake with different arithmetic in front of it.

Here is the habit that catches it. Write down every decision made about the model, one line each, then ask of each line whether it was made before the folds existed. The shape of the model, the columns that go in, the size of any penalty, the transformation applied to an input, the months quietly dropped as odd. Any line that used the whole record has to move inside the fold, or the figure is not a tested figure and should not be described as one.

RUN EVERY MODEL DECISION THROUGH THIS ONE QUESTION Was this decision made once, before the folds existed? yes no, inside each fold It used every month, folds included. The number still comes out and still looks tested. It is optimistic, and by how much cannot be read off the output. Each fold decided for itself. No fold saw anything outside its own months, so the miss it records is a real miss and the average means something. Decisions worth running through it: the shape of the model, and which columns go in. Also the size of any penalty, any transformation applied, and any month dropped as odd.
Any decision about the model that used the whole record has to move inside the fold, because a decision made before the folds existed leaves a figure that reads as tested without being tested.
Try it out

Someone chooses the best input by looking at all ten months, then cross validates the model built from it. What is wrong?

A penalty picked across all folds has seen them. See where the leak sits.

What does an honest tested figure actually say?

An analyst reading somebody else's model, a lender deciding how much to lean on a scoring rule, and a researcher checking a colleague's work all do the same four things with a tested figure, and none of them takes long.

First, it names the scheme. Leaving one out, or a stated number of folds, cut in a stated way. Without that the figure cannot be rebuilt and cannot be compared with anybody else's. Second, it gives the spread across the folds and not only the average. The figures 66.7652 and 15.7551 average to a number that describes neither of them. Third, it says what was chosen before the folds began and what was chosen inside them, decision by decision. Fourth, it puts the in-sample figure beside the tested one.

The fourth habit is the least common and among the most useful. The gap between 21.8000 and 31.0975 is not clutter. The gap is information about how short the record is and how much of the fit was the particular wobble of these particular months. A tiny gap on a long record and a huge gap on a short one are two very different situations, and quoting the tested figure alone hides which of them applies.

WHAT A TESTED FIGURE LOOKS LIKE WHEN IT IS WRITTEN OUT PROPERLY TESTED ERROR, THE TEN PAIRED MONTHS Scheme: five folds of two, cut in time order Average across the folds: 34.2305 The five folds: 66.7652, 49.5921, 16.5556, 15.7551 and 22.4846 Best to worst: 15.7551 to 66.7652 Chosen before the folds: the shape of the model Chosen inside each fold: nothing else was chosen Beside it, the in-sample figure: 21.8000 every figure above invented for this lesson 1 The scheme is named, so anybody can rebuild the figure exactly. 2 The spread is quoted, because the average describes no fold well. 3 Every decision is placed either before the folds or inside them. 4 The gap to 21.8000 says how short the record is, which is worth knowing. The same result reduced to one line: tested error 34.2305. Nothing above is false. Everything that would let a reader judge it has gone. The short version is not a summary of the long one. It is a different claim, and a weaker one.
An honest tested figure names the scheme, gives the spread across the folds, places every decision either before the folds or inside them, and prints the in-sample figure beside the tested one.
Try it out

Which two figures should always be quoted together?

What is left for later reading?

The three parts of a split, and what each part is for, are covered under splitting a record and taken as known here. The judgement about a model being too simple or too flexible for the record in front of it is covered separately too, and is a different question from how a figure gets tested. How large a penalty ought to be depends entirely on the job the model is being built to do; the penalty is fixed at one throughout so that the movement stays visible.

Whether a tested model would be worth running against anything bought or sold is a separate question. Questions about buying and selling carry conditions of their own and are handled elsewhere.

What was consulted to produce these readings?

Nothing outside a script. Every reading here comes out of refitting ten invented paired months, so the row below records the working file that produced the arithmetic rather than an institution that published a table.

SourceDocumentSite
No external source is usedA checking script kept beside these notes, which recomputes each reading from the ten months and halts if one has driftedNone, because no maintained record is opened
The names cross validation, leaving one out, folds, ridge and lassoOrdinary teaching vocabulary that appears in any statistics textNone needed

The Nakshatra unit, the Vasant unit and the Chandana unit are invented.
Educational material. Not advice on any investment, tax, budget or market position.

← PreviousNext →
Fin Maverick Micro CoursesExplore Micro Courses
Fin Maverick BootcampsExplore Bootcamps
Fin Maverick

Finance education that ends in a job, not a certificate that gathers dust. Built for young India.

LEARN
CalculatorsFrameworksComparisonsCareersShowdown
RESOURCES
All CoursesMicro CoursesBootcampsInternships
COMPANY
AboutJob openingPartnership
LEGAL
Privacy PolicyTerms & ConditionsContent LicenseReturn & Refund Policy
© 2026 FIN MAVERICK / BUILT FOR INDIA.DO FINANCE, DO NOT JUST READ ABOUT IT.