Vol. 17 · ML & Decision Systems

Forecasting, Causal Inference & Bandits

The next layer after classic ML. Not just “predict the label”, but understand three different questions: what will happen next, what will happen if we intervene, and what is better to show right now with incomplete information. These are three different formulations of the problem, with different metrics, leakage risks and different language of communication with researchers and product teams.

Retrieval answer

The next layer after classic ML. Not just “predict the label”, but understand three different questions: what will happen next, what will happen if we intervene, and what is better to show right now with incomplete information. These are three different formulations of the problem, with different metrics, leakage risks and different language of communication with researchers and product teams.

01

Correct Statement of the Problem

4 cards
01FramingThree different questions that are often confused1 visual

A lot of the confusion in applied ML starts not with the model, but with the wrong question. `Forecasting` asks: what is most likely to happen next? `Causal inference` asks: what will change if we intervene? `Bandit/policy` asks: what is better to choose right now, while we are still learning?

02FramingWhy does regular iid logic break down?1 source note

Classic supervised ML often assumes that the examples are independent and the distribution does not drift too quickly. In a time series, neighboring points depend on each other in time. In causal, we are not just interested in the observed correlation, but in the effect of the intervention. In bandits, the data collection policy itself affects future data.

Source-complete noteswhat exactly breaks
what exactly breakssql
time series:
  x_t depends on x_(t-1), x_(t-2), ...

causal: causal
  observed outcome != effect of action

bandits:
  you select action
  and with this you change what you see next
03FramingPrediction, intervention, policy - three different types of output1 source note

Sometimes the model needs to predict a future value. Sometimes estimate the effect size of an action. Sometimes choose the action with the best expected reward. If you mix these three outputs, you can get a technically neat, but productually useless system.

Source-complete notestable
ModeWhat do we give out?What we optimize
Forecasty_hat(t+h)forecast error
Causaltreatment effecteffect estimate bias
Banditaction / policyregret / cumulative reward
04FramingMini-dictionary: horizon, counterfactual, reward, regret1 source note

To speak the same language with researchers and analysts, it is enough to remember a few central terms. They constantly pop up in articles, discussions of experiments, and product reviews.

Source-complete notesterms
termstext
horizon:
  how many steps forward do we predict?

counterfactual:
  what would happen if the action was different

reward:
  Useful framing of the chosen action

regret:
  how much was lost relative to the best action

policy:
  rule for choosing an action by context
02

Forecasting: Time Series Basics

5 cards
05ForecastingAnatomy of a time series: trend, seasonality, noise, shocks1 visual

A time series is rarely just a list of numbers. It is typically a mixture of slow baseline changes, repeating seasonal cycles, random noise, and occasional external shocks. A conversation about forecasting often begins with the decomposition of these components.

Visual model · Annotated exampleInspect the concrete example behind Anatomy of a time series: trend, seasonality, noise, shocks, one layer at a time.
Complete view · 3 layers
06ForecastingLags and autocorrelation: the past really helps1 source note

If today's value is similar to yesterday's or to the value a week ago, then there is auto-dependence in the series. This is why lags and rolling statistics are so important: they give the model direct access to the past state of the system.

Source-complete notestypical features
typical featurestext
lag_1   = y_(t-1)
lag_7   = y_(t-7)
lag_24  = y_(t-24)

roll_mean_7  = mean(y_(t-6) ... y_t)
roll_std_30  = std(last_30_points)

calendar:
  day_of_week, month, holiday_flag
07ForecastingOne-step vs multi-step forecasting1 visual

Forecasting one step ahead and forecasting 30 steps ahead are not the same task. The further the horizon, the higher the uncertainty and the more errors accumulate. In multi-step systems, you need to decide in advance whether you will build one general multi-horizon forecast or repeat a single-step forecast along the chain.

Visual model · Annotated exampleInspect the concrete example behind One-step vs multi-step forecasting, one layer at a time.
Complete view · 5 layers
08EvaluationTemporary split and rolling backtest: you can’t interfere with the future in the train1 visual1 source note

The usual random split for time series is almost always wrong. The future should not be included in the training of the model that supposedly predicts this future. Therefore, they use time-based split, rolling origin evaluation and `TimeSeriesSplit`-like schemes, where train is always strictly before validation.

Visual model · Formula mapConnect the quantities and operations that determine Temporary split and rolling backtest: you can’t interfere with the future in the train.
Source-complete notesantipatterns

antipatterns

  • shuffle split for row
  • feature from the future window
  • walk-forward validation
