Non-negative Matrix Factorization
An implementation of non-negative matrix factorization. This can be used to decompose an input dataset into two low-rank non-negative components.
:- use_module('path/to/.../src/methods/nmf/nmf.pl').
%% usage example
TrainData = [5.1,3.5,1.4, 4.9,3.0,1.4, 4.7,3.2,1.3, 4.6,3.1,1.5],
nmf(multdist, 10000, 0.00001, TrainData, 3, 6, W, _, H, _).
Available Predicates
nmf/10
Initilizes the nmf model and applies it to the given data.
%% predicate definition
nmf(UpdateRule, MaxIterations, MinResidue, DataList, DataRows, Rank, WList, YCols, HList, ZCols) :-
MaxIterations >= 0,
MinResidue >= 0,
Rank > 0,
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrows, X)),
nmfI(UpdateRule, MaxIterations, MinResidue, X, Xsize, Xrows, Rank, Y, YCols, YRows, Z, ZCols, ZRows),
convert_float_array_to_2d_list(Y, YCols, YRows, WList),
convert_float_array_to_2d_list(Z, ZCols, ZRows, HList).
%% foreign c++ predicate definition
foreign(nmf, c, nmfI( +string, +integer, +float32,
+pointer(float_array), +integer, +integer,
+integer,
-pointer(float_array), -integer, -integer,
-pointer(float_array), -integer, -integer)).
Parameters
Name | Type | Description | Default |
---|---|---|---|
updateRule | +string | Update rules for each iteration: "multdist", "multdiv", "als" . | multdist |
maxIterations | +integer | Number of iterations before NMF terminates (0 runs until convergence. | 10000 |
minResidue | +float | The minimum root mean square residue allowed for each iteration, below which the program terminates. | 1e-5 |
data | +matrix | Input matrix to be factorized. | - |
rank | +integer | Rank r of the factorization. | - |
W | -matrix | Basis matrix to be output. | - |
H | -matrix | Encoding matrix to output. | - |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation