Algorithm Search⌘K

Modelcore

Cascade click model

Also called Craswell cascade model, cascade model, CM.

The user scans results from the top and clicks the first attractive one, then stops; each result is examined only if all above were skipped.

The cascade click model is a click model in which the user reads a result list from the top, clicks the first result that looks attractive, and stops. Nick Craswell, Onno Zoeter, Michael Taylor and Bill Ramsey introduced it in 2008, in the paper that compared several explanations of position bias. It has one parameter per document, the probability αd\alpha_d that the document attracts a click when it is examined, and its examinations are fully determined by the click, so the parameters have closed-form maximum likelihood estimates. The position-based model instead lets examination depend on the rank alone, and the DBN model lets the user continue after a click.

The machine

A session shows a ranking d1,…,dnd_1, \ldots, d_n for one query. The model has hidden examination events EiE_i and attraction events AiA_i, and the observed click events CiC_i:

  • E1=1E_1 = 1: the user always examines the first result.
  • Ai∼Bernoulli(αdi)A_i \sim \mathrm{Bernoulli}(\alpha_{d_i}), independently, and Ci=1C_i = 1 exactly when Ei=1E_i = 1 and Ai=1A_i = 1.
  • Ei+1=1E_{i+1} = 1 exactly when Ei=1E_i = 1 and Ci=0C_i = 0: after a skip the user goes on, and after a click the user stops.

So the user examines the results one by one and stops at the first click. Every session has at most one click, and every result above the click was examined and skipped.

What it counts

The model gives the probability of each possible session. The click falls at rank ii with probability

P(Ci=1)=αdi∏j<i(1−αdj),P(C_i = 1) = \alpha_{d_i} \prod_{j < i} (1 - \alpha_{d_j}),

and there is no click with probability ∏j≤n(1−αdj)\prod_{j \le n} (1 - \alpha_{d_j}); these n+1n + 1 numbers sum to 1. For example, with α=0.5,0.4,0.2\alpha = 0.5, 0.4, 0.2 for the ranking a, b, c, the click is on a with probability 0.50.5, on b with 0.5⋅0.4=0.20.5 \cdot 0.4 = 0.2, on c with 0.5⋅0.6⋅0.2=0.060.5 \cdot 0.6 \cdot 0.2 = 0.06, and there is no click with probability 0.5⋅0.6⋅0.8=0.240.5 \cdot 0.6 \cdot 0.8 = 0.24. A document has a click-through rate that falls with its rank even when its α\alpha is fixed, because every result above it can take the click first.

Relation to other models

  • Examination hypothesis. Like most click models, it clicks exactly when a result is examined and attractive. In the position-based model the examination of rank ii has a fixed probability that ignores the other results; in the cascade model it is the probability that all results above were skipped.
  • Craswell et al. 2008. The paper compared four hypotheses on data from an experiment that swapped two adjacent results: a baseline with no position bias, a mixture model, the examination model and the cascade model. The cascade model predicted the clicks best, most clearly at the top ranks. This result is a measurement on their logs.
  • Extensions. The dependent click model, the click chain model and the DBN model all keep the scan from the top and add a chance to continue after a click. The DBN model with perseverance γ=1\gamma = 1 and satisfaction 11 for every document is the cascade model (Section 3.8.1 of Chuklin, Markov and de Rijke).
  • Metrics. Expected reciprocal rank is a metric built on a cascade user who stops at a satisfying result.
  • Online learning. Cascading versions of the multi-armed bandit learn a ranking from clicks under this model.

Known results in the model

The examinations are observed. In a session with a click at rank cc, the results at ranks 1,…,c1, \ldots, c were examined and the results below were not. In a session without a click all nn were examined. So the likelihood factors over documents:

L(α)=∏dαdkd(1−αd)md−kd,L(\alpha) = \prod_d \alpha_d^{k_d} (1 - \alpha_d)^{m_d - k_d},

where mdm_d is the number of sessions in which dd was examined and kdk_d the number in which it was clicked. The maximum likelihood estimate is α^d=kd/md\hat\alpha_d = k_d / m_d: the clicks on dd divided by the impressions of dd at or above the click, or anywhere in a session without a click. No iterative method such as EM is needed.

