{"id":19267014,"url":"https://github.com/mljs/fcnnls","last_synced_at":"2025-04-21T19:32:30.602Z","repository":{"id":43402684,"uuid":"201298257","full_name":"mljs/fcnnls","owner":"mljs","description":"Fast Combinatorial Non-negative Least Squares","archived":false,"fork":false,"pushed_at":"2024-10-14T14:29:19.000Z","size":1458,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-11T10:59:35.326Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mljs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-08T16:38:06.000Z","updated_at":"2024-10-14T14:30:59.000Z","dependencies_parsed_at":"2024-06-18T22:53:18.921Z","dependency_job_id":"077e8507-f13a-4a25-a13a-41310ff3bc87","html_url":"https://github.com/mljs/fcnnls","commit_stats":{"total_commits":61,"total_committers":9,"mean_commits":6.777777777777778,"dds":0.6557377049180328,"last_synced_commit":"ffcfd95ddaab02775af76d79a8f5b78a10f809ea"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Ffcnnls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Ffcnnls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Ffcnnls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Ffcnnls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/fcnnls/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249352809,"owners_count":21255937,"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":["hacktoberfest"],"created_at":"2024-11-09T20:09:22.431Z","updated_at":"2025-04-21T19:32:30.596Z","avatar_url":"https://github.com/mljs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fcnnls\n\n[![NPM version][npm-image]][npm-url]\n[![build status][ci-image]][ci-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8189402.svg)](https://doi.org/10.5281/zenodo.8189402)\n\nFast Combinatorial Non-negative Least Squares.\n\nAs described in the publication by Van Benthem and Keenan ([10.1002/cem.889](http://doi.org/10.1002/cem.889)), which is in turn based on the active-set method algorithm previously published by Lawson and Hanson. The basic active-set method is implemented in the [nnls repository.](https://github.com/mljs/nnls)\n\nGiven the matrices $\\mathbf{X}$ and $\\mathbf{Y}$, the code finds the matrix $\\mathbf{K}$ that minimises the squared Frobenius norm $$\\mathrm{argmin}_K ||\\mathbf{XK} -\\mathbf{Y}||^2_F$$ subject to $\\mathbf{K}\\geq 0$.\n\nhttps://en.wikipedia.org/wiki/Non-negative_least_squares\n\n## Installation\n\n```bash\nnpm i ml-fcnnls\n```\n\n## Usage Example\n\n1. Single $y$, using arrays as inputs.\n\n```js\nimport { fcnnlsVector } from 'ml-fcnnls';\n\nconst X = [\n  [1, 1, 2],\n  [10, 11, -9],\n  [-1, 0, 0],\n  [-5, 6, -7],\n];\nconst y = [-1, 11, 0, 1];\n\nconst k = fcnnlsVector(X, y).K.to1DArray();\n/* k = [0.4610, 0.5611, 0] */\n```\n\n2. Multiple RHS, using `Matrix` instances as inputs.\n\n```js\nimport { fcnnls } from 'ml-fcnnls';\nimport { Matrix } from 'ml-matrix'; //npm i ml-matrix\n\n// Example with multiple RHS\n\nconst X = new Matrix([\n  [1, 1, 2],\n  [10, 11, -9],\n  [-1, 0, 0],\n  [-5, 6, -7],\n]);\n\n// Y can either be a Matrix or an array of arrays\nconst Y = new Matrix([\n  [-1, 0, 0, 9],\n  [11, -20, 103, 5],\n  [0, 0, 0, 0],\n  [1, 2, 3, 4],\n]);\n\nconst K = fcnnls(X, Y).K;\n// `K.to2DArray()` converts the matrix to array.\n/*\nK = Matrix([\n  [0.4610, 0, 4.9714, 0],\n  [0.5611, 0, 4.7362, 2.2404],\n  [0, 1.2388, 0, 1.9136],\n])\n*/\n```\n\n3. Using the options\n\n```js\nconst K = fcnnls(X, Y, {\n  info: true, // returns the error/iteration.\n  maxIterations: 5,\n  gradientTolerance: 0,\n});\n/* same result than 2*/\n```\n\n## [API Documentation](https://mljs.github.io/fcnnls/)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-fcnnls.svg\n[npm-url]: https://www.npmjs.com/package/ml-fcnnls\n[ci-image]: https://github.com/mljs/fcnnls/workflows/Node.js%20CI/badge.svg?branch=main\n[ci-url]: https://github.com/mljs/fcnnls/actions?query=workflow%3A%22Node.js+CI%22\n[codecov-image]: https://img.shields.io/codecov/c/github/mljs/fcnnls.svg\n[codecov-url]: https://codecov.io/gh/mljs/fcnnls\n[download-image]: https://img.shields.io/npm/dm/ml-fcnnls.svg\n[download-url]: https://www.npmjs.com/package/ml-fcnnls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Ffcnnls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Ffcnnls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Ffcnnls/lists"}