Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
49 changes: 49 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-

"""Setup module."""

import setuptools

if __name__ == '__main__':
setuptools.setup()
Empty file added src/netmf/__init__.py
Empty file.
5 changes: 4 additions & 1 deletion netmf.py → src/netmf/netmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -155,3 +155,6 @@ def netmf_small(args):
else:
netmf_small(args)


if __name__ == "__main__":
main()
5 changes: 4 additions & 1 deletion predict.py → src/netmf/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down Expand Up @@ -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()