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.Yis assumed to be equal toTH + GA + W, whereTHis an approximately low rank matrix,GAis a sparse "spiky" matrix, andWis 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 have0orFalsein the positions whereYis incomplete,1orTrueelsewhere. Defaults toNone.lambda_d: regularization paramater for the low rankTHmatrix.mu_d: regularization parameter for the sparseGAmatrix. 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.