egc


Nameegc JSON
Version 0.2.4 PyPI version JSON
download
home_page
SummaryBenchmark of Graph Clustering.
upload_time2023-12-14 09:36:30
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2023-present EAGLE-Lab, Zhejiang University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords community detection graph graph clustering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # EAGLEGraphClustering <!-- omit in toc -->

<div align="center">

[![PYPI](https://img.shields.io/pypi/v/egc?style=flat)](https://pypi.org/project/egc/)
<!-- [![Latest Release](https://img.shields.io/github/v/tag/eaglelab-zju/EGC)](https://github.com/eaglelab-zju/EGC/tags) -->

</div>

A benchmark of graph clustering from [EAGLE-Lab, Zhejiang University](https://eagle.zju.edu.cn/).

- [Installation](#installation)
- [Usage](#usage)
  - [Pip Package](#pip-package)
  - [Command line](#command-line)
- [Datasets](#datasets)
- [Implemented baseline methods](#implemented-baseline-methods)
  - [Disjoint](#disjoint)
    - [Unsupervised Graph Neural Networks + Kmeans](#unsupervised-graph-neural-networks--kmeans)
    - [End-to-End Graph Clustering](#end-to-end-graph-clustering)
  - [Overlapping](#overlapping)
- [Requirements](#requirements)
- [Contributing](#contributing)

## Installation
- python>=3.8
- torch>=1.12
- dgl>=1.1

```bash
$ python -m pip install egc
```

## Usage

### Pip Package

See [egc](https://eaglelab-zju.github.io/egc_doc_repo/) for docs.

- Import the package and use any graph clustering model supported as:

```python
from torch import nn
from egc.model import DGL_GAEKmeans
from egc.utils import load_data
from egc.utils import get_default_args
from egc.utils import set_seed
from egc.utils import set_device

# set the random seed
set_seed(4096)

# set the gpu id
set_device('0')

# load graph
graph, label, n_clusters = load_data(
    dataset_name='Cora',
    directory='./data',
)
features = graph.ndata["feat"]
adj_csr = graph.adj_external(scipy_fmt="csr")

# get default args
args = get_default_args('gae_kmeans')

# init the model
model = DGL_GAEKmeans(
    epochs=args["epochs"],
    n_clusters=10,
    fead_dim=features.shape[1],
    n_nodes=features.shape[0],
    hidden_dim1=args["hidden1"],
    dropout=args["dropout"],
    lr=args["lr"],
    early_stop=args["early_stopping_epoch"],
    activation=args["activation"],
)

# fit the model
model.fit(adj_csr, features)

# get clustering results
res = model.get_memberships()
```

### Command line

- Clone the Repo
- Install the env

```bash
# NOTE: python>=3.8 is needed
# Install cuda if necessary. Check Cuda version first.
$ cd EGC
# Leave out `bash .ci/install-dev.sh &&` if no dev env is needed.
$ bash .ci/install-dev.sh && bash .ci/install.sh
# run `source .env/bin/activate` to activate the virtual env
```

- Run any supported model as:

```shell
$ python train.py ${OPTIONAL global args} ${POSITIONAL args (model)} ${optional model args}
```

- *OPTIONAL* global args which should be used before `${model}`
- *POSITIONAL* args, i.e., all models supported

E.g.,

```bash
# check OPTIONAL global args, e.g., all models supported
$ python train.py -h

# check optional args of certain model
$ python train.py gae_kmeans -h

# run any model
$ python train.py --dataset=Cora gae_kmeans --lr 0.001
```

## Datasets

- `Cora`, `Citeseer`, `Pubmed` come from [DGL Lib](https://docs.dgl.ai/api/python/dgl.data.html)
- `BlogCatalog`, `Flickr` come from [CoLA github](https://github.com/GRAND-Lab/CoLA/tree/main/raw_dataset)
- `ACM` come from [SDCN github](https://github.com/bdy9527/SDCN)
- All above datasets are converted to undirected graphs.

|   Dataset   |  Nodes |   Edges | Attributes | Classes |
| :---------: | -----: | ------: | ---------: | ------: |
|    Cora     |  2,708 |  10,556 |      1,433 |       7 |
|  Citeseer   |  3,327 |   9,228 |      3,703 |       6 |
|   Pubmed    | 19,717 |  88,651 |        500 |       3 |
| BlogCatalog |  5,196 | 343,486 |      8,189 |       6 |
|   Flickr    |  7,575 | 479,476 |     12,047 |       9 |
|     ACM     |  3,025 |  26,256 |      1,870 |       3 |
|  CoraFull   | 19,793 | 126,842 |      8,710 |      70 |

## Implemented baseline methods

### Disjoint

#### Unsupervised Graph Neural Networks + Kmeans

|  method   | Conf/Journal |          Original Code           | Supproted |
| :-------: | :----------: | :------------------------------: | :-------: |
|  [VGAE]   |    16nips    | [TensorFlow][vgae in tensorflow] |     ✅     |
| GraphSAGE |              |                                  |           |
|   [DGI]   |    19iclr    |    [Pytorch][dgi in pytorch]     |     ✅     |
|   [GMI]   |    20www     |    [Pytorch][gmi in pytorch]     |     ✅     |
|  [SENet]  |     21nn     |                                  |     ✅     |

#### End-to-End Graph Clustering

|  method  | Conf/Journal |       Original Code        | Supproted |
| :------: | :----------: | :------------------------: | :-------: |
|  [SDCN]  |    20www     | [Pytorch][sdcn in pytorch] |     ✅     |
| [DANMF]  |    18cikm    |     [code][danmf code]     |     ✅     |
| [M-NMF]  |    17aaai    | [Matlab][m-nmf in matlab]  |     ✅     |
|  [DFCN]  |    21aaai    | [Pytorch][dfcn in pytorch] |     ✅     |
| [VGAECD] |    18icdm    |             --             |     ✅     |
|  [ComE]  |    17cikm    |     [code][come code]      |     ✅     |
| [DAEGC]  |   19ijcai    |  [code][daegc in pytorch]  |     ✅     |

### Overlapping

|     method     | Conf/Journal |              Original Code               | Supproted |
| :------------: | :----------: | :--------------------------------------: | :-------: |
| [CommunityGAN] |    19www     | [TensorFlow][communitygan in tensorflow] |     ✅     |

## Requirements

See [dependencies](./pyproject.toml), [requirements-dev.txt](./requirements-dev.txt) and [requirements.txt](./requirements.txt).

## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md).

[come]: https://dl.acm.org/doi/abs/10.1145/3132847.3132925
[come code]: https://github.com/andompesta/ComE
[communitygan]: https://arxiv.org/pdf/1901.06631.pdf
[communitygan in tensorflow]: https://github.com/SamJia/CommunityGAN
[daegc]: https://www.ijcai.org/proceedings/2019/0509.pdf
[daegc in pytorch]: https://github.com/Tiger101010/DAEGC
[danmf]: https://www.researchgate.net/profile/Chuan-Chen-11/publication/328439632_Deep_Autoencoder-like_Nonnegative_Matrix_Factorization_for_Community_Detection/links/5d7dc4b3a6fdcc2f0f6fbf3a/Deep-Autoencoder-like-Nonnegative-Matrix-Factorization-for-Community-Detection.pdf
[danmf code]: https://github.com/benedekrozemberczki/DANMF
[dfcn]: https://arxiv.org/pdf/2012.09600.pdf
[dfcn in pytorch]: https://github.com/WxTu/DFCN
[dgi]: https://arxiv.org/pdf/1809.10341.pdf
[dgi in pytorch]: https://github.com/PetarV-/DGI
[gmi]: https://arxiv.org/pdf/2002.01169.pdf
[gmi in pytorch]: https://github.com/zpeng27/GMI
[m-nmf]: https://aaai.org/ocs/index.php/AAAI/AAAI17/paper/view/14589/13763
[m-nmf in matlab]: https://github.com/AnryYang/M-NMF
[sdcn]: https://arxiv.org/pdf/2002.01633.pdf
[sdcn in pytorch]: https://github.com/bdy9527/SDCN
[senet]: https://www.sciencedirect.com/science/article/abs/pii/S0893608021002227
[vgae]: https://arxiv.org/pdf/1611.07308.pdf
[vgae in tensorflow]: https://github.com/tkipf/gae
[vgaecd]: https://sci-hub.ru/10.1109/icdm.2018.00022

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "egc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "community detection,graph,graph clustering",
    "author": "",
    "author_email": "EAGLE-Lab <galo.gm.work@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/71/cd/370706edb7448561f6fee914e41df7a4310781182a3590c98e53dee5e530/egc-0.2.4.tar.gz",
    "platform": null,
    "description": "# EAGLEGraphClustering <!-- omit in toc -->\n\n<div align=\"center\">\n\n[![PYPI](https://img.shields.io/pypi/v/egc?style=flat)](https://pypi.org/project/egc/)\n<!-- [![Latest Release](https://img.shields.io/github/v/tag/eaglelab-zju/EGC)](https://github.com/eaglelab-zju/EGC/tags) -->\n\n</div>\n\nA benchmark of graph clustering from [EAGLE-Lab, Zhejiang University](https://eagle.zju.edu.cn/).\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Pip Package](#pip-package)\n  - [Command line](#command-line)\n- [Datasets](#datasets)\n- [Implemented baseline methods](#implemented-baseline-methods)\n  - [Disjoint](#disjoint)\n    - [Unsupervised Graph Neural Networks + Kmeans](#unsupervised-graph-neural-networks--kmeans)\n    - [End-to-End Graph Clustering](#end-to-end-graph-clustering)\n  - [Overlapping](#overlapping)\n- [Requirements](#requirements)\n- [Contributing](#contributing)\n\n## Installation\n- python>=3.8\n- torch>=1.12\n- dgl>=1.1\n\n```bash\n$ python -m pip install egc\n```\n\n## Usage\n\n### Pip Package\n\nSee [egc](https://eaglelab-zju.github.io/egc_doc_repo/) for docs.\n\n- Import the package and use any graph clustering model supported as:\n\n```python\nfrom torch import nn\nfrom egc.model import DGL_GAEKmeans\nfrom egc.utils import load_data\nfrom egc.utils import get_default_args\nfrom egc.utils import set_seed\nfrom egc.utils import set_device\n\n# set the random seed\nset_seed(4096)\n\n# set the gpu id\nset_device('0')\n\n# load graph\ngraph, label, n_clusters = load_data(\n    dataset_name='Cora',\n    directory='./data',\n)\nfeatures = graph.ndata[\"feat\"]\nadj_csr = graph.adj_external(scipy_fmt=\"csr\")\n\n# get default args\nargs = get_default_args('gae_kmeans')\n\n# init the model\nmodel = DGL_GAEKmeans(\n    epochs=args[\"epochs\"],\n    n_clusters=10,\n    fead_dim=features.shape[1],\n    n_nodes=features.shape[0],\n    hidden_dim1=args[\"hidden1\"],\n    dropout=args[\"dropout\"],\n    lr=args[\"lr\"],\n    early_stop=args[\"early_stopping_epoch\"],\n    activation=args[\"activation\"],\n)\n\n# fit the model\nmodel.fit(adj_csr, features)\n\n# get clustering results\nres = model.get_memberships()\n```\n\n### Command line\n\n- Clone the Repo\n- Install the env\n\n```bash\n# NOTE: python>=3.8 is needed\n# Install cuda if necessary. Check Cuda version first.\n$ cd EGC\n# Leave out `bash .ci/install-dev.sh &&` if no dev env is needed.\n$ bash .ci/install-dev.sh && bash .ci/install.sh\n# run `source .env/bin/activate` to activate the virtual env\n```\n\n- Run any supported model as:\n\n```shell\n$ python train.py ${OPTIONAL global args} ${POSITIONAL args (model)} ${optional model args}\n```\n\n- *OPTIONAL* global args which should be used before `${model}`\n- *POSITIONAL* args, i.e., all models supported\n\nE.g.,\n\n```bash\n# check OPTIONAL global args, e.g., all models supported\n$ python train.py -h\n\n# check optional args of certain model\n$ python train.py gae_kmeans -h\n\n# run any model\n$ python train.py --dataset=Cora gae_kmeans --lr 0.001\n```\n\n## Datasets\n\n- `Cora`, `Citeseer`, `Pubmed` come from [DGL Lib](https://docs.dgl.ai/api/python/dgl.data.html)\n- `BlogCatalog`, `Flickr` come from [CoLA github](https://github.com/GRAND-Lab/CoLA/tree/main/raw_dataset)\n- `ACM` come from [SDCN github](https://github.com/bdy9527/SDCN)\n- All above datasets are converted to undirected graphs.\n\n|   Dataset   |  Nodes |   Edges | Attributes | Classes |\n| :---------: | -----: | ------: | ---------: | ------: |\n|    Cora     |  2,708 |  10,556 |      1,433 |       7 |\n|  Citeseer   |  3,327 |   9,228 |      3,703 |       6 |\n|   Pubmed    | 19,717 |  88,651 |        500 |       3 |\n| BlogCatalog |  5,196 | 343,486 |      8,189 |       6 |\n|   Flickr    |  7,575 | 479,476 |     12,047 |       9 |\n|     ACM     |  3,025 |  26,256 |      1,870 |       3 |\n|  CoraFull   | 19,793 | 126,842 |      8,710 |      70 |\n\n## Implemented baseline methods\n\n### Disjoint\n\n#### Unsupervised Graph Neural Networks + Kmeans\n\n|  method   | Conf/Journal |          Original Code           | Supproted |\n| :-------: | :----------: | :------------------------------: | :-------: |\n|  [VGAE]   |    16nips    | [TensorFlow][vgae in tensorflow] |     \u2705     |\n| GraphSAGE |              |                                  |           |\n|   [DGI]   |    19iclr    |    [Pytorch][dgi in pytorch]     |     \u2705     |\n|   [GMI]   |    20www     |    [Pytorch][gmi in pytorch]     |     \u2705     |\n|  [SENet]  |     21nn     |                                  |     \u2705     |\n\n#### End-to-End Graph Clustering\n\n|  method  | Conf/Journal |       Original Code        | Supproted |\n| :------: | :----------: | :------------------------: | :-------: |\n|  [SDCN]  |    20www     | [Pytorch][sdcn in pytorch] |     \u2705     |\n| [DANMF]  |    18cikm    |     [code][danmf code]     |     \u2705     |\n| [M-NMF]  |    17aaai    | [Matlab][m-nmf in matlab]  |     \u2705     |\n|  [DFCN]  |    21aaai    | [Pytorch][dfcn in pytorch] |     \u2705     |\n| [VGAECD] |    18icdm    |             --             |     \u2705     |\n|  [ComE]  |    17cikm    |     [code][come code]      |     \u2705     |\n| [DAEGC]  |   19ijcai    |  [code][daegc in pytorch]  |     \u2705     |\n\n### Overlapping\n\n|     method     | Conf/Journal |              Original Code               | Supproted |\n| :------------: | :----------: | :--------------------------------------: | :-------: |\n| [CommunityGAN] |    19www     | [TensorFlow][communitygan in tensorflow] |     \u2705     |\n\n## Requirements\n\nSee [dependencies](./pyproject.toml), [requirements-dev.txt](./requirements-dev.txt) and [requirements.txt](./requirements.txt).\n\n## Contributing\nSee [CONTRIBUTING.md](./CONTRIBUTING.md).\n\n[come]: https://dl.acm.org/doi/abs/10.1145/3132847.3132925\n[come code]: https://github.com/andompesta/ComE\n[communitygan]: https://arxiv.org/pdf/1901.06631.pdf\n[communitygan in tensorflow]: https://github.com/SamJia/CommunityGAN\n[daegc]: https://www.ijcai.org/proceedings/2019/0509.pdf\n[daegc in pytorch]: https://github.com/Tiger101010/DAEGC\n[danmf]: https://www.researchgate.net/profile/Chuan-Chen-11/publication/328439632_Deep_Autoencoder-like_Nonnegative_Matrix_Factorization_for_Community_Detection/links/5d7dc4b3a6fdcc2f0f6fbf3a/Deep-Autoencoder-like-Nonnegative-Matrix-Factorization-for-Community-Detection.pdf\n[danmf code]: https://github.com/benedekrozemberczki/DANMF\n[dfcn]: https://arxiv.org/pdf/2012.09600.pdf\n[dfcn in pytorch]: https://github.com/WxTu/DFCN\n[dgi]: https://arxiv.org/pdf/1809.10341.pdf\n[dgi in pytorch]: https://github.com/PetarV-/DGI\n[gmi]: https://arxiv.org/pdf/2002.01169.pdf\n[gmi in pytorch]: https://github.com/zpeng27/GMI\n[m-nmf]: https://aaai.org/ocs/index.php/AAAI/AAAI17/paper/view/14589/13763\n[m-nmf in matlab]: https://github.com/AnryYang/M-NMF\n[sdcn]: https://arxiv.org/pdf/2002.01633.pdf\n[sdcn in pytorch]: https://github.com/bdy9527/SDCN\n[senet]: https://www.sciencedirect.com/science/article/abs/pii/S0893608021002227\n[vgae]: https://arxiv.org/pdf/1611.07308.pdf\n[vgae in tensorflow]: https://github.com/tkipf/gae\n[vgaecd]: https://sci-hub.ru/10.1109/icdm.2018.00022\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023-present EAGLE-Lab, Zhejiang University  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Benchmark of Graph Clustering.",
    "version": "0.2.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/eaglelab-zju/EGC/issues",
        "Homepage": "https://github.com/eaglelab-zju/EGC"
    },
    "split_keywords": [
        "community detection",
        "graph",
        "graph clustering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62e938f10e3b110f86b042eef58b793271ecb4201bfc1240c18207434dcfbfc2",
                "md5": "2e42097fb43b455d2cf0926bb46fdc57",
                "sha256": "818bedd858ea385cf190e0a31fb45653a1eca4839107a6d5d298e19e2f5f4805"
            },
            "downloads": -1,
            "filename": "egc-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2e42097fb43b455d2cf0926bb46fdc57",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 208396,
            "upload_time": "2023-12-14T09:36:27",
            "upload_time_iso_8601": "2023-12-14T09:36:27.643100Z",
            "url": "https://files.pythonhosted.org/packages/62/e9/38f10e3b110f86b042eef58b793271ecb4201bfc1240c18207434dcfbfc2/egc-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71cd370706edb7448561f6fee914e41df7a4310781182a3590c98e53dee5e530",
                "md5": "fe3349b77bf462d2abc1f9989d438ad4",
                "sha256": "bed3d71d7463e811d5d7892a1d032d99b4d4562fdddaee957b22baff0c83f3af"
            },
            "downloads": -1,
            "filename": "egc-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "fe3349b77bf462d2abc1f9989d438ad4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3566713,
            "upload_time": "2023-12-14T09:36:30",
            "upload_time_iso_8601": "2023-12-14T09:36:30.071792Z",
            "url": "https://files.pythonhosted.org/packages/71/cd/370706edb7448561f6fee914e41df7a4310781182a3590c98e53dee5e530/egc-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-14 09:36:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eaglelab-zju",
    "github_project": "EGC",
    "github_not_found": true,
    "lcname": "egc"
}
        
Elapsed time: 0.14819s