https://github.com/mljs/nmf
Non-negative Matrix Factorization (NMF)
https://github.com/mljs/nmf
Last synced: 9 months ago
JSON representation
Non-negative Matrix Factorization (NMF)
- Host: GitHub
- URL: https://github.com/mljs/nmf
- Owner: mljs
- License: mit
- Created: 2017-07-17T11:52:40.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T10:18:51.000Z (over 3 years ago)
- Last Synced: 2025-04-01T15:41:55.527Z (about 1 year ago)
- Language: JavaScript
- Size: 915 KB
- Stars: 3
- Watchers: 8
- Forks: 2
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Non-negative Matrix Factorization (NMF)
=======================================
Implementation of the projected gradient methods for NMF. [Wikipedia](https://en.wikipedia.org/wiki/Non-negative_matrix_factorization)
Usage
=====
```js
const NMF = require('../src');
const {Matrix} = require("ml-matrix");
let w = new Matrix([[1,2,3],[4,5,6]]);
let h = new Matrix([[1,2],[3,4],[5,6]]);
let winit = new Matrix([[1,1,3],[4,5,6]]);
let hinit = new Matrix([[1,1],[3,4],[5,6]]);
let v = w.mmul(h);
const options = {
Winit: winit,
Hinit: hinit,
tol: 0.001,
maxIter: 10
}
let result = NMF.nmf(v, options);
let w0 = result.W;
let h0 = result.H;
console.log('W computed :', w0);
console.log('H computed :', h0);
console.log('W*H :', w0.mmul(h0));
console.log('expected :', v);
```
References
==========
- C.-J. Lin. Projected gradient methods for non-negative matrix factorization. Neural Computation, 19(2007), 2756-2779.
- WebAssembly implementation: https://github.com/firmenich/NNLSjs