Skip to content
Merged
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
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contributing Guidelines

- Fork the repo.
- Install env with `python>=3.7`, e.g., for linux run:

```bash
# install python 3.7.16, e.g, if using pyenv run:
# pyenv install 3.7.16
# pyenv local 3.7.16
$ bash .ci/install-dev.sh
$ bash .ci/install.sh

# activate env:-
$ activate .venv/bin/activate
```

- Modify the code, commit the changes and create a PR.
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

## Installation

- python>=3.7
- torch>=1.12
- torch_geometric>=2.0
- dgl>=1.1

```bash
$ python -m pip install graph_datasets
```
Expand Down Expand Up @@ -44,21 +49,6 @@ $ nohup bash scripts/install.sh > logs/install.log &

<!-- Statistics begins -->

## Contribution
- Fork the repo.
- Install env with `python>=3.7`. For linux run:
```bash
# install python 3.7.16, e.g, if using pyenv run:
# pyenv install 3.7.16
# pyenv local 3.7.16
bash .ci/install-dev.sh
bash .ci/install.sh

# activate env:-
activate .venv/bin/activate
```
- Modify the code, commit the changes and create a PR.

## Statistics
| idx | source | dataset | n_nodes | n_feats | n_edges | n_clusters |
|------:|:---------|:----------------|:----------|:----------|:------------|-------------:|
Expand Down Expand Up @@ -124,3 +114,7 @@ activate .venv/bin/activate
## Requirements

See [requirements-dev.txt](./requirements-dev.txt) and [requirements.txt](./requirements.txt).

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion doc_repo
Submodule doc_repo updated 38 files
+1 −1 .buildinfo
+7 −0 README.md
+7 −3 _modules/graph_datasets/datasets/cola.html
+7 −3 _modules/graph_datasets/datasets/critical.html
+7 −3 _modules/graph_datasets/datasets/dgl.html
+7 −3 _modules/graph_datasets/datasets/linkx.html
+7 −3 _modules/graph_datasets/datasets/ogb.html
+7 −3 _modules/graph_datasets/datasets/pyg.html
+9 −4 _modules/graph_datasets/datasets/sdcn.html
+7 −3 _modules/graph_datasets/load_data.html
+289 −0 _modules/graph_datasets/utils/common.html
+434 −0 _modules/graph_datasets/utils/evaluation/eval_tools.html
+309 −0 _modules/graph_datasets/utils/evaluation/evaluation.html
+7 −4 _modules/graph_datasets/utils/model_management.html
+7 −4 _modules/graph_datasets/utils/output.html
+7 −4 _modules/graph_datasets/utils/statistics.html
+12 −6 _modules/index.html
+11 −6 _sources/rst/graph_datasets.utils.rst.txt
+1 −1 _sources/rst/table.rst.txt
+29 −0 _sources/tmp/graph_datasets.utils.evaluation.rst.txt
+16 −0 _sources/tmp/graph_datasets.utils.rst.txt
+1 −1 _static/documentation_options.js
+92 −16 genindex.html
+29 −24 index.html
+ objects.inv
+27 −3 py-modindex.html
+19 −8 rst/data_info.html
+11 −4 rst/graph_datasets.datasets.html
+73 −36 rst/graph_datasets.utils.html
+9 −5 rst/load_data.html
+10 −6 rst/table.html
+7 −3 search.html
+1 −1 searchindex.js
+11 −4 tmp/graph_datasets.datasets.html
+38 −16 tmp/graph_datasets.html
+262 −0 tmp/graph_datasets.utils.evaluation.html
+128 −91 tmp/graph_datasets.utils.html
+9 −3 tmp/project.html
15 changes: 6 additions & 9 deletions docs/rst/graph_datasets.utils.rst
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
utils
======================

evaluation
------------
======================
.. automodule:: graph_datasets.utils.evaluation.evaluation
:members:
:show-inheritance:
:exclude-members:
:exclude-members: save_to_csv_files
:no-undoc-members:

statistics
------------
======================
.. automodule:: graph_datasets.utils.statistics
:members:
:show-inheritance:
:exclude-members: get_long_edges, get_same_class_deg
:no-undoc-members:

model management
-----------------
======================
.. automodule:: graph_datasets.utils.model_management
:members:
:show-inheritance:
:no-undoc-members:

output
-------
======================
.. automodule:: graph_datasets.utils.output
:members:
:show-inheritance:
:no-undoc-members:

