Notes

k-Nearest Users

Ask the friend whose taste has matched yours before what to watch tonight, and you are running this algorithm by hand. k-Nearest Users formalises the instinct: find the few people whose interaction history most resembles yours, then let their choices stand in for the preferences you have not expressed yet.

How the neighbourhood is picked
Every other user is scored against the target by a similarity over the items both have touched — Pearson correlation on explicit ratings, cosine on an implicit click vector — and only the top k are kept. An unseen item's score is then a similarity-weighted average of what those neighbours did with it, mean-centred per user so a generous rater does not inflate the result. Neighbours who never touched the item contribute nothing, so the working neighbourhood is smaller than k for anything obscure.

What k trades off

  • Small k, around five to ten: sharp and idiosyncratic, with predictions that swing on one person's rating.
  • Large k, in the hundreds: the average drifts toward catalogue popularity and the list stops being personal.
  • A similarity threshold usually beats a fixed count — drop weak neighbours instead of filling slots with them.

Why it matters
Nothing is trained in advance, so a user becomes recommendable the moment they have a handful of interactions — the real advantage over a factor model that must be refitted. The cost lands at request time: similarities shift as history grows, and comparing one user against millions does not fit a few-millisecond budget without an approximate-nearest-neighbour index such as FAISS. That is why production neighbourhood systems usually flip to item-item similarity, which is stable enough to precompute, and keep nearest users for small user bases and for explaining a recommendation.

k-Nearest Users is the neighbourhood of the k users most similar to a target user, selected by a similarity over their shared interaction history and used to score items the target has not seen. The choice of k is a bias-variance dial: too few neighbours makes predictions erratic, too many collapses them toward popularity. It lets user-based collaborative filtering recommend for a user the moment they have any history, with no retraining.

Think of asking around before booking a holiday. You do not poll everyone you know — you ask the three or four friends whose taste has matched yours before, because their answer is worth more than a crowd's.

That is what k-Nearest Users does. Software compares your history of clicks, plays and ratings against everyone else's, keeps the small group that looks most like you, and suggests what they went for and you have not tried. The k is simply how many people are in that group. Too few, and one odd neighbour skews everything. Too many, and you get whatever is broadly popular, which is no longer a recommendation for you.