Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 43

Predicting Lingerie Ratings with User-Based Collaborative Filtering

Recommended resources

Introduction

In our last lesson, we explored association rule mining to discover which lingerie items tend to appear together in successful outfits. This helps in building cohesive looks based on historical data. Now, we'll shift our focus from relationships between items to relationships between people—or in our context, the models wearing the lingerie.

This lesson introduces Collaborative Filtering, the powerhouse behind most recommendation engines. Specifically, we will focus on user-based collaborative filtering. You will learn how to predict a model's rating for a lingerie piece she has never seen before by analyzing the preferences of other models with similar tastes. This technique is a cornerstone of the "Style Optimization" phase of your project, enabling you to pre-screen and personalize selections for a specific model, making fitting sessions more efficient and effective.


The Problem of Predicting Preference

At its core, the recommendation problem is about filling in the blanks. Imagine a large table where rows represent your models and columns represent all the lingerie pieces you've ever used. The cells contain the rating each model gave to each piece, but most cells are empty because no model has tried every single item. Our goal is to predict these missing values.

A typical rating matrix. In our case, 'u' stands for a model and 'i' represents a lingerie item. The empty cells are the ratings we want to predict.

This process of "filling in the matrix" can be approached in several ways. One powerful method is collaborative filtering, which leverages the "wisdom of the crowd."

The Math Behind Recommender Systems

To get a high-level overview of this problem, watch the first two minutes of this video from the "Art of the Problem" channel. It provides an excellent visual and conceptual introduction to the matrix representation of preferences.

Watch from the beginning until the problem is framed as predicting missing values in a user-item matrix.


User-Based vs. Item-Based Filtering

Collaborative filtering primarily splits into two approaches, both starting from the same rating matrix but taking different paths to find a prediction.

This diagram illustrates the two main pathways in collaborative filtering. User-based filtering (top path) finds similar users to make a prediction. Item-based filtering (bottom path) finds similar items.
  1. User-Based Collaborative Filtering (our focus today): The core idea is "If model A and model B have similar tastes, then model A will likely enjoy other lingerie pieces that model B has enjoyed." We find a 'neighborhood' of similar models and use their ratings to predict the target model's rating for a new item.

  2. Item-Based Collaborative Filtering: The idea here is "If a model liked a specific lace balconette bra, she will probably also like other similar lace balconette bras." This involves finding similar items and predicting a rating based on how the model rated those similar items.

While both are powerful, we will concentrate on the user-based approach as specified in our learning goal.


Step 1: Finding Models with Similar Tastes

The most critical step in user-based collaborative filtering is to mathematically define and calculate "similar tastes." How can we quantify the similarity between two models, say Alice and Brenda, based on their rating history?

A simple approach might be to look at the movies... I mean, lingerie... they've both rated. However, as your statistical background will tell you, a simple count or basic similarity measure can be misleading. A more robust method is needed that accounts for individual rating behavior. For instance, Alice might be a "tough rater" who rarely gives a score above 4, while Brenda is an "easy rater" who hands out 5s freely.

To handle this, we use Centered Cosine Similarity, which you'll know by another name: the Pearson correlation coefficient.

Lecture 43 — Collaborative Filtering Stanford University

This lecture from Stanford University gives a fantastic explanation of why simpler methods like Jaccard or basic Cosine similarity fall short, and why Pearson correlation (centered cosine) is the superior choice.

Watch the segment from Jaccard to Pearson. The lecturer walks through a numerical example showing how mean-centering each user's ratings normalizes for biases like being a "tough" or "easy" rater and provides a much more intuitive measure of similarity.

The process, as explained in the video, is as follows:

  1. For each model, calculate her average rating across all the items she has rated.
  2. Create a new, "centered" rating matrix by subtracting this average from each of her individual ratings. Now, a positive rating means she liked an item more than her personal average, a negative rating means she liked it less, and a zero represents an average rating.
  3. Calculate the cosine similarity between the vectors of two models using this new centered matrix. This value is the Pearson correlation coefficient, , between model and model . It will range from -1 (perfectly opposite tastes) to +1 (identical tastes).

Step 2: Predicting the Rating

Once we have a way to calculate the similarity between our target model and all other models , we can predict her rating for a new lingerie piece, .

The logic is to find a neighborhood of the k most similar models to who have already rated item , and then calculate a weighted average of their ratings. The weights are their similarity scores. A model with a similarity of 0.9 to our target model will have her opinion count much more than a model with a similarity of 0.2.

The prediction formula looks like this. Given your operations research background, this formulation of a weighted sum should be quite familiar.

[PDF] Recommender System Using Collaborative Filtering Algorithm

This research paper provides the formal mathematical definitions for the process. We will focus on the formulas for user-based collaborative filtering.

In the section titled User-Based Collaborative Filtering, examine the three formulas presented. The first shows the calculation of the user mean rate (\bar{v}_u). The second is the Pearson correlation formula for the weight (w_{uv}). The third is the final prediction formula, which adjusts the weighted average by the user's own mean rating.