09WorkflowLeakage in time series is almost always subtler than it seems1 source note

The most common failure of a forecasting project is not the “wrong model”, but an unnoticeable leak of the future. Any rolling mean, target encoding, cumulative metric or exogenous signal should be considered as if you are actually living at time `t` and do not yet know the future.

Source-complete notestypical leaks
typical leakssql
bad:
  average demand of the month, if the month has not yet ended
  normalizer, fit on the entire row
  signs from post-event tables

good:
  only information available at t
  feature engineering inside each fold
03

Forecasting: Tools & Metrics

4 cards
10ForecastingNaive baseline is almost mandatory1 source note

In forecasting it is very easy to build a complex model that is worse than the simplest baseline. Therefore, they almost always consider at least `last value`, `seasonal naive` or `drift`. If you don't beat these primitives, the project has not yet reached the real ML win.

Source-complete notessimple basic forecasts
simple basic forecaststext
naive:
  y_hat_(t+1) = y_t

seasonal naive:
  y_hat_(t+h) = y_(t+h-m)

drift:
  continue the last linear trend

basic question: are we really better than this?
11ForecastingTwo large families of forecasting models1 source note

In practice, forecasting often follows two paths. First: specialized time-series models like ETS / ARIMA, which explicitly describe the dynamics of the series. Second: feature-based ML, where you build lags, rolling features and exogenous features, and then train gradient boosting or another supervised model.

Source-complete notestable
FamilyStrengthWhen it's convenient
ETS / ARIMAthe structure of the series is clearly laid downsingle rows, transparent statistics
Feature-based MLeasy to add external featuresmany entities, complex business context
Neural forecastingshared patterns across many seriesscale, large panels, complex dependencies
12ForecastingML approach to forecasting: a series turns into a supervised table1 source note

Very often forecasting is solved not by a separate “magic” model, but by ordinary supervised ML. You create lags, calendar features, prices, stocks, balances, weather data and turn each time point into a table row. Then you can learn boosting, a linear model or a neural network.

Source-complete notestable forecasting scheme
table forecasting schemetext
row at time t:
  lag_1
  lag_7
  roll_mean_14
  day_of_week
  holiday
  price
  promo_flag
  stock
  ...
target:
  y_(t+h)
13EvaluationMAE, RMSE, MAPE: metric changes conclusions1 source note

Different forecasting metrics penalize the model in different ways. RMSE hits harder for large errors, MAE is more robust, MAPE breaks down around zero, and sMAPE partially corrects this defect. Therefore, one cannot say “the model is better” without specifying by what metric and on what horizon.

Source-complete notesshort intuition

short intuition

  • MAE: mean absolute error
  • RMSE: Big misses hurt more
  • MAPE behaves poorly at small values
  • see horizon metrics separately
04

Causal Inference: What Happens If We Intervene

7 cards
14CausalPrediction ≠ Causation1 visual

The usual predictive model answers the question “who buys more often?” well, but it still does not answer the question “what will happen if we send a promotional code?”. A model can find strong correlations and yet not know the true effect of an action at all. Causal inference is needed exactly where we are interested in the result of the intervention.

Visual model · Annotated exampleInspect the concrete example behind Prediction ≠ Causation, one layer at a time.
Complete view · 4 layers
15CausalPotential Outcomes: Every object has two worlds1 source note

The basic causal intuition is simple: the same person or object has at least two potential outcomes - with treatment and without treatment. The problem is that in reality we only see one of them. The second world remains a counterfactual, and that is why causal inference is more difficult than ordinary prediction.

Source-complete notesdesignations
designationstext
Y(1):
  outcome if treatment was

Y(0):
  outcome if there was no treatment

individual effect:
  τ = Y(1) - Y(0)

ATE:
  E[Y(1) - Y(0)]
16CausalConfounding: a hidden reason ruins a naive comparison1 visual

If treatment is not obtained by chance, but because the object already differs in important ways, a simple comparison of the treated and untreated groups will be biased. This is confounding. Usually, causal work is largely a fight against it.

Visual model · Annotated exampleInspect the concrete example behind Confounding: a hidden reason ruins a naive comparison, one layer at a time.
Complete view · 5 layers
17CausalA/B test: the gold standard of causal evaluation1 source note

Randomization makes the treatment independent of hidden factors on the sample average. This is why A/B tests are so valuable: they eliminate much of the confounding without complex math. If a good experiment can be done, this is usually the best way to estimate a causal effect.

