User-based filtering asks "who is like you?". Item-based filtering turns it around: to predict how you'd rate an item, find the items most similar to it that you have already rated, and average your own ratings of those.
Task: write predict_item_cf(ratings, user, item, k) returning the prediction, rounded to 4 decimal places.
The steps:
0.k most similar candidates. Ties go to the lower item index.ratings is a list of rows (users) by columns (items), with None for unrated. zip(*ratings) gives you the columns.0, return 0.0.Item-based is the version that actually got deployed at scale, and the reason is practical rather than mathematical: item-item similarities are far more stable than user-user ones. A film's relationship to other films barely moves from week to week, so the similarity matrix can be computed nightly and cached, while a user's taste profile shifts with every click. Amazon's recommender was built on exactly this asymmetry.