Convolutive Matrix Factorizations (CMF) in Julia.
Fitting CMF models is as simple as calling fit_cnmf
:
>> using CMF
>> data = CMF.gen_synthetic(N=500, T=2000)
>>
>> results = fit_cnmf(data; L=10, K=5, alg=:hals)
>> println(results.loss_hist[end])
Produces:
0.012
The command results = fit_cnmf(data)
fits a convolutive NMF model to the dataset. Several optional parameters are available, including:
alg
: the algorithm used to fit the model. The package currently supports:- Multiplicative Updates (
:mult
) - Hierarchical Alternating Least Squares (
:hals
) - Alternating Nonnegative Least Squares (
:anls
)
- Multiplicative Updates (
K
: the number of components in the model (defaultK=5
).L
: the width, or lag, of each component (defaultL=10
).max_time
: the maximum runtime in seconds (defaultmax_time=Inf
).max_itr
: the maximum number of iterations (defaultmax_itr=100
).
Multiplicative Updates (MU) and Hierarchical Alternating Least Squares (HALS) support L1 and L2 regularization. Using regularization with the Alternating Nonnegative Least Squares solver will raise an error.
Regularization is added with additional keyword arguments to the fit_cnmf
function. The following keyword arguments may be used:
l1_H
l2_H
l1_W
l2_W
These add L1 and L2 regularization to W or H as you would expect. Below is an example:
results = fit_cnmf(data; L=10, K=5, alg=:hals, l1_H=0.1, l2_H=0.2, l1_W=0.1, l2_W=0.5)
First, install the latest version of Julia. Then use the ]
key to enter package mode and type:
(v1.0) pkg> add https://github.com/degleris1/CMF.jl