DEV Community

Cover image for Recommendation system #4 - Algorithm and final results
Meat Boy
Meat Boy

Posted on • Updated on

Recommendation system #4 - Algorithm and final results

In the previous post we looked closer at the algorithm and connection between Redis and Node. Today, quickly I summarize how the recommendation is made.

A single recommendation is an overlap between item tags and actor tag-event interactions.

For example items:
Titanic has tags: drama, tragedy, history, action.
Merlin has tags: adventure, fantasy, history, wizards.
Harry Potter has tags: adventure, fantasy, action, wizards.

Actor - user - previously could interact with some films:
Liked a film with tags: action, fantasy
Add to favourite film with tags: action, fantasy
Liked a film with tags: history, action, comedy
Liked a film with tags: adventure, fantasy, dragons
Liked a film with tags: wizards, history, action
Add to favourite film with tags: drama, wizards, fantasy

Now let's say, each like is a weight of 1 and each favourite is a weight of 3. The Sum of overlap (with or without duplication, with or without clamp to 1) divided by the maximum value per film is our overlap. And the higher it is, the stronger recommendation is.

Example with duplication

To make sure tags are still relevant, they have an expiration time. So as the interest may change, they expire and will be replaced with new tags. In this approach is also worth to notice the more keywords items have, the more suggestion is precise.

Demo of film recommendations with 10,000 videos

And the source code:

GitHub logo pilotpirxie / recommendation

🦝 Simple and open source recommendation system



Open source recommendation system based on time-series data and statistical analysis. Written in TypeScript and Node.js using Redis for storage. The recommendation system uses the Jaccard index to calculate the intersection between two sets. One set is represented by the maximum possible sum of tag score and the other set is the score sum of user events per tag. The higher the Jaccard index, the higher the recommendation. It uses numbers to represent sets to increase performance.


  • Use tag score and Jaccard index
  • Content-based filtering
  • Event-driven powered engine
  • Naive exploration of new tags
  • Suitable for product and content recommendation
  • Fine-tuning of tag weights
  • Minimalist and lightweight
  • Written in TypeScript and Node.js

Recommendation Architecture

Overview video


How it works

How the data is stored:

  • Actors are stored in Redis as simple String keys with create date timestamps as value.
  • Items are Set type with tags as members. The item may have…

That was the last post about my Redis Hackathon journey. It was fun to participate and learn more about the technical aspects of Redis. Also, the hackathon allowed me to stay focused and finish another side project! What a wonderful event! ;)

Top comments (0)