LambdaMART combines boosted regression trees with ranking-sensitive pairwise updates. See how an NDCG swap weight guides training and why ranking scores are not returns.
LambdaMART
LambdaMART is a learning-to-rank algorithm that combines LambdaRank's ranking-sensitive updates with boosted regression trees, also called MART (Multiple Additive Regression Trees). It learns scores for ordering items within a group. In a financial application, the group might be a rebalance date and the items its eligible securities: ordering candidates well is a different task from estimating each candidate's return. Burges's overview develops the algorithm's components.
Why a swap matters
Suppose one synthetic query contains items A, B and C with relevance grades 3, 1 and 0. These are stipulated teaching labels, not observed returns. Use gain g(y)=2y−1 and rank discount d(r)=1/log2(r+1). Normalised discounted cumulative gain at three positions is
NDCG@3=IDCG@3∑r=13g(y(r))d(r),
where the denominator is the DCG of the ideal ordering of the same query. Here the ideal order is A, B, C:
IDCG@3=7+log231=7.63093.
Swap A and B, leaving C last. DCG becomes 1+7/log23=5.41651, so NDCG falls to 0.70981. The absolute swap effect is 0.29019. This number says how important this particular pair's placement is under the chosen metric. Changing the gain mapping or evaluation cutoff changes that importance.
Synthetic single-query rankings: ideal A, B, C has DCG 7.63093 and NDCG 1; swapped B, A, C has DCG 5.41651 and NDCG 0.70981. Their swap weight is 0.29019. Pairwise pushes are summed by item before fitting the next tree.
Original synthetic example using grades 3, 1 and 0, exponential gains and logarithmic discounts. The flow separates within-query comparisons from the tree fitted across training queries.
From pairwise pushes to trees
A learning-to-rank model assigns each item a score si. For a pair in the same query where item i has the higher relevance grade, one conventional positive upward-push magnitude is
pij=1+exp(σ(si−sj))σ∣ΔNDCGij∣,σ>0.
It pushes i upward and j downward by equal magnitudes. The logistic factor emphasises poorly separated or reversed scores; the swap factor emphasises placements that matter to the metric. Signs called “lambda” differ across descriptions depending on whether they denote a loss gradient or its negative; the push convention above fixes the direction explicitly. Wu et al., §3 explains this combination.
Training repeatedly sorts each query, calculates pair contributions, sums them for each item, then fits a regression tree to the resulting pseudo-responses across the training queries. Leaf updates use curvature information, and a learning rate shrinks the next tree's contribution. This is the gradient-boosting machinery with ranking-specific training signals.
NDCG itself stays constant while scores move without changing their order, and jumps at rank crossings. The lambdas therefore are not the ordinary smooth derivative of NDCG. They use a smooth pairwise signal weighted by a swap effect evaluated at the current ranking; a tree update need not improve every query.
The grouping and financial decisions remain yours
In LightGBM's ranking interface, group supplies consecutive query sizes, not a query identifier for every row. Rows must be arranged accordingly. Its lambdarank settings also specify label gains, query normalisation and training truncation. Record these conventions alongside the evaluation cutoff; different configurations need not implement identical updates.
For security selection, relevance grades could be constructed from future outcome buckets within each date, using a rule set before testing. Features must still be available at that date, and training labels must have finished before a live refit. Keep evaluation dates separate from training dates and address overlapping outcome horizons: correct query groups alone do not prevent look-ahead bias.
A high ranking metric does not establish profitable trading. NDCG values the chosen relevance grades and positions; it does not include turnover, transaction costs, exposure constraints or portfolio sizing. A ranking score is neither a calibrated probability nor an expected return, and its level need not be comparable across dates.