Bird
Raised Fist0
ML Pythonml~20 mins

User-based vs item-based in ML Python - Practice Questions

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Collaborative Filtering Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in similarity calculation between user-based and item-based collaborative filtering

In collaborative filtering, similarity is a key concept. Which statement correctly describes how similarity is calculated differently in user-based versus item-based methods?

AUser-based calculates similarity between items based on user ratings, while item-based calculates similarity between users based on item ratings.
BUser-based calculates similarity between users based on their item ratings, while item-based calculates similarity between items based on user ratings.
CBoth user-based and item-based calculate similarity only between users, ignoring items.
DBoth user-based and item-based calculate similarity only between items, ignoring users.
Attempts:
2 left
💡 Hint

Think about who is being compared in each method: users or items.

❓ Model Choice
intermediate
2:00remaining
Choosing between user-based and item-based collaborative filtering for a large user base

You have a recommendation system with millions of users but only a few thousand items. Which collaborative filtering approach is generally more efficient and why?

AUser-based, because it ignores item data and focuses only on user profiles.
BUser-based, because millions of users provide more data to compute accurate user similarities quickly.
CItem-based, because it requires no similarity calculations.
DItem-based, because the number of items is smaller, so computing item similarities is faster and more stable.
Attempts:
2 left
💡 Hint

Consider which similarity matrix is smaller and easier to compute.

❓ Metrics
advanced
2:00remaining
Evaluating recommendation accuracy for user-based vs item-based methods

You run both user-based and item-based collaborative filtering on the same dataset. Which metric would best help you compare their prediction accuracy on unseen user-item ratings?

ATotal number of items recommended.
BNumber of users in the dataset.
CRoot Mean Squared Error (RMSE) between predicted and actual ratings.
DTraining time of the model.
Attempts:
2 left
💡 Hint

Think about a metric that measures how close predictions are to real ratings.

🔧 Debug
advanced
2:00remaining
Identifying the cause of sparse similarity matrix in user-based filtering

You implemented user-based collaborative filtering but notice the user similarity matrix is very sparse, causing poor recommendations. What is the most likely cause?

AUsers have rated very few common items, so similarity cannot be reliably computed.
BThe model is overfitting due to too many training epochs.
CThe dataset contains too many items, causing memory overflow.
DThe item similarity matrix was used instead of the user similarity matrix by mistake.
Attempts:
2 left
💡 Hint

Think about what is needed to calculate similarity between two users.

🧠 Conceptual
expert
2:00remaining
Impact of cold start problem on user-based vs item-based collaborative filtering

Which statement best explains how the cold start problem affects user-based and item-based collaborative filtering differently?

AUser-based struggles more with new users who have no ratings, while item-based struggles more with new items that have no user ratings.
BUser-based struggles more with new items, while item-based struggles more with new users.
CBoth user-based and item-based methods are equally unaffected by cold start problems.
DCold start only affects content-based filtering, not collaborative filtering.
Attempts:
2 left
💡 Hint

Consider what data each method needs to make recommendations.

Practice

(1/5)
1. Which of the following best describes user-based recommendation?
easy
A. Suggest items liked by users similar to you
B. Suggest items similar to what you liked
C. Suggest random popular items
D. Suggest items based on item price

Solution

  1. Step 1: Understand user-based recommendation

    User-based recommendation finds users similar to you and suggests what they liked.
  2. Step 2: Compare options

    Suggest items liked by users similar to you matches this definition exactly, while others describe different or unrelated methods.
  3. Final Answer:

    Suggest items liked by users similar to you -> Option A
  4. Quick Check:

    User-based = Suggest items liked by similar users [OK]
Hint: User-based = find similar users, recommend their items [OK]
Common Mistakes:
  • Confusing user-based with item-based
  • Thinking user-based recommends similar items
  • Choosing popular or random items as user-based
