matrix-factorization
v2.0.0
Published
A matrix factorization implementation written in JavaScript.
Downloads
27
Maintainers
Readme
Matrix Factorization JS
A matrix factorization implementation in Javascript. This is a Work in Progress. Use at your own risk.
To try an interactive example, clone and edit this Runkit Notebook.
Installing / Getting started
Install using npm
:
npm install matrix-factorization
Import in code
// Node, ES5
var matrixFactorization = require('matrix-factorization')
// Node, ES6
const matrixFactorization = require('matrix-factorization')
Install using yarn
:
yarn add matrix-factorization
Import in code
// Node, ES5
var matrixFactorization = require('matrix-factorization')
// Node, ES6
const matrixFactorization = require('matrix-factorization')
Install with minified library
Copy matrix-factorization.min.js
from dist/matrix-factorization.min.js
to a lib
folder.
Import in code
<script src="lib/matrix-factorization.min.js"></script>
This will expose a matrixFactorization
variable which you can access the functions from.
Include using CDN
<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.min.js"></script>
This will expose a matrixFactorization
variable which you can access the functions from.
Using a function in the library:
Just reference a function using the dot notation. For example, to use the sum function, you can do:
matrixFactorization.factorizeMatrix(targetMatrix, numberOfLatentFactors)
Example
var factors = factorizeMatrix(targetMatrix, numberOfLatentFactors)
var completeMatrix = matrixFactorization.dot(factors[0], matrixFactorization.transpose(factors[1]))
Roadmap
- Create demo app.
- Improve docs.
Notes
Implementation based on this article by @albertauyeung.
License
MIT