{"id":23722369,"url":"https://github.com/tsonono/collaborative-filtering","last_synced_at":"2025-10-25T09:38:38.191Z","repository":{"id":49712558,"uuid":"213156470","full_name":"TSonono/collaborative-filtering","owner":"TSonono","description":"Recommendation engine based on collaborative filtering","archived":false,"fork":false,"pushed_at":"2022-12-30T19:07:24.000Z","size":130,"stargazers_count":47,"open_issues_count":10,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-21T00:08:33.444Z","etag":null,"topics":["collaborative-filtering","node-js","recommendation-engine","statistics"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/collaborative-filter","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TSonono.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-06T11:31:12.000Z","updated_at":"2024-10-21T09:40:14.000Z","dependencies_parsed_at":"2023-01-31T13:50:23.541Z","dependency_job_id":null,"html_url":"https://github.com/TSonono/collaborative-filtering","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TSonono/collaborative-filtering","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TSonono%2Fcollaborative-filtering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TSonono%2Fcollaborative-filtering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TSonono%2Fcollaborative-filtering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TSonono%2Fcollaborative-filtering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TSonono","download_url":"https://codeload.github.com/TSonono/collaborative-filtering/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TSonono%2Fcollaborative-filtering/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261039156,"owners_count":23100978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborative-filtering","node-js","recommendation-engine","statistics"],"created_at":"2024-12-30T23:35:46.168Z","updated_at":"2025-10-25T09:38:38.186Z","avatar_url":"https://github.com/TSonono.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/TSonono/collaborative-filtering.svg?branch=master)](https://travis-ci.com/TSonono/collaborative-filtering)\n[![Coverage](https://codecov.io/gh/TSonono/collaborative-filtering/branch/master/graph/badge.svg)](https://codecov.io/gh/TSonono/collaborative-filtering)\n[![Dependencies](https://david-dm.org/TSonono/collaborative-filtering.svg)](https://david-dm.org/TSonono/collaborative-filtering)\n[![npm version](https://badge.fury.io/js/collaborative-filter.svg)](https://www.npmjs.com/package/collaborative-filter)\n[![Downloads](https://img.shields.io/npm/dt/collaborative-filter)](https://npm-stat.com/charts.html?package=collaborative-filter\u0026from=2019-08-01)\n\n# Collaborative filtering for Node.js\n\n\u003e This API is a lightweight implementation of collaborative filtering for Node.js. The only dependency is [Math.js](https://www.npmjs.com/package/mathjs). Currently it supports generating recommendations with Jaccard similarity.\n\n## Features\n\n- Generate recommendations for a user based on users with a similar taste.\n- No popularity bias (normalization based on popularity).\n- Currently only supports likes (no dislikes).\n- Database agnostic. As long as you are running Node.js, you can use this API.\n\n## Requirements\n\n- [Node.js](https://nodejs.org/en/)\n\n## Install\n\n```\nnpm i collaborative-filter\n```\n\n## Usage\n\nIn your project, simply include the module.\n\n```javascript\nconst recommend = require('collaborative-filter')\n```\n\n\n## Example\nTo run the provided example.\n\n```bash\nnode examples/demo.js\n```\n\n### How-to\nThe input for the engine is an array matrix which defines the ratings of the users in the database. It should be a matrix containing of 0:s (not rated) and 1:s (liked the item) and follow this format.\n\n```\n     I0 I1 I2 . . .\n    [\nU0  [1  1  1  .  .  .],\nU1  [1  0  1  .  .  .],\nU2  [1  0  0  .  .  .],\n.   [.  .  .  .  .  .],\n.   [.  .  .  .  .  .],\n.   [.  .  .  .  .  .],\n    ]\n ```\n In javascript, this could look something like this\n ```javascript\n const ratings = [\n  [1, 1, 1],\n  [1, 0, 1],\n  [1, 0, 0],\n];\n ```\n If you want to run the whole collaborative filter, you would do this:\n ```javascript\n const recommend = require('../lib/cf_api.js');\n\n const result = recommend.cFilter(ratings, 2);\n ```\nwhere 2 is the user index. The output of this with ratings matrix as above, would be an array `[2, 1]`. This tells us that item 2 is the most appropriate recommendation followed by item 1.\n\nYou could also run the filtering process by calling the global API functions individually.\n\n```javascript\nconst recommend = require('collaborative-filter');\n\nconst coMatrix = recommend.createCoMatrix(ratings, numUsers, numItems);\nconst result = recommend.getRecommendations(ratings, coMatrix, userIndex);\n```\nwhich results in the same array as before. This could be useful when you do not need to generate the co-occurrence matrix multiple times. For instance, if you want recommendations for multiple users, you do not need to generate the co-occurrence matrix multiple times, saving you processing time.\n\n## Cold Start Problem\n\nThe [Cold start problem](https://en.wikipedia.org/wiki/Cold_start_(computing)) is something that can make or break a recommendation application. If you don't have enough data, it's hard to draw any conclusions, especially if the number of items is large.\n\nIn the file `cf_api.js` in the `lib` directory, there is a flag `ONLY_RECOMMEND_FROM_SIMILAR_TASTE`. If you put this to 0, you will get recommendations from users which don't necessarily have similar taste as you (these will however be lower ranked than recommendations from people with similar taste). This option is available if you consider a cold start something that will make your service seem poor. With this flag enabled, you will never receive a recommendation from someone who has no similarity with you.\n\nYou can also disable the `NORMALIZE_ON_POPULARITY` flag, which in turn ensures that the co-occurrence matrix is not normalized.\n\n## Contributing\n\nSubmit a pull request if you want to contribute. We follow the Airbnb JavaScript Style Guide.\n\n# Todo\n- Rating scale options and implementations\n- Performance benchmarks\n- Convert to typescript?\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsonono%2Fcollaborative-filtering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsonono%2Fcollaborative-filtering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsonono%2Fcollaborative-filtering/lists"}