Source-complete notesmeaning of randomization
meaning of randomizationtext
random assign:
  T ~ Bernoulli(p)

→ treatment does not depend on user traits
→ groups are comparable on average
→ difference in outcomes is closer to causal effect
18CausalWhen A/B is impossible: basic observational approaches1 source note

If an experiment is not possible or too expensive, causal inference attempts to approach it through research design. There is no one universal method: matching, regression adjustment, inverse propensity weighting, difference-in-differences, regression discontinuity and instrumental variables solve different types of bias.

Source-complete notestable
ApproachIntuitionWhen appropriate
Matching / propensitycompare similar treated and untreatedobservational data rich in covariates
DiDcompare before/after changes between groupspolicy rollout, natural experiments
RDDcompare around destination thresholdstrict business thresholds
IVuse an external source of variationstrong confounding, but there is a valid instrument
19PolicyATE, CATE, uplift: effect may vary for different people1 source note

The average effect is useful, but heterogeneity is often more important in products. One segment benefits from treatment, another is neutral, and the third even gets worse. Hence the language of `CATE`, `uplift modeling`, `treatment heterogeneity` and personalized interventions.

Source-complete noteseffect levels
effect levelssql
ATE:
  average effect over the entire population

CATE:
  effect for subgroup/context

uplift:
  increase in outcome precisely because of treatment

In personalization, one is almost always interested not just in P(Y), but in ΔY from action
20CausalFrequent causal failures1 source note

Even neat teams regularly make mistakes in causal statements. Most often, this is either an incorrect assumption about parallel trends / ignorability, or post-treatment leakage, or an overly optimistic transfer of the effect from one environment to another.

Source-complete notesantipatterns

antipatterns

  • control a variable that treatment has already changed
  • ignore group selection
  • transfer the effect without re-validation
  • first write out identification assumptions
05

Bandits: Learning While Making Decisions

6 cards
21BanditMulti-Armed Bandit: exploration vs exploitation2 visuals

The Bandit problem occurs when you need to choose an action right now, but you are not yet sure which action is best. If you always choose the current leader, you may miss the best option. If you experiment too much, you lose the reward today. It is this compromise that is called exploration vs exploitation.

Decision labLearn while choosing.

Pull an arm and watch evidence compete with uncertainty.

Total decisions
0
Observed reward
0.00
Next evidence target
Any arm

Start by sampling each arm. Uncertainty is information, not empty space.

The rewards are deterministic for repeatability. The uncertainty bonus keeps under-sampled options visible while evidence accumulates.
Visual model · Annotated exampleInspect the concrete example behind Multi-Armed Bandit: exploration vs exploitation, one layer at a time.
Complete view · 5 layers
22BanditRegret: the main currency of bandit systems1 source note

In bandits, it is important not only how much reward you collected, but also how much you lost relative to the ideal oracle, which always knows the best action. This difference is regret. A good bandit policy makes regret grow slowly as experience accumulates.

Source-complete notesintuition regret
intuition regrettext
oracle reward:
  always chooses the best arm

policy reward:
  sometimes makes mistakes while learning

regret =
  oracle cumulative reward
  - policy cumulative reward
23BanditEpsilon-Greedy: The Easiest Way to Explore1 source note

Epsilon-greedy works crudely, but is very clear. With probability `1 - ε` you choose the best known arm, and with probability `ε` you randomly try something else. This is a simple baseline that is often used as a starting point before smarter strategies.

Source-complete notesalgorithm
algorithmpython
if rand() < ε:
  action = random arm
else:
  action = argmax estimated_reward

update estimate after observing reward
24BanditUCB: underexplored options get uncertainty bonus1 source note

Upper Confidence Bound chooses not just the arm with the best average reward, but the arm with the best “optimistic score”. If an option has been little explored, an exploration bonus is added to it. Therefore, UCB automatically balances learning and use without random rolls like epsilon-greedy.

Source-complete notesUCB intuition
UCB intuitionpython
score(arm) =
  empirical_mean(arm)
  + uncertainty_bonus(arm)

if arm is poorly studied:
  bonus big

if arm is studied well:
  bonus small
25BanditThompson Sampling: Explore through Probabilistic Faith1 source note

Thompson Sampling stores the uncertainty distribution over the quality of each arm and samples from this belief at each step. An Arm with a potentially high reward and high uncertainty has a natural chance of being selected. This is one of the most practical bandit approaches.

