skip to content

Recommenders and Ranking

How a sparse user-item matrix becomes a ranked list: neighborhood similarity, matrix factorization fit by ALS, and pairwise ranking objectives. Cold start and offline metrics are the usual probes.

on this pageshow

explore

questions

page 1 of 2

What do support, confidence and lift measure for a basket association rule?

level: juniorimportance: must knowfreq 78%

answer

  1. three counts off one basket log
  2. how often, how reliable, how surprising
  3. confidence conditions on the left side
  4. lift divides confidence by consequent support
  5. support symmetric, confidence directional

basics

~20 s

Support is the share of all baskets containing the rule's items. Confidence is the share of baskets holding the left-hand side that also hold the right-hand side. Lift divides confidence by the right-hand side's own support.

solid answer

~50 s

A rule `{A} -> {B}` is scored on three counts taken from the same transaction log. **Support** is how often the whole itemset shows up: baskets containing A and B over all baskets, so it says whether the rule is common enough to matter. **Confidence** is baskets with A and B over baskets with A, so it says how reliable the rule is once A appears. **Lift** is confidence divided by the support of B on its own: how much more often B turns up alongside A than it turns up anywhere. With 10,000 baskets, 1,200 holding coffee, 400 holding filters and 300 holding both: support is 0.03, confidence is 300/1200 = 0.25, and lift is 0.25/0.04 = 6.25. Support and confidence say the rule is frequent and reliable; only lift says the pairing beats the item's own popularity.

go deeper

for a junior

Be ready to write the three formulas straight from basket counts and evaluate them on a small table. Interviewers commonly hand you four numbers and watch which denominator you reach for.

for a middle

Explain why confidence alone ranks rules badly and how dividing by the consequent's support repairs it. Be able to say which of the three metrics change when the rule is reversed, and why.

for a senior

Show that you pick the metric to fit the decision: support for whether a rule is worth building anything around, confidence for a triggered suggestion, lift for whether the pairing beats the item's own popularity.

for a principal

Own the definition of a transaction - one checkout, one session, one customer-month - because that choice moves every support and confidence figure before an algorithm runs, and nobody downstream will question the numbers once they are in a deck.

