DEV Community

Cover image for Recommendation system
Meat Boy
Meat Boy

Posted on • Updated on

Recommendation system

Overview of My Submission

Project logo

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.

Features

  • 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

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 multiple tags.
  • Events are String type with actorId:id:tag:timestamp:ttl and an expire attribute set to ensure freshness of recommendations.

How the data is accessed:

  • Get the actor with events
    • Check if the actor exists with EXISTS actor:${id}
    • Get all user events with SCAN ${loop cursor} MATCH actor:${id}
  • Delete a single actor
    • Scan for each related to actor key SCAN ${loop cursor} MATCH actor:${id}*
    • For each key delete with DEL ${key}
  • Add a single actor
    • Scan for each related to actor key SCAN ${loop cursor} MATCH actor:${id}*
    • For each key delete with DEL ${key}
    • Add new actor with SET actor:${id} ${Date.now().toString()}
  • Add a single event
    • Check if actor exists if flag is set using EXISTS actor:${id}
    • Add event with SET actor:${id}:${tag}:${date}:${ttl} ${score}
    • If TTL has been provided, set expiration for event with EXPIRE actor:${id}:${tag}:${date}:${ttl} ${ttl}
  • Get all items with tags
    • Get all items with SCAN ${loop cursor} MATCH item:*
    • For each item get all tags with SMEMBERS ${itemKey}
  • Get a single item with tags
    • Get all tags of item with SMEMBERS item:${id}
  • Delete single item
    • Call with DEL item:${id}
  • Add a single item
    • Check if item already exists EXISTS item:${id}
    • If so, then remove DEL item:${id}
    • And add item with tags SADD item:${id} ${tags}

GitHub logo pilotpirxie / recommendation

🦝 Simple and open source recommendation system

Recommendation

recommendation

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.

Features

  • 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

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…

Video - Demo of film recommendations

Submission Category:

Minimalism Magicians

Replaces time series database for high volume input of actor (e.g. user) events and OLAP operations to calculate recommendations. Have in mind the time limitation of hackathon so take this statement with a pinch of salt ;)

Language Used

TypeScript

Link to Code

https://github.com/pilotpirxie/recommendation

Additional Resources / Info

Architecture

Collaborators


Top comments (0)