#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 →

Use AI to Recommend Personalized Content in Apps

An app recommends personalised content by logging what each user does (views, plays, likes, purchases, skips), using that history to find a few hundred candidate items, ranking them with a model that predicts what the user is likely to engage with next, and then filtering the list for freshness, variety and business rules. You can start with a simple item-to-item similarity method that needs no machine learning framework, and move to trained ranking models once you have enough data.

Use AI to Recommend Personalized Content in Apps

Use AI to Recommend Personalized Content in Apps

What should a news app show Aman when he opens it at 8 a.m.? He read two cricket stories yesterday, skipped a budget explainer and has never opened the tech section. A recommender turns that history into a ranked list. The rest of this guide explains how, from the data you log to the code that produces the list.

The four layers of a recommender

LayerQuestion it answersTypical starting point
EventsWhat did the user do?Log views, clicks, watch time, likes, add-to-cart and skips, with user id, item id and timestamp
Candidate generationWhich few hundred items out of thousands are worth scoring?Similar items, trending items, items from followed creators or categories
RankingIn what order should those candidates appear?A rule-based score first; later a trained model such as gradient-boosted trees
Re-ranking and rulesIs the final list fresh, varied and allowed?Remove already-seen items, cap one creator per screen, respect age and region rules

Large platforms build each layer with dedicated teams, but the same shape works for a college events app or a small e-commerce store in Jaipur. What changes is how sophisticated each layer is.

Step 1: Log the right events

Recommendation quality is limited by data quality. Decide early on a clean event schema, for example:

{ "user_id": "u_1842", "item_id": "a_77", "event": "read",
  "seconds": 95, "ts": "2026-11-16T08:04:11+05:30", "source": "home_feed" }
  • Explicit signals (ratings, likes) are clear but rare.
  • Implicit signals (opens, watch time, purchases) are plentiful but noisy. A 3-second open is not the same as reading to the end, so record duration or completion.
  • Negative signals (skips, "not interested", quick back-presses) are valuable and often forgotten.
  • Record source, so you can later tell whether a click came from your recommendations or from search.

Tools such as Firebase Analytics, Segment or your own backend table can collect these. What matters is that item ids are consistent across the app, the website and the catalogue.

Step 2: A working item-to-item recommender

Item-to-item collaborative filtering says: "people who read this also read that". It is simple, explainable and works well with implicit data. Here is a complete example with five users and six articles, using only NumPy:

import numpy as np

# rows = users, columns = articles; 1 = the user read it
articles = ["IPL auction", "Budget 2026", "UPI tips", "Cricket stats", "Tax saving", "Phone review"]
reads = np.array([
    [1, 0, 0, 1, 0, 0],   # Aman
    [1, 0, 0, 1, 0, 1],   # Bhavna
    [0, 1, 1, 0, 1, 0],   # Chirag
    [0, 1, 0, 0, 1, 0],   # Deepa
    [1, 0, 1, 0, 0, 1],   # Esha
])

# cosine similarity between article columns
norms = np.linalg.norm(reads, axis=0)
sim = (reads.T @ reads) / np.outer(norms, norms)
np.fill_diagonal(sim, 0)

def recommend(user_row, k=2):
    scores = sim @ user_row          # add up similarity to everything the user read
    scores[user_row == 1] = -1       # never recommend what they already read
    top = np.argsort(scores)[::-1][:k]
    return [(articles[i], round(float(scores[i]), 2)) for i in top if scores[i] > 0]

new_user = np.array([0, 0, 0, 0, 1, 0])   # has read only "Tax saving"
print("Aman  ->", recommend(reads[0]))
print("Deepa ->", recommend(reads[3]))
print("New   ->", recommend(new_user))

Output:

Aman  -> [('Phone review', 1.32), ('UPI tips', 0.41)]
Deepa -> [('UPI tips', 1.0)]
New   -> [('Budget 2026', 1.0), ('UPI tips', 0.5)]

How to read it: Aman read the IPL and cricket stories. Bhavna read both of those plus the phone review, and Esha read IPL and the phone review, so "Phone review" scores highest for him. Deepa gets only one suggestion because nothing else overlaps with her history; returning nothing is better than padding the list with zero-evidence items. The new user who read one tax article is pointed to the budget story, because both readers of "Tax saving" also read "Budget 2026".

In production you would compute the similarity matrix offline (nightly or hourly), keep only the top 50 neighbours per item, and store them in a fast lookup such as Redis, so the app's API can assemble recommendations in milliseconds. A fuller walk-through with real ratings data is in this book recommendation engine tutorial.

Step 3: Move to learned models when the data supports it

  • Matrix factorisation (for example ALS on implicit data, available in the open-source implicit library or Spark MLlib) learns a small vector for each user and item; the dot product predicts interest.
  • Content-based features (category, tags, text embeddings of the title, price band, language) help with new items that have no interactions yet. For text-heavy content, see how news recommenders use NLP.
  • Two-tower neural models and learning-to-rank (TensorFlow Recommenders, LightGBM's ranking objectives) combine behaviour and features at scale.
  • Managed services such as Amazon Personalize on AWS and Google Cloud's recommendation products take your events and catalogue and return ranked lists through an API, at a usage-based cost.

The main families are explained in this overview of recommender system types.

Step 4: Solve cold start

New users have no history. Show popular or trending items in their city or language, ask two or three preference questions during onboarding, and switch to personal recommendations after a handful of interactions. New items have no interactions. Use content features to place them next to similar items, and give them a small, controlled share of impressions so they can collect data.

Step 5: Measure honestly

  • Offline: hold out each user's most recent interactions and check precision@k or recall@k (did the items they actually chose appear in your top k?).
  • Online: run an A/B test against the current feed and track the metric you care about (completed reads, repeat visits, orders), not just clicks.
  • Guardrails: watch diversity, the share of the catalogue ever recommended, and complaints. A model that only shows the same viral items can raise clicks while making the app feel stale.

Privacy and fairness

Recommendations are built from personal data. In India, the Digital Personal Data Protection Act, 2023 requires a lawful basis such as consent for processing personal data and limits its use to the stated purpose. In practice:

  • Say in plain words that the feed is personalised, and offer a non-personalised option.
  • Give users a way to remove items from their history or reset recommendations.
  • Do not infer sensitive traits (health, religion, finances) for targeting.
  • Check whether some groups of creators or sellers are systematically shown less.

The trade-offs are discussed in balancing privacy and personalisation and in this piece on privacy and bias in AI.

A practical rollout plan

  1. Ship event logging and a "popular this week" shelf.
  2. Add an item-to-item "because you viewed" shelf like the example above.
  3. Add re-ranking rules for freshness and variety.
  4. Run your first A/B test.
  5. Only then try matrix factorisation or a managed service, and compare it against the simple baseline.

The simple baseline is often hard to beat, and it is the one you can explain to your product manager. To build these skills step by step, Uncodemy's machine learning with Python course covers the underlying models.

Placed Students

Our Clients

Partners

...