Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@eyevinn/eye-recommender
Advanced tools
A simple similarity based recommendation engine and NPM module built on top of Node.js and Redis. The engine uses the Jaccard coefficient to determine the similarity between users and k-nearest neighbors to create recommendations.
npm install @eyevinn/eye-recommender
eyeRecommender keeps track of the ratings and recommendations from your users. It does not need to store any meta data of the user or product aside from an id. To get started:
npm install @eyevinn/eye-recommender
The configuration is defaulted to run against a local Redis instance. If you want to use a remote instance, you can set the following settings in your environment
const eyeRecommender = require("@eyevinn/eye-recommender");
(async () => {
await eyeRecommender.input.like("Jane", "The Holiday");
await eyeRecommender.input.like("Jane", "Love Actually");
await eyeRecommender.input.like("Jane", "The Grinch");
await eyeRecommender.input.like("Carly", "The Holiday");
await eyeRecommender.input.dislike("Carly", "The Grinch");
const recommendations = await eyeRecommender.statistics.recommendationsForUser("Carly");
console.log("Recommendations for Carly", recommendations);
})()
Outputs
Recommendations for Carly [ 'Love Actually' ]
// these are the default values but you can change them
eyeRecommender.config.nearestNeighbors = 5; // number of neighbors you want to compare a user against
eyeRecommender.config.className = 'movie'; // prefix for your items (used for redis)
eyeRecommender.config.numOfRecsStore = 30; // number of recommendations to store per user
// to set ratings
await eyeRecommender.input.like("userId", "itemId");
await eyeRecommender.input.dislike("userId", "itemId");
// to remove already set ratings
await eyeRecommender.input.unlike("userId", "itemId");
await eyeRecommender.input.undislike("userId", "itemId");
await eyeRecommender.statistics.recommendationsForUser("userId", "numberOfRecs (default 10)");
await eyeRecommender.statistics.mostSimilarUsers("userId");
await eyeRecommender.statistics.leastSimilarUsers("userId");
/**
* Item related
*/
await eyeRecommender.statistics.bestRated();
await eyeRecommender.statistics.worstRated();
await eyeRecommender.statistics.bestRatedWithScores("numberOfRatings (default 10)");
await eyeRecommender.statistics.mostLiked();
await eyeRecommender.statistics.mostDisliked();
// Get a list of users who liked a given asset
await eyeRecommender.statistics.likedBy("itemId");
// Get the amount of users who liked a given asset
await eyeRecommender.statistics.likedCount("itemId");
// Get a list of users who disliked a given asset
await eyeRecommender.statistics.dislikedBy("itemId");
// Get the amount of users who disliked a given asset
await eyeRecommender.statistics.dislikedCount("itemId");
/**
* User related
*/
// Get a list of items that the given user has liked
await eyeRecommender.statistics.allLikedForUser("userId");
// Get a list of items that the given user has disliked
await eyeRecommender.statistics.allDislikedForUser("userId");
// Get a list of items that the given user has rated
await eyeRecommender.statistics.allWatchedForUser("userId");
There are many ways to gauge the likeness of two users. The original implementation of recommendation eyeRecommender used the Pearson Coefficient which was good for measuring discrete values in a small range (i.e. 1-5 stars). However, to optimize for quicker calcuations and a simplier interface, recommendation eyeRecommender instead uses the Jaccard Coefficient which is useful for measuring binary rating data (i.e. like/dislike). Many top companies have gone this route such as Youtube because users were primarily rating things 4-5 or 1. The choice to use the Jaccard's instead of Pearson's was largely inspired by David Celis who designed Recommendable, the top recommendation engine on Rails. The Jaccard Coefficient also pairs very well with Redis which is able to union/diff sets of like/dislikes at O(N).
To deal with large user bases, it's essential to make optimizations that don't involve comparing every user against every other user. One way to deal with this is using the K-Nearest Neighbors algorithm which allows you to only compare a user against their 'nearest' neighbors. After a user's similarity is calculated with the Jaccard Coefficient, a sorted set is created which represents how similar that user is to every other. The top users from that list are considered their nearest neighbors. recommendation eyeRecommender uses a default value of 5, but this can easily be changed based on your needs.
If you've ever been to Amazon or another site with tons of reviews, you've probably ran into a sorted page of top ratings only to find some of the top items have only one review. The Wilson Score Interval at 95% calculates the chance that the 'real' fraction of positive ratings is at least x. This allows for you to leave off the items/products that have not been rated enough or have an abnormally high ratio. It's a great proxy for a 'best rated' list.
FAQs
A Recommendation Engine built on Node.js utilizing Redis
We found that @eyevinn/eye-recommender demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.