py_nnma Package

py_nnma Package

Routines for nonnegative matrix approximation (nnma)

nnma Module

py_nnma: python modules for nonnegative matrix approximation (NNMA)

  1. 2009 Uwe Schmitt, uschmitt@mineway.de

NNMA minimizes dist(Y, A X)

where: Y >= 0, m x n

A >= 0, m x k X >= 0, n x k

k < min(m,n)

dist(A,B) can be || A - B ||_fro
or KL(A,B)

This moudule provides the following functions:

NMF, NMFKL, SNMF, RRI, ALS, GDCLS, GDCLS_L1, FNMAI, FNMAI_SPARSE, NNSC and FastHALS

The common parameters when calling such a function are:

input:

Y – the matrix for decomposition, maybe dense
from numpy or sparse from scipy.sparse package

k – number of componnets to estimate

Astart Xstart – matrices to start iterations. Maybe None

for using random start matrices.

eps – termination swell value

maxcount – max number of iterations to be performed

verbose – if False: produce no output durint interations
if integer: give all ‘verbose’ itetations some output about current state of iterations

output:

A, X – result matrices of algorithm

obj – value of objective function of last iteration

count – number of iterations done

converged – flag: indicates if iterations stoped within
max number of iterations

The following extra parameters exist depending on algorithm:

RRI : damping parameter ‘psi’ (default: 1e-12)

SNMF : sparsity parameter ‘sparse_par’ (default: 0)

ALS : regularization parameter ‘regul’ for stabilizing iterations
(default value 0). needed if objective value jitters.

GCDLS : ‘regul’ for l2-smoothness of X (default 0)

GDCLS_L1 : ‘regul’ for l1-smoothness of X (default 0)

FNMAI : ‘stabil’ for stabilizing algorithm (default value 1e-12)
‘alpha’ for stepsize (default value 0.1) ‘tau’ for number of inner iterations (default value 2)
FNMAI_SPARSE : as FNMAI plus
‘regul’ for l1-smoothness of X (default 0)
NNSC : ‘alpha’ for stepsize of gradient update of A
‘sparse_par’ for sparsity

Copyright (c) 2009 Uwe Schmitt, uschmitt@mineway.de

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright
  • notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above
  • copyright notice, this list of conditions and the following
  • disclaimer in the documentation and/or other materials provided
  • with the distribution. Neither the name of the <ORGANIZATION>
  • nor the names of its contributors may be used to endorse or
  • promote products derived from this software without specific
  • prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This module is based on:

  • Daniel D. Lee and H. Sebastian Seung:

    “Algorithms for non-negative matrix factorization”, in Advances in Neural Information Processing 13 (Proc. NIPS*2000) MIT Press, 2001.

    “Learning the parts of objects by non-negative matrix

    factorization”,

    Nature, vol. 401, no. 6755, pp. 788-791, 1999.

    1. Cichocki and A-H. Phan:

      “Fast local algorithms for large scale Nonnegative Matrix and

      Tensor Factorizations”,

      IEICE Transaction on Fundamentals, in print March 2009.

      1. Hoyer
      “Non-negative Matrix Factorization with sparseness

      constraints”,

      Journal of Machine Learning Research, vol. 5, pp. 1457-1469, 2004.

  • Dongmin Kim, Suvrit Sra,Inderjit S. Dhillon:

    “Fast Newton-type Methods for the Least Squares Nonnegative Matrix Approximation Problem” SIAM Data Mining (SDM), Apr. 2007

  • Ngoc-Diep Ho:

PyMca5.PyMcaMath.mva.py_nnma.nnma.A_inexact_lsq_update(Y, YT, A, X, **param)[source]

ALS fixed point update

PyMca5.PyMcaMath.mva.py_nnma.nnma.A_mult_update(Y, YT, A, X, **param)[source]

Lee and Sung multiplicative update

PyMca5.PyMcaMath.mva.py_nnma.nnma.A_mult_update_kl_div(Y, YT, A, X, **param)[source]

update A for minimization of KL(Y || A X)

