Challenge - 5 Problems
Content-based Filtering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
How does content-based filtering recommend items?
Which of the following best describes how content-based filtering recommends items to a user?
Attempts:
2 left
💡 Hint
Think about how the system uses the user's past preferences and item details.
✗ Incorrect
Content-based filtering uses the features of items the user liked to find similar items to recommend.
❓ Predict Output
intermediate2:00remaining
Output of cosine similarity calculation
What is the output of this Python code that calculates cosine similarity between two item feature vectors?
ML Python
from sklearn.metrics.pairwise import cosine_similarity import numpy as np item1 = np.array([[1, 0, 1, 0]]) item2 = np.array([[0, 1, 1, 0]]) similarity = cosine_similarity(item1, item2) print(round(similarity[0][0], 2))
Attempts:
2 left
💡 Hint
Recall cosine similarity formula and count overlapping features.
✗ Incorrect
Cosine similarity is the dot product divided by the product of vector lengths. Here it equals 0.5.
❓ Model Choice
advanced2:00remaining
Best model for content-based filtering with sparse user-item data
Which model is most suitable for content-based filtering when user-item interaction data is sparse but item features are rich?
Attempts:
2 left
💡 Hint
Focus on models that use item features directly.
✗ Incorrect
K-Nearest Neighbors on item features works well when user-item data is sparse but item features are available.
❓ Hyperparameter
advanced2:00remaining
Choosing the number of neighbors in content-based KNN
In a content-based filtering system using K-Nearest Neighbors on item features, what is the effect of increasing the number of neighbors (k)?
Attempts:
2 left
💡 Hint
Think about how more neighbors affect similarity and variety.
✗ Incorrect
Increasing k includes more items that are less similar, increasing diversity but possibly lowering relevance.
🔧 Debug
expert3:00remaining
Why does this content-based filtering code produce identical recommendations for all users?
Given this simplified content-based filtering code, why do all users get the same recommended items?
```python
import numpy as np
user_profiles = {
'user1': np.array([1, 0, 1]),
'user2': np.array([1, 0, 1]),
'user3': np.array([1, 0, 1])
}
item_features = {
'itemA': np.array([1, 0, 0]),
'itemB': np.array([0, 1, 1]),
'itemC': np.array([1, 0, 1])
}
recommendations = {}
for user, profile in user_profiles.items():
scores = {}
for item, features in item_features.items():
scores[item] = np.dot(profile, features)
recommended = sorted(scores, key=scores.get, reverse=True)[:2]
recommendations[user] = recommended
print(recommendations)
```
Attempts:
2 left
💡 Hint
Check the user profiles carefully.
✗ Incorrect
Since all user profiles are the same vector, their dot products with items are identical, leading to identical recommendations.