Random (methods.seeding.random)

Random is the simplest MF initialization method.

The entries of factors are drawn from a uniform distribution over [0, max(target matrix)). Generated matrix factors are sparse matrices with the default density parameter of 0.01.

class nimfa.methods.seeding.random.Random

Bases: object

gen_dense(dim1, dim2)

Return randomly initialized numpy.matrix matrix of specified dimensions.

Parameters:
  • dim1 (int) – Dimension along first axis.
  • dim2 (int) – Dimension along second axis.
gen_sparse(dim1, dim2)

Return randomly initialized sparse matrix of specified dimensions.

Parameters:
  • dim1 (int) – Dimension along first axis.
  • dim2 (int) – Dimension along second axis.
initialize(V, rank, options)

Return initialized basis and mixture matrix (and additional factors if specified in :param:`Sn`, n = 1, 2, ..., k). Initialized matrices are of the same type as passed target matrix.

Parameters:
  • V (One of the scipy.sparse sparse matrices types or numpy.matrix) – Target matrix, the matrix for MF method to estimate.
  • rank (int) – Factorization rank.
  • options (dict) –

    Specify the algorithm and model specific options (e.g. initialization of extra matrix factor, seeding parameters).

    Option Sn, n = 1, 2, 3, ..., k specifies additional k matrix factors which need to be initialized. The value of each option Sn is a tuple denoting matrix shape. Matrix factors are returned in the same order as their descriptions in input.

    Option density represents density of generated matrices. Density of 1 means a full matrix, density of 0 means a matrix with no nonzero items. Default value is 0.7. Density parameter is applied only if passed target V is an instance of one scipy.sparse sparse types.

Fork me on GitHub