Network-Dictionary-Learning
Learning from and reconstructing networks using MCMC motif sampling and Nonnegative Matrix Factorization
Installation
To install the Network Dictionary Learning package, run this command in your terminal:
$ pip install ndlearn
This is the preferred method to install Network Dictionary Learning. If you don't have pip installed, these installation instructions can guide you through the process.
Usage
Our package lies on the backbone of the NNetwork class (see https://github.com/HanbaekLyu/NNetwork).
>>> from ndl import Wtd_NNetwork
>>> G = Wtd_NNetwork()
>>> G.load_add_edges_wtd("example.txt", use_genfromtxt=True, delimiter=",")
Learning a Dictionary
>>> from ndl import NetDictLearner
>>> NDL = NetDictLearner(G=G, n_components=25, k=21)
>>> NDL.train_dict()
>>> W = NDL.get_dictionary()
Display and save the learned dictionary:
>>> NDL.display_dict(path="example_dict.npy")
Replace the dictionary with a pre-trained dictionary and/or replace the network:
>>> NDL.set_dict(W)
>>> NDL.set_network(G)
Reconstructing a Network
>>> G_recons = NDL.reconstruct(recons_iter=10000)
The NetDictLearner class provices the base code to perform network dictionary learning and network reconstruction, but we also provide a series of helper fuctions to use alongside the NetDictLearner class to assist on performing tasks related to Network Dictionary Learning and evaluate performance.
Measure Accuracy of Reconstruction (Jaccard)
>>> from ndl import utils
>>> utils.recons_accuracy(G, G_recons)
0.92475345
Network Denoising Application
To add positive corruption (overlaying edges) or negative corruption (deleting edges) from a networks:
>>> len(G.edges())
1000
>>> G_add = utils.corrupt(G, p=0.1, noise_type="ER")
>>> G_remove_10 = utils.corrupt(G, p=0.1, noise_type="negative")
>>>len(G_remove_10.edges())
900
To measure the AUC of network denoising with positive (or negative) noise:
>>> G_corrupt = utils.corrupt(G, p=0.1, noise_type="ER")
>>> NDL_corrupt = NetDictLearner(G=G_corrupt)
>>> NDL_corrupt.train_dict()
>>> G_corrupt_recons = NDL_corrupt.reconstruct(recons_iter=10000)
>>> utils.auc(original=G, corrupt=G_corrupt, corrupt_recons=G_corrupt_recons, type="positive")
0.864578
Release files for ndlearn 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ndlearn-0.0.2.tar.gz | 24.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ndlearn-0.0.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 48.7 kB
Release files / ndlearn-0.0.2.tar.gz
| Download URL | ndlearn-0.0.2.tar.gz |
|---|---|
| Size | 24.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a42d37c7220c76de4fbef5d909760fecd08aacb9a5cd1742c8ef4bdc1927302f
|
|
BLAKE2b-256 checksum How to use checksums |
21cb122ed06a2e2eba5b47f76e6ff56cc7897321369f484a4bdf332b3bd39e76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1
|
Release files / ndlearn-0.0.2-py2.py3-none-any.whl
| Download URL | ndlearn-0.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 24.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
51ccd4961b08e947007e5889741cd468b6a47f7dc7e54a078756b17d1205ffe0
|
|
BLAKE2b-256 checksum How to use checksums |
f6f4cf9d43a2a031c4f4fb6478c11c2e9aa82d68ca81cc9808c5fd31626c44ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.1
|