2. Which code snippet correctly represents item-based recommendation logic?
easy
A. recommend_items = find_similar_users(user).liked_items()
B. recommend_items = find_similar_items(user_liked_items)
C. recommend_items = random_popular_items()
D. recommend_items = items_sorted_by_price()

Solution

  1. Step 1: Identify item-based recommendation code

    Item-based recommends items similar to those the user liked, so code should find similar items.
  2. Step 2: Match code to logic

    recommend_items = find_similar_items(user_liked_items) calls find_similar_items(user_liked_items), which fits item-based logic. Others do not.
  3. Final Answer:

    <code>recommend_items = find_similar_items(user_liked_items)</code> -> Option B
  4. Quick Check:

    Item-based = find similar items [OK]
Hint: Item-based code finds similar items to user's liked items [OK]
Common Mistakes:
  • Choosing user-based code for item-based question
  • Confusing random or price sorting with item similarity
  • Ignoring the input to similarity function
3. Given this code snippet for user-based recommendation:
user_similarities = {'User1': 0.9, 'User2': 0.8}
user_likes = {'User1': ['ItemA', 'ItemB'], 'User2': ['ItemB', 'ItemC']}
recommend = set()
for user, sim in user_similarities.items():
if sim > 0.85:
recommend.update(user_likes[user])
print(sorted(recommend))

What is the output?
medium
A. ['ItemA', 'ItemB', 'ItemC']
B. ['ItemB', 'ItemC']
C. ['ItemA', 'ItemB']
D. []

Solution

  1. Step 1: Identify users with similarity > 0.85

    Only 'User1' has similarity 0.9 > 0.85, so only their liked items are added.
  2. Step 2: Collect items liked by 'User1'

    'User1' likes ['ItemA', 'ItemB'], so these are added to the recommendation set.
  3. Final Answer:

    ['ItemA', 'ItemB'] -> Option C
  4. Quick Check:

    Similarity filter picks User1's items [OK]
Hint: Only users with similarity > 0.85 contribute items [OK]
Common Mistakes:
  • Including items from User2 who has similarity 0.8
  • Not sorting output before printing
  • Confusing set update with append
4. Find the error in this item-based recommendation code:
user_liked = ['ItemA', 'ItemB']
def find_similar_items(items):
return ['ItemC', 'ItemD']
recommend = find_similar_items(user_liked)
print(recommend)

What is the main problem?
medium
A. Syntax error in function definition
B. Print statement missing parentheses
C. Variable user_liked is not defined
D. Function returns unrelated items, ignoring input

Solution

  1. Step 1: Check function behavior

    The function find_similar_items ignores its input and returns fixed items.
  2. Step 2: Identify why this is a problem

    Item-based recommendation should return items similar to input, but this function does not use input at all.
  3. Final Answer:

    Function returns unrelated items, ignoring input -> Option D
  4. Quick Check:

    Function must use input to find similar items [OK]
Hint: Check if function uses input parameter correctly [OK]
Common Mistakes:
  • Thinking code has syntax errors when it doesn't
  • Ignoring that function ignores input
  • Confusing variable names or print syntax
5. You want to build a hybrid recommendation system combining user-based and item-based methods. Which approach best fits this goal?
hard
A. Combine scores from similar users and similar items for each candidate
B. Use only user-based recommendations to simplify model
C. Use only item-based recommendations to reduce computation
D. Randomly pick recommendations from either user or item-based

Solution

  1. Step 1: Understand hybrid recommendation

    Hybrid systems combine strengths of user-based and item-based methods to improve accuracy.
  2. Step 2: Identify best combination method

    Combining scores from both similar users and similar items for each candidate item leverages both perspectives effectively.
  3. Final Answer:

    Combine scores from similar users and similar items for each candidate -> Option A
  4. Quick Check:

    Hybrid = combine user and item scores [OK]
Hint: Hybrid = combine user and item recommendation scores [OK]
Common Mistakes:
  • Choosing only one method loses hybrid benefits
  • Random picking reduces recommendation quality
  • Ignoring score combination logic
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard