diff --git a/README.md b/README.md index a7d457e..13c5baf 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,34 @@ Wikipedia [Source](http://www.mattmahoney.net/dc/textdata) [Preprocessed](http:/ [Flickr](http://leitang.net/code/social-dimension/data/flickr.mat) +## Installation + +The latest version of NetMF can be downloaded and installed from +[GitHub](https://github.com/xptree/NetMF) on Python 3.5+ with: + +```bash +$ pip install git+https://github.com/xptree/NetMF.git +``` + +For developers, NetMF can be installed from the source code in +in development mode with: + +```bash +$ git clone https://github.com/xptree/NetMF.git +$ cd NetMF +$ pip install -e . +``` + +## Usage + +This is a minimal example to use the code via the command line to train on the PPI network. + +```bash +$ wget http://snap.stanford.edu/node2vec/Homo_sapiens.mat +$ netmf-train --input Homo_sapiens.mat --output homo_sapiens_embeddings.txt +$ netmf-predict --label Homo_sapiens.mat --embedding homo_sapiens_embeddings.txt.npy --seed 5 +``` + ## Cite Please cite our paper if you use this code in your own work: diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..246b026 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,49 @@ +########################## +# Setup.py Configuration # +########################## +# Configuring setup() +[metadata] +name = netmf +version = 0.0.1 + +# Author information +author = Jiezhong Qiu + +# License information +license = MIT +license_file = LICENSE + +# Search tags +classifiers = + Development Status :: 4 - Beta + Environment :: Console + Intended Audience :: Science/Research + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Programming Language :: Python + Topic :: Scientific/Engineering :: Artificial Intelligence +keywords = + Node Representation Learning + Network Representation Learning + +[options] +install_requires = + scipy + numpy + theano + sklearn + +python_requires = >=3.5 + +# Where is my code +packages = find: +package_dir = + = src + +[options.packages.find] +where = src + +[options.entry_points] +console_scripts = + netmf-train = netmf.netmf:main + netmf-predict = netmf.predict:main diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a78fbfd --- /dev/null +++ b/setup.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +"""Setup module.""" + +import setuptools + +if __name__ == '__main__': + setuptools.setup() diff --git a/src/netmf/__init__.py b/src/netmf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/netmf.py b/src/netmf/netmf.py similarity index 99% rename from netmf.py rename to src/netmf/netmf.py index 6eebe77..88166e7 100644 --- a/netmf.py +++ b/src/netmf/netmf.py @@ -122,7 +122,7 @@ def netmf_small(args): logger.info("Save embedding to %s", args.output) np.save(args.output, deepwalk_embedding, allow_pickle=False) -if __name__ == "__main__": +def main(): parser = argparse.ArgumentParser() parser.add_argument("--input", type=str, required=True, help=".mat input file path") @@ -155,3 +155,6 @@ def netmf_small(args): else: netmf_small(args) + +if __name__ == "__main__": + main() diff --git a/predict.py b/src/netmf/predict.py similarity index 99% rename from predict.py rename to src/netmf/predict.py index ba4d50c..1d34106 100644 --- a/predict.py +++ b/src/netmf/predict.py @@ -88,7 +88,7 @@ def predict_cv(X, y, train_ratio=0.2, n_splits=10, random_state=0, C=1.): np.mean(macro) * 100) -if __name__ == "__main__": +def main(): parser = argparse.ArgumentParser() parser.add_argument("--label", type=str, required=True, help="input file path for labels (.mat)") @@ -136,3 +136,6 @@ def predict_cv(X, y, train_ratio=0.2, n_splits=10, random_state=0, C=1.): predict_cv(embedding, label, train_ratio=tr/100., n_splits=args.num_split, C=args.C, random_state=args.seed) + +if __name__ == "__main__": + main()