#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

What Are Recommender Systems in Data Science?

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.

What Are Recommender Systems in Data Science

What Are Recommender Systems in Data Science?

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.

The data recommenders learn from

  • Explicit feedback: star ratings, likes, thumbs up or down. Clear, but most users rarely give it.
  • Implicit feedback: clicks, views, watch time, purchases, add-to-cart, skips. Plentiful but noisy; a click is not always interest.
  • Item data: category, price, brand, text description, genre, cast.
  • User and context data: location, device, time of day, language.

The main types

TypeIdeaStrengthWeakness
Content-basedRecommend items similar to what the user liked, using item featuresWorks for new items; easy to explainRecommends more of the same
User-based collaborative filteringFind users with similar taste, recommend what they likedNo item features neededSlow with many users; tastes drift
Item-based collaborative filteringItems liked by the same people are similar; recommend neighbours of liked itemsStable, scales well, explainableCold start for new items
Matrix factorisationLearn hidden "taste" factors for users and items from the rating matrixAccurate on sparse dataFactors are hard to interpret
Deep learning and sequence modelsNeural networks over user histories, text and imagesCaptures complex patterns and order of actionsNeeds a lot of data and compute
HybridCombine several of the aboveCovers each method's gapsMore 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.

Worked example: item-based collaborative filtering in Python

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.

How recommenders are evaluated

Offline, on historical data

  • RMSE / MAE for predicted ratings: how far predictions are from actual ratings.
  • Precision@k: of the top k items recommended, how many did the user actually interact with?
  • Recall@k: of the items the user interacted with, how many appeared in the top k?
  • NDCG: rewards putting relevant items near the top of the list.
  • Coverage and diversity: does the system recommend across the catalogue, or only the same bestsellers?

Split data by time (train on earlier interactions, test on later ones), not randomly, or the model sees the future.

Online, with real users

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.

Where recommenders are used

  • E-commerce: related products, bundles, personalised home pages. See data science on e-commerce platforms.
  • Streaming: films, series, music and podcasts.
  • News and social feeds: ranking posts and articles; why news recommendation is hard explains the extra problems of freshness and bias.
  • Edtech: next lesson or practice question suited to a learner's level.
  • Jobs and careers: matching candidates to openings; for a project version, try a career recommendation tool.
  • Food delivery and travel: restaurants, dishes, hotels and routes based on past orders and location.

Recommendations are one of the main ways analytics lifts order value; how businesses use analytics to improve revenue places them among the other levers.

Common problems

  • Cold start: new users and new items have no history. Use content features, popular items, or a short onboarding question ("pick three genres you like").
  • Sparsity: most users interact with a tiny fraction of items, so the matrix is almost empty.
  • Popularity bias: popular items get recommended more, get more clicks, and become even more popular, burying the long tail.
  • Filter bubbles: users see only more of what they already like. Adding diversity and some exploration helps.
  • Feedback loops and fairness: the system learns from data its own recommendations shaped, which can reinforce bias, for example in job matching.
  • Privacy: behaviour data is personal; collect with consent and keep only what you need.

Where the field is going

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.

FAQs

Is a recommender system machine learning?

Mostly, yes. Simple versions use similarity calculations, as in the example above; larger ones use matrix factorisation or neural networks trained on interaction data.

Which algorithm should a beginner start with?

Item-based collaborative filtering and a content-based model on a public dataset such as MovieLens. Then try matrix factorisation and compare precision@k.

What is the cold start problem?

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.

Placed Students

Our Clients

Partners

...