The estimate concentrates. Whether dd is examined in a session depends only on the attraction coins of the results above it, not on those of dd. So, given mdm_d, the kdk_d clicks are a sum of mdm_d independent Bernoulli(αd\alpha_d) coins, and Hoeffding's inequality gives ∣α^d−αd∣≤ln⁡(2/δ)/(2md)|\hat\alpha_d - \alpha_d| \le \sqrt{\ln(2/\delta) / (2 m_d)} with probability at least 1−δ1 - \delta. The tests simulate 50000 sessions of 5 results drawn from 10 documents with a fixed seed, and check every estimate against this bound with δ=10−6\delta = 10^{-6}. This shows that the estimator recovers the parameters when the data come from the model; how well the model fits real users is a separate question, answered only by measurements on logs.

One click per session. The model gives probability 0 to a session with two clicks. Real logs have many such sessions, so in practice the model is fitted on the part of each session up to its first click, or a model that allows more clicks is used. Section 3.4 of Chuklin, Markov and de Rijke notes that the cascade model can only describe sessions with one click and cannot explain non-linear examination patterns. In their experimental comparison on a public log of a commercial search engine (Chapter 7), more complex models fit better than the cascade model; this is a measurement as well.

A worked estimate. Four sessions show a, b, c. Two click a, one clicks b and one has no click. Then a was examined 4 times and clicked twice, b examined twice and clicked once, and c examined once and never clicked, so α^=(0.5,0.5,0)\hat\alpha = (0.5, 0.5, 0). The raw click-through rates, 0.50.5, 0.250.25 and 00, understate b because two of its four impressions were never examined.

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

cascade_click_model.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/cascade-click-model/. The authors are listed in prov/F0GVXM.jsonl.
"""The cascade click model (Craswell, Zoeter, Taylor and Ramsey, 2008).

The user examines the results from the top. At each examined result d the
user clicks with probability alpha[d]. After a click the user stops; after
a skip the user examines the next result. A session is recorded as the
rank of its click (0-based) or None when there is no click.
"""

import math


def click_distribution(ranking, alpha):
    """Return ([P(click at rank i) for each i], P(no click))."""
    probs = []
    miss = 1.0
    for d in ranking:
        probs.append(miss * alpha[d])
        miss *= 1.0 - alpha[d]
    return probs, miss


def simulate(rankings, alpha, rng):
    """Draw one session for each ranking, with the random source rng."""
    out = []
    for ranking in rankings:
        click = None
        for i, d in enumerate(ranking):
            if rng.random() < alpha[d]:
                click = i
                break
        out.append(click)
    return out


def examination_counts(rankings, clicks):
    """Return (examined, clicked): per document, the sessions in which it was
    examined (at or above the click, or anywhere in a session without a
    click) and the sessions in which it was clicked."""
    examined, clicked = {}, {}
    for ranking, c in zip(rankings, clicks):
        depth = len(ranking) if c is None else c + 1
        for d in ranking[:depth]:
            examined[d] = examined.get(d, 0) + 1
        if c is not None:
            clicked[ranking[c]] = clicked.get(ranking[c], 0) + 1
    return examined, clicked


def fit(rankings, clicks):
    """Maximum likelihood estimate: alpha[d] = clicks on d / examinations of d."""
    examined, clicked = examination_counts(rankings, clicks)
    return {d: clicked.get(d, 0) / n for d, n in examined.items()}


def log_likelihood(rankings, clicks, alpha):
    """Natural log of the probability of the observed sessions."""
    total = 0.0
    for ranking, c in zip(rankings, clicks):
        probs, miss = click_distribution(ranking, alpha)
        p = miss if c is None else probs[c]
        if p <= 0.0:
            return -math.inf
        total += math.log(p)
    return total
test_cascade_click_model.py 83 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/cascade-click-model/. The authors are listed in prov/F0GVXM.jsonl.

import math
import random

from cascade_click_model import click_distribution, examination_counts, fit, log_likelihood, simulate

TOL = 1e-12
DOCS = list(range(10))
TRUE_ALPHA = {d: 0.05 + 0.05 * d for d in DOCS}  # 0.05, 0.10, ..., 0.50


def hoeffding(n, delta):
    """Half width of a two-sided Hoeffding interval for a mean of n coins."""
    return math.sqrt(math.log(2.0 / delta) / (2.0 * n))


