The text of DEMO program S.Funk

## Generalized Non-negative Matrix Factorization

There is no shortage of algorithms for non-negative matrix factorization, however, most of them do not provide support for hidden elements and for multiple elements in each matrix cell.

In general case we may not know all elements of the matrix and also have multiple elements for a particular cell. Let us look at the data below. It is 3d matrix that has 3 layers, so we have 3 elements for each row-column combination, but there are two row-column combinations, for which we do not have data at all. But we still want to find decomposition in a form of two matrices, that being multiplied produce some product close to each of these layers.

 30 N/A 40 11 30 45 33 11 30 45 64 20 24 36 N/A 25 36 54 79 32
 31 N/A 41 12 32 47 36 14 31 45 64 22 25 38 N/A 28 38 56 79 35
 33 N/A 41 11 33 45 34 11 30 48 65 21 25 37 N/A 26 37 56 81 33

With suggested under link at the top algorithm we found cofactors and the product of them shown below.

 1.249 4.084 4.205 1.006 2.704 5.272 4.304 4.87 2.412 5.7 2.534 2.135 6.676 3.38 4.183
 1.444 2.293 7.864 4.063 2.83 4.494 5.069 -0.027 4.281 5.923 2.411 1.514
 31.363 46.127 40.666 11.331 31.671 45.683 34.328 11.997 30.32 46.039 64.345 21.002 24.539 37.101 62.816 26.318 37.11 55.271 79.715 33.362

Negative value in the right cofactor is simple computational inaccuracy. It can be corrected by reduction of learning rate parameter.

The credit goes to someone under name S.Funk, who published this procedure several years ago for two dimensional matrices, and my role is reduced to generalization it into 3d matrices.

The impressive part of this algorithm is that (at the core) it needs only few lines of code.

Andrew Polar, Jan, 2017.