Matrix Factorization JS Usage Example

node v8.17.0
version: 1.0.0
endpointsharetweet
const { factorizeMatrix, fillMatrix, dot, transpose } = require('matrix-factorization') // Number of latent features to extract const LATENT_FEATURES_COUNT = 5 // Recommendations table -- 0 stands for no recommendation yet const RECOMMENDATIONS = [ [5,3,0,1], [4,0,0,1], [1,1,0,5], [1,0,0,4], [0,1,5,4], ] // Extracts two factor matrices from the recommendations table const [FACTOR1, FACTOR2] = factorizeMatrix(RECOMMENDATIONS, LATENT_FEATURES_COUNT) // Get the dot product of the two factor matrices to get the completed recommendations table const COMPLETED_RECOMMENDATIONS = dot(FACTOR1, transpose(FACTOR2)) // Print completed recommendations table to console console.log(COMPLETED_RECOMMENDATIONS)
Loading…

no comments

    sign in to comment