Monash University · FACULTY OF INFORMATION TECHNOLOGY

FIT5202 · Data Processing for Big Data

- one subject, every graph, every model, every mark
Information Technology14 Chapters8-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 8 of 11 · FIT5202

Machine Learning: Collaborative Filtering

Week 8 of Monash FIT5202 covers recommender systems: content-based versus collaborative filtering, user-based and item-based CF using cosine similarity, predicted ratings as a similarity-weighted aggregate, and model-based CF via matrix factorization (Spark MLlib's ALS). It also introduces the cold-start problem. Computing cosine similarity and a predicted rating is a reliable written-response item, and matrix factorization/ALS reasoning appears in the multiple-choice question.

In this chapter

What this chapter covers

  • 01Recommender approaches: content-based vs collaborative filtering (memory-based vs model-based)
  • 02User-based CF: find similar users, predict from their ratings, recommend top-N
  • 03Cosine similarity over co-rated items: sim(u,u') = Σ rᵤᵢ·rᵤ'ᵢ / (√Σ rᵤᵢ² · √Σ rᵤ'ᵢ²)
  • 04Predicted rating rᵤᵢ = k·Σ sim(u,u')·rᵤ'ᵢ with k = 1/Σ|sim(u,u')|
  • 05Item-based CF as the transpose view of user-based CF
  • 06Model-based CF: matrix factorization R ≈ U × V with r latent features (rank)
  • 07Alternating Least Squares (ALS): fix U, solve V; fix V, solve U; minimise RMSE
  • 08The cold-start problem for new users and new items
Worked example · free

User-based collaborative filtering with cosine similarity

Q [6 marks]. Predict Alice's rating for the movie Dune using user-based CF with cosine similarity. Ratings on the three co-rated movies are — Alice: Matrix 5, Inception 3, Interstellar 4 (Dune = ?); Bob: Matrix 4, Inception 2, Interstellar 5, Dune 5; Carol: Matrix 5, Inception 3, Interstellar 3, Dune 4. (6 marks)
  • +1Cosine similarity of Alice and Bob over the co-rated movies {Matrix, Inception, Interstellar}: numerator = 5·4 + 3·2 + 4·5 = 20 + 6 + 20 = 46.
  • +1Denominator = √(5²+3²+4²)·√(4²+2²+5²) = √50·√45 = 7.071·6.708 ≈ 47.43, so sim(Alice, Bob) = 46 / 47.43 ≈ 0.97.
  • +1Similarity of Alice and Carol: numerator = 5·5 + 3·3 + 4·3 = 25 + 9 + 12 = 46; denominator = √50·√(5²+3²+3²) = √50·√43 = 7.071·6.557 ≈ 46.37, so sim(Alice, Carol) ≈ 0.99.
  • +1Normaliser k = 1 / (|sim(Alice, Bob)| + |sim(Alice, Carol)|) = 1 / (0.97 + 0.99) = 1 / 1.96 ≈ 0.510.
  • +1Predicted rating = k · [sim(Alice, Bob)·R(Bob, Dune) + sim(Alice, Carol)·R(Carol, Dune)] = 0.510 · [0.97·5 + 0.99·4] = 0.510 · [4.85 + 3.96] = 0.510 · 8.81.
  • +1= 4.49 ≈ 4.5. Both neighbours are highly similar to Alice and rate Dune well, so Dune is a strong recommendation.
sim(Alice, Bob) ≈ 0.97, sim(Alice, Carol) ≈ 0.99, and the similarity-weighted prediction for Dune is ≈ 4.5, so Dune should be recommended to Alice.
Sia tip — Compute cosine similarity only over the items both users rated, then weight the neighbours' ratings of the target item by those similarities and divide by the sum of the similarities (that is k). Forgetting to normalise by Σ|sim| is the usual slip and pushes the predicted rating out of the valid range.
Glossary

Key terms

Collaborative filtering (CF)
Predicting a user's preferences from the preferences of many users. Memory-based CF (user- or item-based) uses similarity directly; model-based CF learns latent factors.
Cosine similarity
The similarity of two rating vectors over co-rated items: sim(u,u') = Σ rᵤᵢ·rᵤ'ᵢ / (√Σ rᵤᵢ² · √Σ rᵤ'ᵢ²). It measures the angle between the vectors, ignoring their length.
User-based CF
Recommend items by finding users with similar rating patterns to the target user and aggregating their ratings of items the target has not seen.
Matrix factorization
Model-based CF that factors the N×M rating matrix R into a user matrix U (N×r) and item matrix V (r×M), with r latent features, so R ≈ U × V.
ALS (Alternating Least Squares)
The optimisation Spark MLlib uses to learn U and V: alternately fix one and solve the other by least squares, iterating to minimise the RMSE between predicted and actual ratings.
Cold-start problem
The difficulty of recommending for a brand-new user or item that has few or no ratings, so similarity- and factor-based methods have little to work with.
FAQ

Machine Learning: Collaborative Filtering FAQ

Why compute cosine similarity only over co-rated items?

Because a similarity is only meaningful where two users have both expressed a preference. Including items only one of them rated would compare a rating against a missing value. So you restrict the sums in the cosine formula to the items both users rated, then use those similarities to weight predictions.

What is the difference between memory-based and model-based CF?

Memory-based CF (user- or item-based) computes similarities directly from the rating matrix at prediction time. Model-based CF learns a compact model first — matrix factorization factors R into user and item latent-factor matrices via ALS — and predicts from that model, which scales better to large, sparse matrices.

What causes the cold-start problem and how is it handled?

A new user or item has too few ratings for similarity or factorization to work, so CF cannot place them. Common mitigations are falling back to content-based features, asking new users for a few initial ratings, or recommending popular items until enough data accumulates.

Can AI help me with collaborative filtering calculations?

Yes. Sia can compute cosine similarities and similarity-weighted predictions with you, explain matrix factorization and ALS, and quiz you on the cold-start problem — step by step, checking your working. It does not complete your graded assessment, and Monash academic-integrity rules apply.

Study strategy

Exam move

Make the two-formula routine automatic: cosine similarity over co-rated items, then a similarity-weighted prediction normalised by k = 1/Σ|sim|. Practise until you never forget the normaliser, and always sanity-check that a predicted rating lands inside the rating scale. Understand matrix factorization and ALS conceptually — factor R into U and V, alternate least squares, minimise RMSE — for the multiple-choice question, and be able to define the cold-start problem. Rehearse a full prediction on Moodle problems through SWOTVAC and ask Sia for fresh rating matrices.

Working through Machine Learning: Collaborative Filtering in FIT5202? Sia is AskSia’s AI Information Technology tutor — ask any FIT5202 Machine Learning: Collaborative Filtering question and get a clear, step-by-step explanation grounded in how FIT5202 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 47 of your Monash University subjects - and 1,000+ Bibles across every Australian university.
Sia - your FIT5202 tutor, unlimited, worked the way the exam marks it
The full 8-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$25/ month
30-day money-back · cancel in one tap · how it works
Unlock the full FIT5202 Bible + 47 Monash University subjects解锁完整 FIT5202 Bible + Monash University 47 门科目
$25/mo