This code implements a matrix completion and decomposition algorithm, based on this paper.
The main method you will want to use is matrix_decomposition()
which decomposes an optionally incomplete matrix, into two components, one low rank, and one sparse. It takes the following arguments:
Y
: the matrix to decompose.Y
is assumed to be equal toTH + GA + W
, whereTH
is an approximately low rank matrix,GA
is a sparse "spiky" matrix, andW
is noise. A full matrix needs to be given, but some parts can be ignored, as specified by the mask.Mask
: a mask can be given to treat the matrix as incomplete. It must be of the same dimentions asY
. It must have0
orFalse
in the positions whereY
is incomplete,1
orTrue
elsewhere. Defaults toNone
.lambda_d
: regularization paramater for the low rankTH
matrix.mu_d
: regularization parameter for the sparseGA
matrix. Use higher values if no spikes are expected.alpha
: parameter that limits the maximum element of the low rank TH matrix. Bigger matrices will need bigger alpha` values.
The method will return TH
and GA
.
Additionally the code contains some methods and classes to generate synthetic matrices and to test the decomposition in various ways.