## The object being scored Association rule mining runs over a transaction log: each row is a **basket**, an unordered set of items bought in one trip. A rule is written `{A} -> {B}` and read as *baskets containing A tend to also contain B*. The left-hand side is the **antecedent**, the right-hand side the **consequent**; either side may hold several items. Nothing about a rule is causal and nothing is ordered in time - it is a statement about items landing in the same set. Three numbers score every rule, and all three come from counting baskets in that one log. ## Support `support(X) = baskets containing every item of X / total baskets` For the rule `{A} -> {B}`, the rule's support is `support(A and B)`: the share of baskets containing the entire itemset. Support answers *how often does this situation even arise*. A rule at 0.00001 support can be perfectly reliable and still not worth a line of code, because it fires a handful of times a year. Support is **symmetric**: `{A} -> {B}` and `{B} -> {A}` have identical support, because set membership has no direction. It is also the quantity every mining algorithm prunes on, which is why the minimum-support threshold is the single knob that decides how long a run takes. ## Confidence `confidence(A -> B) = support(A and B) / support(A)` Of the baskets that contain A, what fraction also contain B. This is the rule's reliability *given that the antecedent fired*, and it is what a trigger-based cross-sell cares about: the shopper has A in the cart, how often is B there too. Dividing by `support(A)` rather than `support(B)` is what makes confidence **directional**. A rule from a rare item to a common one scores high confidence; reverse it and the number collapses. ## Lift `lift(A -> B) = confidence(A -> B) / support(B)` B appears in `support(B)` of all baskets. Among the A baskets it appears in `confidence` of them. Lift is the ratio of those two rates: how much more often B turns up when A is present than it turns up in the population at large. - **lift = 1** - the A baskets look exactly like every other basket with respect to B; the rule adds nothing. - **lift > 1** - positive association; the items co-occur more than their individual frequencies alone would produce. - **lift < 1** - negative association; seeing A goes with *not* seeing B, which is what substitutes look like. Lift, like support, is symmetric: swapping the sides leaves it unchanged. ## A worked example 10,000 baskets. Coffee in 1,200. Filters in 400. Both in 300. ``` support = 300 / 10000 = 0.03 confidence = 300 / 1200 = 0.25 support(filters)= 400 / 10000 = 0.04 lift = 0.25 / 0.04 = 6.25 ``` Read it out loud: the rule fires on 3% of trips; when coffee is in the basket, filters are there a quarter of the time; and a quarter is more than six times the 4% rate at which filters appear generally. Now reverse it: `confidence({filters} -> {coffee}) = 300/400 = 0.75`, three times the other direction, while support and lift do not move at all. That asymmetry is the most useful single fact about confidence. ## Why you need all three Each metric answers a different question and each is useless alone. - Support alone finds the obvious: the most frequent itemsets in a supermarket are the things everyone buys, and a rule between two staples is common without being informative. - Confidence alone is inflated by a popular consequent. If an item is in most baskets, almost any antecedent reaches high confidence for it. - Lift alone rewards rarity: two obscure items that happened to land in the same three baskets can score a spectacular ratio off almost no data. So mining is usually run as *filter by minimum support, then rank by lift, then sanity-check the absolute basket count behind each rule*. ## What counts as a transaction Before any of these numbers mean anything, someone decided what a row is: one checkout, one online session, one customer-month. Widen the window and almost every pair of items co-occurs somewhere, so support and confidence inflate while the rule stops describing a single shopping decision. The definition of a transaction moves every metric on this page and it is a modelling choice, not a data-engineering detail. ## Common mistakes Reporting support as a raw count rather than a fraction makes thresholds meaningless across datasets of different sizes. Treating confidence as symmetric produces recommendations pointed the wrong way. And treating lift near 1 as *nearly strong* inverts the scale: 1 is the neutral point, not the floor.

  • Why is support identical for {A} -> {B} and {B} -> {A} while confidence is not?
    Support counts baskets containing the combined itemset {A, B}, and set membership has no direction, so both rules share it. Confidence divides that same count by the left-hand side's own support, and A and B generally differ in frequency. A rule from a rare antecedent to a common consequent scores high confidence; reversed, the same joint count is divided by a much larger denominator and the number falls.
  • What does a lift below 1 tell you about the two items?
    They land in the same basket less often than their individual frequencies alone would produce, so the presence of one goes with the absence of the other. Real causes include substitution - two brands of the same product, or a value pack versus singles. On small joint counts it is just as likely to be noise, so check how many baskets are behind the number before calling it cannibalisation.
  • Why compute these metrics per basket rather than per customer?
    A basket is one shopping decision, which is the thing a store layout or a cart recommendation can act on. Roll a customer's whole history into one row and nearly every pair they ever bought co-occurs, so support and confidence inflate and the rule degrades to 'this person buys both sometimes'. Pick the transaction grain that matches the decision you intend to make.

Support asks how many people in the room own the item at all. Confidence asks, of the coffee buyers, how many also grabbed filters. Lift asks whether coffee buyers do that any more than everyone else does.

saying these in an interview costs you the question

  • Says a high-confidence rule is automatically a strong rule
  • Treats confidence as symmetric between the two sides
  • Reports support as a basket count instead of a fraction
  • Thinks lift of 0 rather than 1 marks no association
  • Describes a rule as if it stated cause and effect

context

open as a page

How does a content-based recommender score an item using only that user's own history?

level: juniorimportance: must knowfreq 70%

basics

~20 s

It describes each item by its own features, builds a profile vector from the features of items that user liked, and ranks candidates by similarity between profile and item vector. No other user's data is involved.

open as a page

How do implicit feedback signals like plays and skips differ from explicit star ratings?

level: juniorimportance: must knowfreq 78%

basics

~20 s

Explicit ratings are stated preferences on a scale and can express dislike. Implicit signals only record actions, so they are abundant and cheap but noisy, one-class, and count-valued: no interaction is not a stated dislike.

open as a page

An install-probability ranker's predicted numbers are wildly off but ordered correctly — does ranking suffer?

level: juniorimportance: must knowfreq 50%

basics

~20 s

No. A ranked list depends only on the order the scores induce, and any strictly increasing transform of every score leaves that order identical. The wrong numbers cost you elsewhere: thresholds, expected-value arithmetic, anything reading the score as a probability.

open as a page

