Interview Prep
Interview questions, roadmaps and practice sets
Tutorials
Free tutorials on 30+ topics
Blog
Career guides, skills and interview tips
Free PDFs
Notes, cheat sheets and question banks
Certificates
Free skill tests and course certificates
Tools & Whiteboard
Free tools you can use right in the browser
Practice Tests
Mock tests, MCQs and quick Q&A
Free LMS
Learn on the Uncodemy LMS
Choose the best training program according to your career.
Improve the performance of your business with our innovative Industrial Training Program.
Read More →
Our instructor-led training classes are designed to make you an expert.
Read More →
Real-life case studies are a great way to demonstrate your practical knowledge.
Read More →
Explore blogs, latest technologies and industry updates with practical examples.
Read More →Browse all available training programs and choose the right one for your career.
Read More →Know more about who we are and what we stand for.
Discover our mission to equip individuals with essential IT skills and industry expertise.
Read More →
Free tutorials, interview questions, tools and calculators to help you learn.
Explore →Learn, practice and plan your career — bilkul free.
Book a free video counselling session and pick the right course for you.
Read More →A recommender system predicts which items a person is likely to want next, from products and films to songs, courses or news, using their past behaviour and the behaviour of similar people. This page explains the main types, builds a tiny one in Python and covers how they are evaluated.

A recommender system is a model that ranks items for a user by predicting how much that user will like each one. "Customers who bought this also bought", the "Up next" queue on YouTube, a playlist made for you, suggested connections on LinkedIn: all of these are recommenders. In data science terms, the task is to fill in the blanks of a huge, mostly empty table of users × items, then show each user the items with the highest predicted scores.
| Type | Idea | Strength | Weakness |
|---|---|---|---|
| Content-based | Recommend items similar to what the user liked, using item features | Works for new items; easy to explain | Recommends more of the same |
| User-based collaborative filtering | Find users with similar taste, recommend what they liked | No item features needed | Slow with many users; tastes drift |
| Item-based collaborative filtering | Items liked by the same people are similar; recommend neighbours of liked items | Stable, scales well, explainable | Cold start for new items |
| Matrix factorisation | Learn hidden "taste" factors for users and items from the rating matrix | Accurate on sparse data | Factors are hard to interpret |
| Deep learning and sequence models | Neural networks over user histories, text and images | Captures complex patterns and order of actions | Needs a lot of data and compute |
| Hybrid | Combine several of the above | Covers each method's gaps | More complex to build and maintain |
Matrix factorisation became well known through the Netflix Prize (2006–2009), a public competition to improve Netflix's rating predictions, where factor models were central to the winning solutions. Large platforms today usually run hybrids: a fast candidate-generation step picks a few hundred items from millions, then a ranking model orders them.
Four users have rated a few films from 1 to 5. Two films are similar if the same people rate them in a similar way, measured with cosine similarity. To predict Asha's rating for a film she has not seen, we take a similarity-weighted average of her ratings for the films she has seen.
from math import sqrt
ratings = {
"Asha": {"Dangal": 5, "3 Idiots": 4, "Drishyam": 1},
"Ravi": {"Dangal": 4, "3 Idiots": 5, "Kahaani": 2},
"Meena": {"Drishyam": 5, "Kahaani": 4, "Andhadhun": 5},
"Kabir": {"3 Idiots": 4, "Dangal": 5, "Andhadhun": 2},
}
def item_vectors(ratings):
items = {}
for user, r in ratings.items():
for item, score in r.items():
items.setdefault(item, {})[user] = score
return items
def cosine(a, b):
common = set(a) & set(b)
if not common:
return 0.0
dot = sum(a[u] * b[u] for u in common)
return dot / (sqrt(sum(v * v for v in a.values())) * sqrt(sum(v * v for v in b.values())))
def recommend(user, ratings, top_n=2):
items = item_vectors(ratings)
seen = ratings[user]
scores = {}
for candidate in items:
if candidate in seen:
continue
sims = [(cosine(items[candidate], items[s]), r) for s, r in seen.items()]
total = sum(sim for sim, _ in sims)
if total > 0:
scores[candidate] = sum(sim * r for sim, r in sims) / total
return sorted(scores.items(), key=lambda kv: kv[1], reverse=True)[:top_n]
for name, score in recommend("Asha", ratings):
print(f"{name}: predicted rating {score:.2f}")
Output:
Kahaani: predicted rating 2.27
Andhadhun: predicted rating 2.13
Both predictions are low, and that is the right answer for this data. Asha loved the two feel-good dramas and disliked the thriller Drishyam. Kahaani and Andhadhun are mostly liked by Meena, who also loved Drishyam, so they sit closer to the film Asha rated 1. A real system would rank these two below anything with a higher prediction and, with so little data, might fall back to popular items instead. With four users the numbers are noisy; the method becomes reliable with thousands of users. In practice you would use libraries such as scikit-learn for similarity, implicit or Surprise for collaborative filtering, or a deep learning framework for large-scale models.
Split data by time (train on earlier interactions, test on later ones), not randomly, or the model sees the future.
An A/B test compares the new recommender with the current one on business metrics: click-through rate, purchases, watch time, retention. A model that wins offline does not always win online, so the A/B test has the final say.
Recommendations are one of the main ways analytics lifts order value; how businesses use analytics to improve revenue places them among the other levers.
Current work focuses on sequence models that treat a user's history like a sentence, using transformer architectures; on large language models that can recommend from natural-language requests ("a light comedy under two hours for the family"); and on better ways to balance relevance with diversity and fairness. To build one yourself, a news recommender with Python and NLP is a good next project, and personalised content in apps covers the product side.
Mostly, yes. Simple versions use similarity calculations, as in the example above; larger ones use matrix factorisation or neural networks trained on interaction data.
Item-based collaborative filtering and a content-based model on a public dataset such as MovieLens. Then try matrix factorisation and compare precision@k.
The system cannot recommend well for a new user or a new item because there is no interaction history yet. Content features and popularity-based defaults are the usual fixes.
Uncodemy's Data Science course covers recommendation models as part of its machine learning modules.