def random_rankings(rng, sessions, depth):
    return [rng.sample(DOCS, depth) for _ in range(sessions)]


def test_distribution_sums_to_one():
    rng = random.Random(1)
    for _ in range(100):
        alpha = {d: rng.random() for d in DOCS}
        ranking = rng.sample(DOCS, rng.randint(1, 10))
        probs, miss = click_distribution(ranking, alpha)
        assert math.isclose(sum(probs) + miss, 1.0, rel_tol=0, abs_tol=TOL)
        assert all(p >= 0.0 for p in probs)


def test_example_of_the_page():
    alpha = {"a": 0.5, "b": 0.4, "c": 0.2}
    probs, miss = click_distribution(["a", "b", "c"], alpha)
    for got, want in zip(probs + [miss], [0.5, 0.2, 0.06, 0.24]):
        assert math.isclose(got, want, rel_tol=1e-12)
    rankings = [["a", "b", "c"]] * 4
    clicks = [0, 1, None, 0]
    examined, clicked = examination_counts(rankings, clicks)
    assert examined == {"a": 4, "b": 2, "c": 1} and clicked == {"a": 2, "b": 1}
    assert fit(rankings, clicks) == {"a": 0.5, "b": 0.5, "c": 0.0}


def test_monte_carlo_frequencies_match_the_formula():
    rng = random.Random(2)
    ranking = [9, 3, 6, 0, 5]
    n = 40000
    clicks = simulate([ranking] * n, TRUE_ALPHA, rng)
    probs, miss = click_distribution(ranking, TRUE_ALPHA)
    tol = hoeffding(n, 1e-6)
    for i, p in enumerate(probs):
        assert abs(clicks.count(i) / n - p) <= tol
    assert abs(clicks.count(None) / n - miss) <= tol


def test_estimates_are_close_to_the_true_parameters():
    # The examinations of d depend only on the coins of the documents above d,
    # so given their number, the clicks of d are independent Bernoulli(alpha[d])
    # coins and Hoeffding's bound applies. With delta = 1e-6 per document the
    # test fails with probability at most 1e-5 for a fresh seed.
    rng = random.Random(3)
    rankings = random_rankings(rng, 50000, 5)
    clicks = simulate(rankings, TRUE_ALPHA, rng)
    assert all(c is None or 0 <= c < 5 for c in clicks)
    examined, _ = examination_counts(rankings, clicks)
    est = fit(rankings, clicks)
    for d in DOCS:
        assert examined[d] >= 5000
        assert abs(est[d] - TRUE_ALPHA[d]) <= hoeffding(examined[d], 1e-6)


def test_estimate_maximizes_the_likelihood():
    rng = random.Random(4)
    rankings = random_rankings(rng, 3000, 4)
    clicks = simulate(rankings, TRUE_ALPHA, rng)
    est = fit(rankings, clicks)
    best = log_likelihood(rankings, clicks, est)
    for d in DOCS:
        for step in (-0.02, -0.001, 0.001, 0.02):
            moved = dict(est)
            moved[d] = min(1.0, max(0.0, est[d] + step))
            assert log_likelihood(rankings, clicks, moved) <= best + 1e-9

References

  1. Nick Craswell, Onno Zoeter, Michael Taylor and Bill Ramsey, An experimental comparison of click position-bias models, Proceedings of the 2008 International Conference on Web Search and Data Mining (WSDM 2008), 87-94, the four position-bias hypotheses (baseline, mixture, examination and cascade), the experiment that swaps adjacent results, and the finding that the cascade model fits best at the top ranks
  2. Aleksandr Chuklin, Ilya Markov and Maarten de Rijke, Click Models for Web Search, Morgan and Claypool 2015, reissued by Springer, Section 3.4 (the cascade model, Equations 3.9 to 3.14, and the remark that it can only describe sessions with one click), Section 3.8.1 (the cascade model as a special case of the simplified DBN), Chapter 4 (maximum likelihood estimation when the examinations are observed) and Chapter 7 (an experimental comparison of click models)
  3. Olivier Chapelle and Ya Zhang, A dynamic Bayesian network click model for web search ranking, Proceedings of the 18th International Conference on World Wide Web (WWW 2009), 1-10, the DBN model, which extends the cascade model with satisfaction and perseverance and reduces to it when both are 1

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/F0GVXM/text.yaml