Let's break down that final prediction formula from the paper:

Where:

  • is the predicted rating of model for item .
  • is the average rating of our target model .
  • is the neighborhood of similar models who have rated item .
  • is the Pearson correlation (similarity) between models and .
  • is the centered rating of neighbor model for item .

In essence, we are calculating the weighted average of how much the other models deviated from their own average for this item, and then adding that deviation to our target model's average rating. This accounts for the fact that our target model might be a "tough rater" herself.


Numerical Exercise

Let's put this into practice. You are trying to predict how a model, Carla, will rate the 'Satin Chemise'. You have a rating matrix from three other models: Alice, Brenda, and Dana. Ratings are on a 1-5 scale.

Model Plunge Bra Lace Bodysuit Satin Chemise Garter Belt
Alice 5 4 4 -
Brenda 2 3 3 2
Dana 5 - 5 4
Carla 4 3 ? 5

Your Task: Predict Carla's rating for the 'Satin Chemise' using user-based collaborative filtering. Use a neighborhood of the two most similar models (k=2).

  1. Calculate Mean Ratings: Find the average rating for each model who has rated the 'Satin Chemise' (Alice, Brenda, Dana) and for Carla.
  2. Calculate Similarities: Calculate the Pearson correlation between Carla and the other three models. Remember to only use items they have both rated.
    • Carla-Alice: Use 'Plunge Bra' and 'Lace Bodysuit'.
    • Carla-Brenda: Use 'Plunge Bra', 'Lace Bodysuit', and 'Garter Belt'.
    • Carla-Dana: Use 'Plunge Bra' and 'Garter Belt'.
  3. Identify the Neighborhood: Select the two models with the highest similarity score to Carla.
  4. Predict the Rating: Use the weighted average formula to calculate the final predicted rating for Carla on the 'Satin Chemise'.

Take your time to work through the steps. The solution is below.



Solution

1. Calculate Mean Ratings:

2. Calculate Similarities (Pearson Correlation):
Let's use the standard formula for Pearson's :

  • Similarity(Carla, Alice):

    • Items in common: Plunge Bra, Lace Bodysuit.
    • Carla's ratings: (4, 3). . Centered: (0.5, -0.5).
    • Alice's ratings: (5, 4). . Centered: (0.5, -0.5).
    • Numerator:
    • Denominator:
    • . (Perfect correlation on the items they share).
  • Similarity(Carla, Brenda):

    • Items: Plunge Bra, Lace Bodysuit, Garter Belt.
    • Carla's ratings: (4, 3, 5). . Centered: (0, -1, 1).
    • Brenda's ratings: (2, 3, 2). . Centered: (-0.33, 0.67, -0.33).
    • Numerator:
    • Denominator:
  • Similarity(Carla, Dana):

    • Items: Plunge Bra, Garter Belt.
    • Carla's ratings: (4, 5). . Centered: (-0.5, 0.5).
    • Dana's ratings: (5, 4). . Centered: (0.5, -0.5).
    • Numerator:
    • Denominator:

3. Identify the Neighborhood (k=2):
The models who have rated 'Satin Chemise' are Alice, Brenda, and Dana.

  • Similarity(Carla, Alice) = 1.0
  • Similarity(Carla, Brenda) = -0.86
  • Similarity(Carla, Dana) = -1.0

The two most similar models are Alice () and Brenda (). So, . Note: Even though Brenda has a negative correlation, she is 'more similar' than Dana, who has a perfect negative correlation.

4. Predict the Rating:

  • Alice's rating for SC: . . Deviation: .
  • Brenda's rating for SC: . . Deviation: .


Predicted rating: ~3.6. Based on the tastes of similar models, Carla is predicted to rate the 'Satin Chemise' around 3.6 out of 5.


Conclusion

In this lesson, you've learned the mechanics of user-based collaborative filtering, a method to predict a model's preferences for items she hasn't seen. By leveraging your statistical foundation, you can now appreciate the importance of using a robust similarity metric like Pearson correlation and understand how to combine the opinions of a "neighborhood" of similar users into a single, actionable prediction.

Key Takeaways:

  • User-based collaborative filtering predicts ratings for a target user by finding a neighborhood of similar users.
  • Pearson correlation is an effective similarity metric because it mean-centers each user's ratings, accounting for individual biases.
  • A weighted average of the neighbors' centered ratings, adjusted by the target user's own average, provides a robust prediction.
  • This technique is powerful but faces challenges, notably the "cold start" problem: it cannot make predictions for new models with no rating history, nor can it recommend new items that no one has rated yet.

Preview of the Next Lesson:
We have now covered methods for discovering item pairings and for predicting individual preferences. This concludes our module on advanced optimization techniques. In our final lesson of this module, we will tackle a different kind of optimization problem directly relevant to the "Fitting Room Experimentation" phase: Optimal Stopping. You will learn a famous rule to decide when to stop scouting for new lingerie options and commit to the best one you have seen so far, maximizing your chances of making the perfect final selection for the photoshoot.