{"id":15646611,"url":"https://github.com/ankane/disco-node","last_synced_at":"2026-03-10T02:04:25.503Z","repository":{"id":193947599,"uuid":"689774848","full_name":"ankane/disco-node","owner":"ankane","description":"Recommendations for Node.js using collaborative filtering","archived":false,"fork":false,"pushed_at":"2025-12-31T20:38:31.000Z","size":21,"stargazers_count":57,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-17T19:48:45.402Z","etag":null,"topics":["recommendation-engine","recommender-system"],"latest_commit_sha":null,"homepage":"","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/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-10T21:18:24.000Z","updated_at":"2025-12-31T20:38:34.000Z","dependencies_parsed_at":"2023-09-10T23:38:27.118Z","dependency_job_id":"e5becebd-4dab-471c-95be-82d9cb9a5312","html_url":"https://github.com/ankane/disco-node","commit_stats":null,"previous_names":["ankane/disco-node"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/disco-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdisco-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdisco-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdisco-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdisco-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/disco-node/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdisco-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30322638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T01:36:58.598Z","status":"online","status_checked_at":"2026-03-10T02:00:06.579Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["recommendation-engine","recommender-system"],"created_at":"2024-10-03T12:13:28.018Z","updated_at":"2026-03-10T02:04:20.494Z","avatar_url":"https://github.com/ankane.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Disco Node\n\n:fire: Recommendations for Node.js using collaborative filtering\n\n- Supports user-based and item-based recommendations\n- Works with explicit and implicit feedback\n- Uses high-performance matrix factorization\n\n[![Build Status](https://github.com/ankane/disco-node/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/disco-node/actions)\n\n## Installation\n\nRun:\n\n```sh\nnpm install disco-rec\n```\n\n## Getting Started\n\nCreate a recommender\n\n```javascript\nimport { Recommender } from 'disco-rec';\n\nconst recommender = new Recommender();\n```\n\nIf users rate items directly, this is known as explicit feedback. Fit the recommender with:\n\n```javascript\nrecommender.fit([\n  {userId: 1, itemId: 1, rating: 5},\n  {userId: 2, itemId: 1, rating: 3}\n]);\n```\n\n\u003e IDs can be integers or strings\n\nIf users don’t rate items directly (for instance, they’re purchasing items or reading posts), this is known as implicit feedback. Leave out the rating.\n\n```javascript\nrecommender.fit([\n  {userId: 1, itemId: 1},\n  {userId: 2, itemId: 1}\n]);\n```\n\n\u003e Each `userId`/`itemId` combination should only appear once\n\nGet user-based recommendations - “users like you also liked”\n\n```javascript\nrecommender.userRecs(userId);\n```\n\nGet item-based recommendations - “users who liked this item also liked”\n\n```javascript\nrecommender.itemRecs(itemId);\n```\n\nUse the `count` option to specify the number of recommendations (default is 5)\n\n```javascript\nrecommender.userRecs(userId, 3);\n```\n\nGet predicted ratings for specific users and items\n\n```javascript\nrecommender.predict([{userId: 1, itemId: 2}, {userId: 2, itemId: 4}]);\n```\n\nGet similar users\n\n```javascript\nrecommender.similarUsers(userId);\n```\n\n## Examples\n\n### MovieLens\n\nLoad the data\n\n```javascript\nimport { loadMovieLens } from 'disco-rec';\n\nconst data = await loadMovieLens();\n```\n\nCreate a recommender and get similar movies\n\n```javascript\nconst recommender = new Recommender({factors: 20});\nrecommender.fit(data);\nrecommender.itemRecs('Star Wars (1977)');\n```\n\n## Storing Recommendations\n\nSave recommendations to your database.\n\nAlternatively, you can store only the factors and use a library like [pgvector-node](https://github.com/ankane/pgvector-node). See an [example](https://github.com/pgvector/pgvector-node/blob/master/examples/disco/example.js).\n\n## Algorithms\n\nDisco uses high-performance matrix factorization.\n\n- For explicit feedback, it uses [stochastic gradient descent](https://www.csie.ntu.edu.tw/~cjlin/papers/libmf/libmf_journal.pdf)\n- For implicit feedback, it uses [coordinate descent](https://www.csie.ntu.edu.tw/~cjlin/papers/one-class-mf/biased-mf-sdm-with-supp.pdf)\n\nSpecify the number of factors and epochs\n\n```javascript\nnew Recommender({factors: 8, epochs: 20});\n```\n\nIf recommendations look off, trying changing `factors`. The default is 8, but 3 could be good for some applications and 300 good for others.\n\n## Validation\n\nPass a validation set with:\n\n```javascript\nrecommender.fit(data, validationSet);\n```\n\n## Cold Start\n\nCollaborative filtering suffers from the [cold start problem](https://en.wikipedia.org/wiki/Cold_start_(recommender_systems)). It’s unable to make good recommendations without data on a user or item, which is problematic for new users and items.\n\n```javascript\nrecommender.userRecs(newUserId); // returns empty array\n```\n\nThere are a number of ways to deal with this, but here are some common ones:\n\n- For user-based recommendations, show new users the most popular items\n- For item-based recommendations, make content-based recommendations\n\n## Reference\n\nGet ids\n\n```javascript\nrecommender.userIds();\nrecommender.itemIds();\n```\n\nGet the global mean\n\n```javascript\nrecommender.globalMean();\n```\n\nGet factors\n\n```javascript\nrecommender.userFactors(userId);\nrecommender.itemFactors(itemId);\n```\n\n## Credits\n\nThanks to [LIBMF](https://github.com/cjlin1/libmf) for providing high performance matrix factorization\n\n## History\n\nView the [changelog](https://github.com/ankane/disco-node/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/disco-node/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/disco-node/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development:\n\n```sh\ngit clone https://github.com/ankane/disco-node.git\ncd disco-node\nnpm install\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fdisco-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Fdisco-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fdisco-node/lists"}