common
-------
======================
.. automodule:: graph_datasets.utils.common
:members:
:show-inheritance:
Expand Down
2 changes: 1 addition & 1 deletion docs/rst/table.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
statistics
dataset cheatsheet
===========
+-----+----------+-------------+-----------+---------+------------+------------+
| idx | source | dataset | n_nodes | n_feats | n_edges | n_clusters |
Expand Down
3 changes: 2 additions & 1 deletion graph_datasets/datasets/critical.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def load_critical_dataset(
Returns:
Tuple[dgl.DGLGraph, torch.Tensor, int]: [graph, label, n_clusters]
"""
data_file = os.path.join(directory, f"{dataset_name.replace('-','_')}.npz")
dataset_name = dataset_name.replace("-", "_")
data_file = os.path.join(directory, f"{dataset_name}.npz")

if not os.path.exists(data_file):
url = f"{CRITICAL_URL}/{dataset_name}.npz?raw=true"
Expand Down
2 changes: 1 addition & 1 deletion graph_datasets/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# pylint:disable=invalid-name
from .common import *
from .evaluation import evaluate_from_embed_file
from .evaluation import save_to_csv_files
from .model_management import check_modelfile_exists
from .model_management import get_modelfile_path
from .model_management import load_model
Expand All @@ -13,6 +12,7 @@
from .output import csv2file
from .output import make_parent_dirs
from .output import refresh_file
from .output import save_to_csv_files
from .statistics import edge_homo
from .statistics import node_homo
from .statistics import statistics
1 change: 0 additions & 1 deletion graph_datasets/utils/evaluation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Evalutaion
"""
from .evaluation import evaluate_from_embed_file
from .evaluation import save_to_csv_files
53 changes: 3 additions & 50 deletions graph_datasets/utils/evaluation/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import torch

from ..output import csv2file
from .eval_tools import evaluate_results_nc


Expand Down Expand Up @@ -44,12 +43,12 @@ def evaluate_from_embed_file(
Example:
.. code-block:: python

from graph_datasets import evaluate_embed_file
from graph_datasets import evaluate_from_embed_file

method_name='orderedgnn'
data_name='texas'

clustering_res, classification_res = evaluate_embed_file(
clustering_res, classification_res = evaluate_from_embed_file(
f'{data_name}_{method_name}_embeds.pth',
f'{data_name}_data.pth',
save_path='./save/',
Expand Down Expand Up @@ -102,52 +101,6 @@ def evaluate_from_embed_file(
return clustering_results, classification_results


def save_to_csv_files(
results: dict,
add_info: dict,
csv_name: str,
save_path="./results",
):
"""Save the evaluation results to a local csv file.

Args:
results (dict): Evaluation results document.
add_info (dict): Additional information, such as data set name, method name.
csv_name (str): csv file name to store.
save_path (str, optional): Folder path to store. Defaults to './results'.

Example:
.. code-block:: python

from graph_datasets import evaluate_embed_file
from graph_datasets import save_to_csv_files

method_name='orderedgnn'
data_name='texas'

clustering_res, classification_res = evaluate_embed_file(
f'{data_name}_{method_name}_embeds.pth',
f'{data_name}_data.pth',
save_path='./save/',
)

add_info = {'data': data_name, 'method': method_name,}
save_to_csv_files(clustering_res, add_info, 'clutering.csv')
save_to_csv_files(classification_res, add_info, 'classification.csv')
"""
# save to csv file
results.update(add_info)

# list of values
csv2file(
target_path=os.path.join(save_path, csv_name),
thead=list(results.keys()),
tbody=list(results.values()),
refresh=False,
is_dict=False,
)


# if __name__ == "__main__":
# method_name = 'orderedgnn' # 'selene' 'greet' 'hgrl' 'nwr-gae' 'orderedgnn'
# data_name = 'texas' # 'actor' 'chameleon' 'cornell' 'squirrel' 'texas' 'wisconsin'
Expand All @@ -159,7 +112,7 @@ def save_to_csv_files(
# save_path='/data/gnn/heter/save/',
# quiet=True,
# )
# from graph_datasets.utils import tab_printer
# from graph_datasets.utils import tab_printer, save_to_csv_files
# tab_printer(clu_res, sort=False)
# tab_printer(cls_res, sort=False)

Expand Down
46 changes: 46 additions & 0 deletions graph_datasets/utils/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,49 @@ def csv2file(
dict_writer.writerow(elem)
else:
csv_write.writerow(tbody)


def save_to_csv_files(
results: dict,
add_info: dict,
csv_name: str,
save_path="./results",
) -> None:
"""Save the evaluation results to a local csv file.

Args:
results (dict): Evaluation results document.
add_info (dict): Additional information, such as data set name, method name.
csv_name (str): csv file name to store.
save_path (str, optional): Folder path to store. Defaults to './results'.

Example:
.. code-block:: python

from graph_datasets import evaluate_from_embed_file
from graph_datasets import save_to_csv_files

method_name='orderedgnn'
data_name='texas'

clustering_res, classification_res = evaluate_from_embed_file(
f'{data_name}_{method_name}_embeds.pth',
f'{data_name}_data.pth',
save_path='./save/',
)

add_info = {'data': data_name, 'method': method_name,}
save_to_csv_files(clustering_res, add_info, 'clutering.csv')
save_to_csv_files(classification_res, add_info, 'classification.csv')
"""
# save to csv file
results.update(add_info)

# list of values
csv2file(
target_path=os.path.join(save_path, csv_name),
thead=list(results.keys()),
tbody=list(results.values()),
refresh=False,
is_dict=False,
)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"torch>=1.10.2",
"torch-geometric>=2.0.3",
"torch>=1.12",
"torch-geometric>=2.0",
"torchaudio>=0.10.2",
"torchvision>=0.11.3",
"dgl>=1.1.0",
Expand Down