Class MatrixFactorization

java.lang.Object
org.dulab.javanmf.algorithms.MatrixFactorization

public class MatrixFactorization
extends java.lang.Object
This class performs non-negative matrix factorization: for given matrix X, find matrices W and H that minimize the objective function

  D(X, WH) + λw||W||1 + λh||H||1 + 0.5 μw||W||2 + 0.5 μh||H||2

where D(X, WH) is either the euclidean distance or the Kullback-Leibler divergence, ||·|| is the Frobenius norm, and ||·||1 is the l1-norm.

Example for given matrix matrixX, matrices matrixW and matrixH are modified to minimize the euclidean distance with regularization.

 
     UpdateRule updateRuleW = new MUpdateRule(1.0, 0.0);
     UpdateRule updateRuleH = new MUpdateRule(0.0, 1.0);

     MatrixFactorization factorization = new MatrixFactorization(
         updateRuleW, updateRuleH, 1e-6, 10000);

     factorization.execute(matrixX, matrixW, matrixH);
  
Author:
Du-Lab Team dulab.binf@gmail.com
  • Constructor Summary

    Constructors 
    Constructor Description
    MatrixFactorization​(UpdateRule updateRuleW, UpdateRule updateRuleH, double tolerance, int maxIteration)
    Creates an instance of MatrixFactorization
  • Method Summary

    Modifier and Type Method Description
    void execute​(org.ejml.data.DMatrixRMaj data, org.ejml.data.DMatrixRMaj w, org.ejml.data.DMatrixRMaj h)
    Performs the non-negative matrix factorization with given initial matrices W and H.
    void execute​(org.ejml.data.DMatrixRMaj data, org.ejml.data.DMatrixRMaj w, org.ejml.data.DMatrixRMaj h, boolean verbose)
    Performs the non-negative matrix factorization with given initial matrices W and H.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MatrixFactorization

      public MatrixFactorization​(@Nonnull UpdateRule updateRuleW, @Nonnull UpdateRule updateRuleH, double tolerance, int maxIteration)
      Creates an instance of MatrixFactorization
      Parameters:
      updateRuleW - instance of UpdateRule for matrix W
      updateRuleH - instance of UpdateRule for matrix H
      tolerance - the fitting error tolerance
      maxIteration - maximum number of iterations to use
  • Method Details

    • execute

      public void execute​(@Nonnull org.ejml.data.DMatrixRMaj data, @Nonnull org.ejml.data.DMatrixRMaj w, @Nonnull org.ejml.data.DMatrixRMaj h, boolean verbose)
      Performs the non-negative matrix factorization with given initial matrices W and H.

      Parameters w and h contain the result of the factorization.

      Parameters:
      data - matrix of shape [Npoints, Nvectors], a collection of vectors in Npoints-dimensional space
      w - matrix of shape [Npoints, Ncomponents], a collection of initial components
      h - matrix of shape [Ncomponents, Nvectors], a collection of initial coefficients
      verbose - flag to output verbose information
    • execute

      public void execute​(@Nonnull org.ejml.data.DMatrixRMaj data, @Nonnull org.ejml.data.DMatrixRMaj w, @Nonnull org.ejml.data.DMatrixRMaj h)
      Performs the non-negative matrix factorization with given initial matrices W and H.

      Parameters w and h contain the result of the factorization.

      Parameters:
      data - matrix of shape [Npoints, Nvectors], a collection of vectors in Npoints-dimensional space
      w - matrix of shape [Npoints, Ncomponents], a collection of initial components
      h - matrix of shape [Ncomponents, Nvectors], a collection of initial coefficients