liveBook · Manning

Retrieval ranking

As explained in AI Recommender Systems

The process of ordering candidate items according to a relevance or preference score.

Ranking orders a candidate set by a final score and selects the items to recommend. It can balance multiple objectives, such as similarity and popularity. section 2.2.5

Within a recommender pipeline, ranking:

  • Makes final ordering decisions after retrieval, filtering, and scoring. section 2.2.8
  • Can trade off similarity and popularity by changing their weights; more advanced rankers may also account for diversity, business rules, position bias, and exploration versus exploitation. section 2.2.5
  • Needs room to work: retrieving 2–10 times the desired final list size leaves candidates available after filtering. section 2.2.5

Changing the weights

For a movie recommender, rank candidates using a weighted combination of similarity and popularity. Comparing similarity weights of 1.0, 0.5, and 0.0 shows how the balance changes the top-five results. section 2.2.5

Listing 2.9 Ranking by weighted scores
def rank_candidates(candidates, similarity_weight=0.7, k=10):
    for item in candidates:
        item['final_score'] = (
            similarity_weight * item['similarity'] +
            (1 - similarity_weight) * item['popularity']
        ) #A
    
    ranked = sorted(
        candidates,
        key=lambda x: x['final_score'],
        reverse=True
    ) #B
    
    return ranked[:k] #C

The Python example calculates each candidate’s weighted score, sorts by that score, and returns the top k. section 2.2.5

How AI Recommender Systems covers it

How deep it goes
Implements weighted scoring and top-k sorting, then notes advanced objectives without detailing their algorithms.
Examples
Compares movie recommendations ranked with different similarity and popularity weights.
What it assumes
Assumes candidates and scores are available, and places ranking after retrieval, filtering, and scoring.
What you can do after
Apply weighted ranking by combining similarity and popularity scores, sorting candidates, and selecting the top k.
How it connects
Connects ranking to retrieval, scoring, filtering, and recommender-system evaluation.

Also explained in

Compare how 9 books explain retrieval ranking →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Recommender Systems. The section links point to the parts of the book it draws on.