How does matrix factorization predict a missing rating in a users-by-films matrix?

level: juniorimportance: must knowfreq 68%

basics

~20 s

Matrix factorization learns a short vector of latent factors for every user and every film, then predicts a rating as the dot product of the two vectors plus bias terms. Every empty cell can be filled that way.

open as a page

What is the difference between user-based and item-based collaborative filtering?

level: juniorimportance: must knowfreq 72%

basics

~20 s

User-based collaborative filtering finds people whose ratings resemble yours and recommends what they liked. Item-based finds items rated similarly to ones you already liked. Same rating matrix, but similarity is computed between rows instead of between columns.

open as a page

Why can a basket rule with 40% support and 67% confidence still be worthless?

level: middleimportance: must knowfreq 66%

basics

~20 s

Because both numbers can come entirely from the right-hand item being popular. If milk sits in 70% of baskets, any rule predicting milk reaches high confidence by default. Lift near 1 and leverage near 0 expose it.

open as a page

Why can a latent-factor recommender not rank an item with zero interactions?

level: middleimportance: must knowfreq 64%

basics

~10 s

An item's latent vector is learned only from that item's observed interactions. With none, the training objective contains no term for it, so the vector carries no information and every cold item scores alike.

open as a page

Beyond relevance, what do catalog coverage, intra-list diversity, novelty and serendipity each measure?

level: middleimportance: must knowfreq 58%

basics

~20 s

Catalog coverage is the share of the catalog that ever gets recommended. Intra-list diversity is how unlike each other the items inside one list are. Novelty is how unfamiliar an item is to the user. Serendipity is relevant plus unexpected.

open as a page

In implicit feedback data, why is an unobserved user-item cell not a negative example?

level: middleimportance: must knowfreq 66%

basics

~20 s

An unobserved cell mixes two situations that look identical: the item was never shown to the user, and the item was shown and ignored. Only the second is evidence against, so the cell is missing information, not a recorded dislike.

open as a page

In learning to rank, how do pointwise, pairwise and listwise objectives differ?

level: middleimportance: must knowfreq 70%

basics

~20 s

Pointwise fits each item independently against its own label. Pairwise trains on two items from the same list and penalises the wrong order. Listwise optimises a whole ranked list at once. Only the last two target order.

open as a page

When do you fit matrix factorization with alternating least squares rather than SGD?

level: middleimportance: must knowfreq 60%

basics

~20 s

Use alternating least squares when the per-user and per-item solves can be spread across a cluster, or when the loss covers every cell. Use SGD when ratings are sparse and observed-only, and you want a cheap, easily extended update.

open as a page

Why is raw cosine similarity on 1-5 star rating vectors replaced by Pearson or adjusted cosine?

level: middleimportance: must knowfreq 58%

basics

~20 s

Raw cosine treats every star rating as a positive quantity, so two raters who use the scale differently look similar even when they disagree. Subtracting each rater's own mean first turns ratings into signed deviations, so disagreement becomes negative similarity.

open as a page

Why is rating RMSE a poor offline metric for a recommender that shows a top-10 list?

level: middleimportance: must knowfreq 72%

basics

~20 s

RMSE averages prediction error over items the learner already interacted with, weighting them all equally. A top-10 shelf is decided only by which handful of items score highest, so RMSE can fall while the ten shown items get worse.

open as a page

How does the examination hypothesis explain position bias in a ranked results page's click log?

level: middleimportance: must knowfreq 62%

basics

~20 s

The examination hypothesis says a logged click happens only when the user both examined that slot and found the item relevant. Since examination falls steeply with rank, a top slot's higher click rate reflects position, not quality.

open as a page

How does Apriori's downward-closure property prune candidate itemsets during mining?

level: middleimportance: should knowfreq 58%

basics

~20 s

Adding an item to an itemset can only reduce the number of baskets containing it, so any superset of an infrequent itemset is also infrequent. Apriori works level by level and discards candidates whose subsets already failed.

open as a page

How do item side features get folded into a latent-factor recommender for cold items?

level: middleimportance: should knowfreq 40%

basics

~20 s

Give each item feature its own learned vector in the same latent space and build the item's vector by summing the vectors of the features it has. A brand-new item then inherits a position the moment its metadata is known.

open as a page

