npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@asymmetrik/akin

v0.2.4

Published

Recommendation Engine based on Collaborative Filtering

Downloads

30

Readme

@asymmetrik/akin

Build Status Code Climate Test Coverage standard-readme compliant

Recommendation Engine Library based on Collaborative Filtering. Node.js implementation using MongoDB via Mongoose.

Provides hooks for logging user activity on items referenced by an ObjectID and an optional item type. Additional methods provide execution of a scalable, collaborative filtering algorithm that outputs recommendation results for each user into a namespaced Mongo collections. These results can then be retrieved and integrated into the application as desired.

Table of Contents

Install

Include this module as a dependency of your application in the package.json file. It also requires that MongooseJS is available as a peer dependency. For example:

{
  ...
  dependencies: {
    "mongoose": "~4.6",
    "@asymmetrik/akin": "latest"
  }
  ...
}

Usage

Include the module via require wherever applicable:

var akin = require('@asymmetrik/akin');

The most fundamental use case of logging user activity, running the engine, and retrieving recommendations for a user is achieved via:

akin.activity.log(userId, itemId, { type: 'itemType' }, 'action');
...
akin.run();
...
akin.recommendation.getAllRecommendationsForUser(userId);

There are four classes that allow for managing activity logs and recalculating recommendations at a more granular level:

akin.model

Manages query execution for schemas

akin.activity

  1. Manage (add or remove) a user's activity for any item.
  2. Calculates the first phase of the recommendation engine: user's weighted scores on items

akin.similarity

  1. Calculates the second phase of the recommendation engine: user's similarity to other users

akin.recommendation

  1. Calculates the third and final phase of the recommendation engine: collaborative filtering to generate recommendations
  2. Allows for retrieval of all or a weighted random sample of recommendations
  3. Marking items as do not recommend for a user to stop them from returning in the sampling query

API

recalculate all recommendations

Execute the recommendation engine based on the data supplied to the activity.log() API

akin.run();

activity

Add a user's activity on an item

akin.activity.log(userId, itemId, { type: 'itemType' }, 'actionType');

Remove a user's activity on an item

akin.activity.removeLog(userId, itemId, 'actionType');

retrieve recommendations

Get all recommendations created for a user

akin.recommendation.getAllRecommendationsForUser(userId);

Get a sampling of recommendations created for a user based on a weighted cumulative distribution function

akin.recommendation.sampleRecommendationsForUser(userId, numberOfSamples);

Contribute

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

@asymmetrik/akin is MIT licensed.