class PyMca5.PyMcaMath.mva.py_nnma.nnma.AlgorunnerTemplate[source]

Bases: object

dist(Y, A, X)

frobenius distance between Y and A X

frob_dist(Y, A, X)

frobenius distance between Y and A X

init_factors(Y, k, A=None, X=None)

generate start matrices U, V

kl_divergence(Y, A, X)

kullbach leibler divergence D(Y | A X)

param_update = None
PyMca5.PyMcaMath.mva.py_nnma.nnma.FNMAI_A_update(Y, YT, A, X, **param)[source]

FNMAI (Kim et al) update for A

PyMca5.PyMcaMath.mva.py_nnma.nnma.FNMAI_X_update(Y, YT, A, X, **param)[source]

FNMAI (Kim et al) update for V

class PyMca5.PyMcaMath.mva.py_nnma.nnma.FactorizedNNMA(update_A, update_X, param_update=None)[source]

Bases: PyMca5.PyMcaMath.mva.py_nnma.nnma.AlgorunnerTemplate

update(Y, YT, A, X, **param)
PyMca5.PyMcaMath.mva.py_nnma.nnma.FastHALS_A_update(Y, YT, A, X, **param)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.FastHALS_X_update(Y, YT, A, X, **param)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.GradA(Y, YT, A, X, **param)[source]

dPhi(Y, A, X) / dA with Phi(Y, A, X) = || Y - A X ||_fro

PyMca5.PyMcaMath.mva.py_nnma.nnma.GradA_step(Y, YT, A, X, **param)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.GradX(Y, YT, A, X, **param)[source]

dPhi(Y, A, X) / dX with Phi(Y, A, X) = || Y - A X ||_fro

PyMca5.PyMcaMath.mva.py_nnma.nnma.GradX_step(Y, YT, A, X, **param)[source]
class PyMca5.PyMcaMath.mva.py_nnma.nnma.RRI_[source]

Bases: PyMca5.PyMcaMath.mva.py_nnma.nnma.AlgorunnerTemplate

Runtime optimisations from Cichocki applied to Damped rank one residual iteration from Ngoc-Diep Ho.

update(Y, YT, A, X, **param)
class PyMca5.PyMcaMath.mva.py_nnma.nnma.SNMF_[source]

Bases: PyMca5.PyMcaMath.mva.py_nnma.nnma.AlgorunnerTemplate

W. Liu, N. Zheng, and X. Lu.: “Non-negative matrix factorization for visual coding”. In Proc. IEEE Int. Conf. on Acoustics, Speech and Signal Processing (ICASSP’2003), 2003

dist(Y, A, X)

kullbach leibler divergence D(Y | A X)

update(Y, YT, A, X, **param)
PyMca5.PyMcaMath.mva.py_nnma.nnma.X_inexact_lsq_update(Y, YT, A, X, **param)[source]

ALS fixed point update

PyMca5.PyMcaMath.mva.py_nnma.nnma.X_inexact_lsq_update_l1regul(Y, YT, A, X, **param)[source]

ALS fixed point update with L1 regularization for X

PyMca5.PyMcaMath.mva.py_nnma.nnma.X_mult_update(Y, YT, A, X, **param)[source]

Lee and Sung multiplicative update

PyMca5.PyMcaMath.mva.py_nnma.nnma.X_mult_update_kl_div(Y, YT, A, X, **param)[source]

update V for minimization of KL(Y || A X)

PyMca5.PyMcaMath.mva.py_nnma.nnma.X_mult_update_nnsc(Y, YT, A, X, **param)[source]

Lee and Sung multiplicative update

PyMca5.PyMcaMath.mva.py_nnma.nnma.coerced(Y)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.diff(A, B)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.divide_matrix(A, by)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.divide_sparse_matrix(A, by)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.dot(A, B)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.flatten(A)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.frob_norm(A)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.get_scaling_vector(A, p=1.0)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.is_sparse(A)
PyMca5.PyMcaMath.mva.py_nnma.nnma.regul_dec(param)[source]
PyMca5.PyMcaMath.mva.py_nnma.nnma.transpose(A)[source]