liveBook · Manning

Baseline

As explained in AI Recommender Systems

A popularity baseline recommends items according to their overall popularity and serves as a reference for personalized methods.

A popularity baseline ranks items by their overall interaction counts and recommends the same top items to every user. It is a simple, nonpersonalized reference: a more complex recommender should justify its added complexity by outperforming it, not merely by outperforming random selection. section 4.4.4 section 4.5.1

To build and test one offline:

  • Split historical interactions by time. Count each item's interactions in the training data, then take the top k items. Do not use test-period interactions to determine popularity. section 4.2.1 section 4.4.4
  • Give each test user that same ranked list. Compare it with the user's test-period relevance set using the same metric applied to the candidate model. section 4.2.1 section 4.4.4
Listing 4.7 Popularity baseline
def generate_recommendations_popularity(train_df, user_ids, k=10):
    """
    Generate popularity-based recommendations.
    Returns DataFrame with [user_id, item_id, rank, score]
    """
    item_counts = train_df['item_id'].value_counts()       #A
    top_items = item_counts.head(k)                         #B
    
    recommendations = []
    for user_id in user_ids:
        for rank, (item_id, count) in enumerate(top_items.items(), 1):
            recommendations.append({                        #C
                'user_id': user_id,
                'item_id': item_id,
                'rank': rank,
                'score': count
            })
    
    return pd.DataFrame(recommendations)
 
pop_recs = generate_recommendations_popularity(train, test_user_ids, k=10)
pop_metrics = calculate_precision_at_k(pop_recs, ground_truth, k=10)
 

The implementation counts training-set item IDs, takes the top k, and emits each item’s count as its score in an identical ranked list for every test user. section 4.4.4

Interpreting a comparison

An ALS recommender scores 0.1523 precision@10 against the popularity baseline’s 0.1234: a 23.4% improvement. That suggests ALS has learned something beyond general popularity, but popularity still achieves about 81% of its precision without the added complexity. Whether the gain is worthwhile depends on engineering resources and business goals. section 4.4.4

Treat the result as a starting point, not a deployment decision. Check ranking quality, catalog coverage, and performance across user segments: a good average precision can conceal narrow recommendations or weak results for particular users. Popularity can be especially hard to beat for cold-start users; established users set a higher bar for personalization. If a production recommender already exists, compare against that system too. section 4.10 section 4.5.2

How AI Recommender Systems covers it

How deep it goes
Works through training-set item counts and an offline precision comparison; calls for further ranking, coverage, and segment checks.
Examples
Compares ALS precision@10 of 0.1523 with popularity precision@10 of 0.1234 and supplies a pandas recommendation function.
What it assumes
Assumes historical user-item interactions and a train/test workflow; builds the baseline without a personalized model.
What you can do after
Build it from scratch by counting training-set item interactions, ranking the top items, and evaluating identical per-user lists.
How it connects
Connects random recommendation, ALS, precision@10, temporal splitting, catalog coverage, and cold-start evaluation.

Also explained in

Compare how 27 books explain baseline →

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.