Last checked
A recommendation feed scores items for you using three ideas: what people like you chose (collaborative filtering), what the item is like (content-based matching), and how you react (engagement signals). It then ranks the highest scores first, and learns from whatever you do next.
McTaba runs coding and data bootcamps in Kenya. This guide is written to be useful whether or not you ever join one.
Picture a matatu stage at 6 PM. Fifty touts shout fifty destinations. You listen to one, the one you need. A feed has the same job for millions of videos or thousands of products: pick the few you will care about, fast.
The job has two steps. First, narrow millions of items to a few hundred candidates. Second, score the candidates and sort them. The three ideas below decide the scores. If you are weighing recommenders as a career area, our data science career map for Kenya shows how they fit among other roles.
| Idea | It asks | It needs |
|---|---|---|
| Collaborative filtering | What did people like you choose? | Many users and their history |
| Content-based | What is this item like? | Descriptions of items |
| Engagement signals | How did you react just now? | Likes, watch time, skips, purchases |
If you want to build a recommender yourself, the Data Science to AI Engineering programme covers clustering, online learning and bandits, which are the methods that sit behind live feeds.
This idea ignores what an item is. It only looks at who chose it. For example, imagine a Jumia-style online shop with four made-up customers and the items they bought:
Now Daudi opens the shop. What do we show him? Look for the other customers who share his blender. Amina and Brian bought a blender too. Between them they also bought a kettle (both) and an iron (Amina). The kettle appears twice among his neighbours, the iron once. So the kettle ranks first.
Real systems do this on millions of rows, usually by comparing items. In 2003, Amazon engineers described exactly that: item B is related to item A if people who buy A are more likely to buy B than the average customer (Linden, Smith and York, IEEE Internet Computing, checked on 3 November 2026).
The weakness is the cold start. A new product with no buyers has no neighbours. A new user with no history is anonymous. Both need another idea.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
This idea reads the item itself. A shop gives each product tags: category, brand, price band, colour. A video app reads the caption, sound and hashtags. Then it recommends items whose tags overlap with what you chose before.
For example, imagine you just bought a 2-litre electric kettle with tags "kitchen, appliance, 2 litres, stainless". A new toaster tagged "kitchen, appliance, stainless" overlaps on three tags out of four. A school bag overlaps on none. The toaster scores higher.
A common way to score the overlap is to turn the tags into a list of numbers and measure the angle between two lists, called cosine similarity. You do not need the formula to grasp it: more shared tags means a smaller angle and a higher score.
This fixes the cold start for new items, because a new toaster has tags on day one. Its weakness is sameness. If you buy one kettle, you see kettles for a month. Systems add variety on purpose to avoid it.
Platforms learn from what you do, not only from what you say. TikTok's own explanation lists three kinds of input: user interactions such as the videos you like or share and accounts you follow; video information such as captions, sounds and hashtags; and device and account settings such as language, country and device type, which it says receive lower weight (TikTok Newsroom, checked on 3 November 2026). The same page says follower count is not a direct factor in the recommendation.
The idea in the engagement row is a ranking of strengths. A purchase tells a shop more than a click. A video watched to the end tells an app more than a quick scroll past. Think of it as weighing evidence, the same as a loan officer trusts a repaid loan more than a promise.
Platforms do not publish their exact weights. Treat any blog post that claims to know the secret formula with suspicion. What you can learn from their own pages is the kinds of signals, not the numbers.
You can try collaborative filtering in about fifteen lines. This code uses the four made-up customers above.
from collections import Counter
baskets = {
"Amina": {"kettle", "blender", "iron"},
"Brian": {"kettle", "blender"},
"Cheptoo": {"kettle", "iron"},
"Daudi": {"blender"},
}
def recommend(user):
mine = baskets[user]
scores = Counter()
for other, items in baskets.items():
if other == user:
continue
overlap = len(mine & items) # shared items
if overlap == 0:
continue
for item in items - mine: # things I do not own yet
scores[item] += overlap
return scores.most_common()
print(recommend("Daudi")) # [('kettle', 2), ('iron', 1)]
Read it slowly. Each other customer votes for the items you lack, and the vote is stronger when you share more items. That is a working, if crude, recommender.
To go further, load a made-up table with pandas as in our first 30 days of Python, and try the same idea on a larger file. Then ask how you would test whether the recommendations help. That is an A/B test, covered in the statistics you actually need for data science.
The names change, the shape does not. Candidates come from neighbours or from item descriptions, scores come from your behaviour, and a ranker sorts them. Production systems blend all three, add rules for variety, and watch for drift as tastes change.
For another worked model, see a machine learning example on a matatu route. To place recommenders in the wider field, read AI versus machine learning versus data science.
No school can promise you a job in this area. Recommenders are one branch of a wider skill set, and you can learn the base on free tools first. The Data Science to AI Engineering programme starts on 11 January 2027 and costs KES 140,000, if you prefer a class.
KES 140,000
Data Science to AI Engineering: 5 months full time or 8 months part time, hybrid in Nairobi. Fraud, credit and M-Pesa data from Week 1, and every model deployed. Starts 11 January 2027.
See the Data Science programme