Source-complete notessimplified diagram
simplified diagramsql
for each arm:
  sample θ_arm from posterior

action =
  argmax sampled_θ_arm

observe reward
update posterior
26PolicyContextual Bandits: the best action depends on the context1 visual1 source note

In many products there is no one best arm for everyone. It is better to show different options to different users. Then bandit receives the user's context as input and learns a policy of the form `π(action | context)`. This is closer to personalization, advertising, recommendations and adaptive ranking.

Visual model · Process flowFollow the sequence behind Contextual Bandits: the best action depends on the context and locate where work or state changes.
Complete view · 4 layers
Source-complete notestypical domains

typical domains

  • ads
  • recommendations
  • homepage modules
  • we need neat action-probabilities logging logic
06

A/B, Bandits AND Online Evaluation

3 cards
27EvaluationA/B testing vs bandits: not competitors, but different tools1 source note

An A/B test is good when you need to reliably measure the effect of fixed options. Bandits are good when you need to adaptively collect rewards along the way, without showing weak options for too long. They are often combined in products: first A/B for pure measurement, then bandit for adaptive serving.

Source-complete notestable
ApproachMain goalStrength
A/Bmeasure the causal effectpure interpretation
Banditmaximize reward while learningless losses on weak options
Hybridmeasure + adaptrealistic food compromise
28EvaluationOffline evaluation is not equal to online success1 source note

Forecasting can be fairly fairly validated by backtest. Causal - through experimental design and assumptions. Bandits and policy systems often run into the fact that offline logs are collected by the old policy, and the new policy will collect different data. Therefore, online validation is especially important here.

Source-complete notesmain idea

main idea

  • offline is useful for weeding out weak ideas
  • online determines the real product value
  • do not confuse replay on old logs with true future behavior
29WorkflowDelayed feedback and non-stationarity1 source note

In many real-world systems, the reward does not come immediately, but after hours or days. Plus, the environment is changing: season, competitors, interface, economic situation, new user segments. This complicates forecasting, bandits, and post-launch causal assessment.

Source-complete noteswhat breaks the system
what breaks the systemtext
delayed feedback:
  action now
  reward tomorrow

non-stationarity:
  P(data) changes over time

policy feedback loop:
  the system itself changes user behavior
07

How to Choose the Right Frame

3 cards
30BridgeDecision Tree: forecasting, causal inference or bandit?1 visual

When a product problem is formulated vaguely, it is useful to quickly run it through one decision tree. Usually this is enough to avoid launching an erroneous project under the guise of “let’s just make an ML model.”

Visual model · Process flowFollow the sequence behind Decision Tree: forecasting, causal inference or bandit? and locate where work or state changes.
Complete view · 5 layers
31BridgeWhere is the place for reinforcement learning?1 source note

Bandits are often called “RL lite”. The difference is that bandit usually does not model long sequences of states and long-term consequences through state transitions. RL is needed where the action now affects what state you will be in next, and this is repeated along the chain.

Source-complete notescomparison
comparisontext
bandit:
  context → action → immediate reward

RL:
  state → action → next state → ... → long-term return

If there are no long state dynamics, bandit is often simpler and more practical
32BridgeThe main idea of the volume1 source note

There is no one universal “ML model for business”. There are different classes of questions. If you need a forecast, build forecasting and think about the horizon and backtesting. If you want an intervention effect, think causal and assumptions. If you need an online selection of actions, go to bandits and regret. Correct setup saves months of useless optimization.

Source-complete notesshort reminder

short reminder

  • predict future → forecasting
  • estimate impact → causal
  • choose adaptively → bandit
  • do not confuse these tasks under the word “ML”

No dead end

Keep moving through the map.

Continue in sequence, switch to a related guide, or return to the seven-track learning map.

Discovery graph / next reads

Continue through New Runtime

Open the graph
  1. 01learning trackMl And Decision SystemsOpen the complete learning track.
  2. 02related materialStatistics for Evaluating LLM SystemsContinue with another guide in this learning track.
  3. 03related materialBERT, Encoders & Non-Generative ModelsContinue with another guide in this learning track.
  4. 04related materialClassical Machine Learning in Plain EnglishContinue with another guide in this learning track.
  5. 05related materialAdvanced RAG: Context & EnrichmentContinue with a related New Runtime material.

These links are also published in this page’s JSON twin and as typed edges in DiscoveryGraph v1.

Who read this page?Machine requests, hidden until opened

Loading the privacy-safe route aggregate…

Open the JSON contract