Python implementation of Generalised Non-negative Matrix Factorisation with Multiplicative and Projected Gradient Approaches.
Reason this release was yanked:
testing
Project description
pyGNMF
Python Library for Generalised Non-Negative Matrix Factorisation (GNMF)
A Python implementation of GNMF method introduced in article by Lekinwala and Bhushan in an article "Generalised Non-Negative Matrix Factorisation for Air Pollution Source Apportionment".
Please refer to the article in SoftwareX (Lekinwala and Bhushan, 2022) for more details.
Some Features
Uses NumPy (or CuPy, if the package is installed) to factorise a matrix $X_{n\times m}$ into $G_{n\times p}$ and $F_{p\times m}$. Depending on the choice of the Covariance matrix, the GNMF will result in one of the following methods,
Covariance Matrix
The covariance matrix ($\Sigma$) should be of size $nm\times nm$ which captures element-wise covariance information. Depending on the type of covariance, GNMF method can act as different methods in the literature,
- Covariance Matrix as Identity: In this case, GNMF method with multiplicative update is same as NMF method proposed by Lee and Seung, 1999.
- Covariance Matrix is Diagonal Matrix: In this case, GNMF method with multiplicative update is same as LS-NMF method (Wang et. al., 2006).
- Covariance Matrix with elements correlated along rows or columns: In this case, GNMF method with multiplicative update is same as glsNMF method (Plis et. al. 2011).
- Covariance Matrix is Dense Matrix: Lekinwala and Bhushan, 2022 proposes the GNMF method with multiplicative and projected gradient updates.
Functions in pyGNMF
Following are some class as part of the module.
-
gnmf_multiplicative_update: There are four functions as part of the class,update_F: This function is used for the update of F.update_G: This function is used for the update of G.objective_function: This function is used to compute the value of objective functionrunning_method: This function is used to run the method under consideration. Following are the inputs required.
Use:
G_updated, F_updated, objective_function = gnmf_multiplicative_updaterunning_method(X_matrix, covariance, option=('row_stacked', 'column_stacked'), G_init='random', F_init='random', num_fact=None, num_init=1, max_iter=500000, tolerance=1e-06, conv_typ=('absolute', 'relative'), conv_num=3)where,
X_matrix(required): Matrix to factorisecovariance(required): Covariance Matrix ($nm\times nm$) for the elements of $X_{n\times m}$ Matrix.option=('row_stacked', 'column_stacked')(required): Option to select if the covariance matrix ($nm\times nm$) elements corresponds to row-stacked elements of $X$ matrix or column-stacked elements of $X$ matrix.G_init='random'(required): Non-negative Initial guess for $G$ of size $n\times p$. Ifrandomkeyword is used,G_initis generated randomly internally.F_init='random'(required): Non-negative Initial guess for $F$ of size $p\times m$. Ifrandomkeyword is used,F_initis generated randomly internally.num_fact=None($p$, required): A critical parameter for the GNMF to work i.e., the number of factors for $X$ matrix.num_init=1(optional): Each method can be initialised multiple times depending on this parameter. Default value is 1.max_iter=500000(optional): Each initialisation of a method under consideration will run till convergence or till the maximum number of iterations defined by this parameters. Default value is 500000.tolerance=1e-06(optional): Each initialisation of a method under consideration will run till convergence or till the maximum number of iterations. This parameter defines the tolerance value for the convergence.conv_typ=('absolute', 'relative')(optional): Each initialisation of a method under consideration will run till convergence. This parameter defines the type of convergence i.e.,absolutedifference in the objective function value orrelativedifference in the objective function value. Default value isrelative.conv_num=3(optional): Each initialisation of a method under consideration will run till convergence.conv_numparameter is used to declare convergence only if theabsoluteorrelativedifference is less than tolerance value for some iterations. Default value is 3.
-
gnmf_projected_gradient: There are four functions as part of the class,update_F: This function is used for the update of F.update_G: This function is used for the update of G.objective_function: This function is used to compute the value of objective functionrunning_method: This function is used to run the method under consideration. Following are the inputs required.
Use:
G_updated, F_updated, objective_function = gproj.running_method( X_matrix, covariance, G_init='random', F_init='random', beta=0.1, sigma=0.0001, alpha_init_G=1, alpha_init_F=1, option=('row_stacked', 'column_stacked'), num_fact=None, num_init=1, max_iter=500000, tolerance=1e-06, conv_typ=('absolute', 'relative'), conv_num=3)where,
X_matrix(required): Matrix to factorisecovariance(required): Covariance Matrix ($nm\times nm$) for the elements of $X_{n\times m}$ Matrix.G_init='random'(required): Non-negative Initial guess for $G$ of size $n\times p$. Ifrandomkeyword is used,G_initis generated randomly internally.F_init='random'(required): Non-negative Initial guess for $F$ of size $p\times m$. Ifrandomkeyword is used,F_initis generated randomly internally.option=('row_stacked', 'column_stacked')(required): Option to select if the covariance matrix ($nm\times nm$) elements corresponds to row-stacked elements of $X$ matrix or column-stacked elements of $X$ matrix.beta = 0.1(optional): $\beta$ value used to reduce the value of initial step-length ($\alpha$) while search for $\alpha$ to achieve sufficient decrease. Default value is 0.1.sigma=0.0001(optional): User-defined parameter used in sufficient decreasealpha_init_G=1: Initial step-length for the update of $G$. Default value is 1.alpha_init_F=1: Initial step-length for the update oF $F$.num_fact=None($p$, required): A critical parameter for the GNMF to work i.e., the number of factors for $X$ matrix.num_init=1(optional): Each method can be initialised multiple times depending on this parameter. Default value is 1.max_iter=500000(optional): Each initialisation of a method under consideration will run till convergence or till the maximum number of iterations defined by this parameters. Default value is 500000.tolerance=1e-06(optional): Each initialisation of a method under consideration will run till convergence or till the maximum number of iterations. This parameter defines the tolerance value for the convergence.conv_typ=('absolute', 'relative')(optional): Each initialisation of a method under consideration will run till convergence. This parameter defines the type of convergence i.e.,absolutedifference in the objective function value orrelativedifference in the objective function value. Default value isrelative.conv_num=3(optional): Each initialisation of a method under consideration will run till convergence.conv_numparameter is used to declare convergence only if theabsoluteorrelativedifference is less than tolerance value for some iterations. Default value is 3.
-
G_updated, F_updated, objective_function = nmf_multiplicative_update: There are two functions as part of the class,objective_function: This function is used to compute the value of objective functionrunning_method: This function is used to run the method under consideration. Following are the inputs required.
Use
nmf_multiplicative_update.running_method(X_matrix, G_init='random', F_init='random', num_fact=None, num_init=1, max_iter=500000, tolerance=1e-06, conv_typ='relative', conv_num=3)where,
X_matrix(required): Matrix to factoriseG_init='random'(required): Non-negative Initial guess for $G$ of size $n\times p$. Ifrandomkeyword is used,G_initis generated randomly internally.F_init='random'(required): Non-negative Initial guess for $F$ of size $p\times m$. Ifrandomkeyword is used,F_initis generated randomly internally.num_fact=None($p$, required): A critical parameter for the GNMF to work i.e., the number of factors for $X$ matrix.num_init=1(optional): Each method can be initialised multiple times depending on this parameter. Default value is 1.max_iter=500000(optional): Each initialisation of a method under consideration will run till convergence or till the maximum number of iterations defined by this parameters. Default value is 500000.tolerance=1e-06(optional): Each initialisation of a method under consideration will run till convergence or till the maximum number of iterations. This parameter defines the tolerance value for the convergence.conv_typ=('absolute', 'relative')(optional): Each initialisation of a method under consideration will run till convergence. This parameter defines the type of convergence i.e.,absolutedifference in the objective function value orrelativedifference in the objective function value. Default value isrelative.conv_num=3(optional): Each initialisation of a method under consideration will run till convergence.conv_numparameter is used to declare convergence only if theabsoluteorrelativedifference is less than tolerance value for some iterations. Default value is 3.
References
[1] Nirav L. Lekinwala and Mani Bhushan, Generalised non-negative matrix factorisation for air pollution source apportionment Science of The Total Environment (2022), 156294, ISSN 0048-9697, https://doi.org/10.1016/j.scitotenv.2022.156294.
[2] Nirav L. Lekinwala and Mani Bhushan,
pyGNMF: A python library for implementation of generalised non-negative matrix factorisation method
SoftwareX, 2022, (Submitted)
[3] Lee, D. and Seung, H. Learning the parts of objects by non-negative matrix factorization Nature (1999), 401(6755):788–791. https://doi.org/10.1038/44565
[4] Wang, G., Kossenkov, A. V., and Ochs, M. F. LS-NMF: A modified non-negative matrix factorization algorithm utilizing uncertainty estimates. BMC Bioinformatics (2006), 7(1):175. https://doi.org/10.1186/1471-2105-7-175
[5] Plis, S.M., Potluru, V.K., Lane, T. et al. Correlated Noise: How it Breaks NMF, and What to Do About it J Sign Process Syst. (2011), 65, 351–359. https://doi.org/10.1007/s11265-010-0511-8
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyGNMF-1.0.6.tar.gz.
File metadata
- Download URL: pyGNMF-1.0.6.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46c230d442fe5a1fdb1c7b098c634e4aaa607ad3c0fdf5565ec654221f4c269e
|
|
| MD5 |
2cf2a4801e579527fbdf22231420ae81
|
|
| BLAKE2b-256 |
44ccfbe82183621a623bd4d63773dcef89b177befa37a2df7d91c8fca6b759ff
|
File details
Details for the file pyGNMF-1.0.6-py3-none-any.whl.
File metadata
- Download URL: pyGNMF-1.0.6-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd3d7a907a0cc771570f1ae86208fc2b3cde97b0c3584c66ea24f08403093ecf
|
|
| MD5 |
44e118bb6f954ee2be0a33065cb8e098
|
|
| BLAKE2b-256 |
0d5ecce22f371f37266aaea76a7e3148109c0d8a3a701c5a64faa1f7d8d52b58
|