In implicit feedback, how do interaction counts become confidence weights rather than ratings?

level: middleimportance: should knowfreq 51%

basics

~20 s

The signal splits in two: a binary preference, one if any interaction happened, and a confidence from the count, such as c = 1 + alpha * r. The count scales how much the loss cares, not how much the user likes it.

open as a page

Why does a rating-prediction factorization model need global, user and item bias terms?

level: middleimportance: should knowfreq 52%

basics

~20 s

Bias terms absorb the part of a rating that is not about taste: the overall rating level, how generous the reviewer is, and how well-liked the film is. Factors then model only the leftover interaction.

open as a page

How does inverse propensity weighting turn position-biased clicks into an unbiased relevance signal?

level: middleimportance: should knowfreq 48%

basics

~20 s

Divide each logged click by the probability that its slot was examined, so a rank-8 click counts far more than a rank-1 click. In expectation that recovers relevance, but rare deep clicks make the estimate noisy.

open as a page

After mining 2 million basket rules, how do you decide which few are worth acting on?

level: seniorimportance: should knowfreq 46%

basics

~20 s

Filter on absolute joint basket counts, not percentages; rank by lift with a leverage floor; drop rules that are redundant given a shorter rule; then test the survivors, because a co-occurrence rule does not predict what happens when you intervene.

open as a page

How do you recommend to a brand-new subscriber who has interacted with nothing yet?

level: seniorimportance: should knowfreq 50%

basics

~20 s

Combine three levers: infer from context the request already carries such as locale and referrer, elicit taste with a short onboarding prompt, and fall back to a trending list. Decay the elicited prior as behaviour arrives.

open as a page

A feed retrained monthly only on its own logged impressions narrows users from twelve interest categories to three — why?

level: seniorimportance: should knowfreq 46%

basics

~20 s

The training log only contains items the previous model chose to show. Categories it stopped surfacing collect no engagement, so the next model sees even less evidence for them and shows them less again. The loop compounds every retrain.

open as a page

How do you sample negatives from unplayed items in an implicit-feedback recommender?

level: seniorimportance: should knowfreq 45%

basics

~20 s

Draw a few unobserved items per observed interaction, often around four, and redraw them each pass. The distribution is the real decision: uniform draws are almost all long tail and too easy, popularity-weighted draws are harder but push popular items down.

open as a page

How do you build pairwise ranking training data from result lists of 500 candidates each?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Form pairs only within one query's list, never across lists, and never enumerate them all: 500 candidates give 124,750 pairs. Keep pairs whose labels differ, sample and weight the rest, and normalise so long lists do not dominate.

open as a page

Why is a similarity of 1.0 between two users with only 3 co-rated titles unreliable?

level: seniorimportance: should knowfreq 45%

basics

~20 s

A similarity is an estimate from a sample, and three co-rated items is a sample of three. Perfect agreement that small happens by chance, so such pairs flood every neighbour list. Shrink similarities toward zero by co-rating count.

open as a page

What does leave-one-out on each learner's most recent item leak that a time-ordered split does not?

level: seniorimportance: should knowfreq 58%

basics

~20 s

Most recent is per learner, not global, so training still holds events dated after some learners' held-out items. The model absorbs future popularity, co-occurrence and catalog changes it could never have at serving time. A fixed-date cut removes that.

open as a page

How do you estimate per-rank examination propensities on a live results page?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Perturb the order for a small traffic slice so the same items land in different slots, then compare their click rates across slots. Holding the items fixed makes the ratio an examination ratio rather than a quality difference.

open as a page

Offline recall rose 12% but launch moved enrolments 0% - how should offline results gate launches?

level: principalimportance: should knowfreq 42%

basics

~20 s

Treat an offline top-k win as a screen, not a decision. It scores re-ranking of behaviour that already happened, not behaviour change. Calibrate the bar against your own recorded history of offline versus online deltas rather than a threshold someone invented.

open as a page

How does FP-growth mine frequent itemsets without generating candidates?

level: middleimportance: nice to knowfreq 30%

basics

~20 s

It compresses the transactions into a prefix tree in two passes, then mines recursively from conditional sub-trees built for each item. No candidate itemsets are enumerated and no extra pass over the raw data is needed per itemset length.

open as a page

showing 1–30 of 38