{"id":35061330,"url":"https://github.com/lgalke/lifelong-learning","last_synced_at":"2025-12-27T10:40:28.823Z","repository":{"id":94639087,"uuid":"337798714","full_name":"lgalke/lifelong-learning","owner":"lgalke","description":"Lifelong Learning of Graph Neural Networks for Open-World Node Classification","archived":false,"fork":false,"pushed_at":"2023-10-04T12:16:37.000Z","size":145,"stargazers_count":30,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-05T03:25:45.292Z","etag":null,"topics":["continual-learning","deep-learning","evolving-graphs","graph-convolutional-networks","graph-neural-networks","lifelong-learning","node-classification","pytorch","unseen-class-detection"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lgalke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-02-10T17:24:09.000Z","updated_at":"2025-05-07T13:19:24.000Z","dependencies_parsed_at":"2025-04-13T13:19:48.015Z","dependency_job_id":"e807de4d-888d-47f2-908e-b71746f6fb17","html_url":"https://github.com/lgalke/lifelong-learning","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/lgalke/lifelong-learning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgalke%2Flifelong-learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgalke%2Flifelong-learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgalke%2Flifelong-learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgalke%2Flifelong-learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lgalke","download_url":"https://codeload.github.com/lgalke/lifelong-learning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgalke%2Flifelong-learning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28077626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["continual-learning","deep-learning","evolving-graphs","graph-convolutional-networks","graph-neural-networks","lifelong-learning","node-classification","pytorch","unseen-class-detection"],"created_at":"2025-12-27T10:40:28.310Z","updated_at":"2025-12-27T10:40:28.817Z","avatar_url":"https://github.com/lgalke.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lifelong Learning of Graph Neural Networks for Open-World Node Classification\n\n## Papers\n\nLukas Galke, Iacopo Vagliano, Benedikt Franke, Tobias Zielke, Marcel Hoffmann, Ansgar Scherp (2023). [Lifelong Learning on Evolving Graphs Under the Constraints of Imbalanced Classes and New Classes](https://authors.elsevier.com/a/1h1SX3BBjKnulZ). *Neural Networks* 164, 156-176.\n\nLukas Galke, Benedikt Franke, Tobias Zielke, Ansgar Scherp (2021). [Lifelong Learning of Graph Neural Networks for Open-World Node Classification](https://doi.org/10.1109/IJCNN52387.2021.9533412), In *2021 International Joint Conference on Neural Networks (IJCNN)*, IEEE.\n\n```\n@article{galke2023lifelong,\n  title = {Lifelong learning on evolving graphs under the constraints of imbalanced classes and new classes},\n  journal = {Neural Networks},\n  volume = {164},\n  pages = {156-176},\n  year = {2023},\n  issn = {0893-6080},\n  doi = {https://doi.org/10.1016/j.neunet.2023.04.022},\n  url = {https://www.sciencedirect.com/science/article/pii/S0893608023002083},\n  author = {Lukas Galke and Iacopo Vagliano and Benedikt Franke and Tobias Zielke and Marcel Hoffmann and Ansgar Scherp}\n}\n\n@inproceedings{galke2021lifelong,\n  author={Galke, Lukas and Franke, Benedikt and Zielke, Tobias and Scherp, Ansgar},\n  booktitle={2021 International Joint Conference on Neural Networks (IJCNN)},\n  title={Lifelong Learning of Graph Neural Networks for Open-World Node Classification},\n  year={2021},\n  volume={},\n  number={},\n  pages={1-8},\n  doi={10.1109/IJCNN52387.2021.9533412}\n}\n```\n\n## Installation\n\n1. Setup a python virtual environment (recommended)\n2. Install [pytorch](https://pytorch.org/get-started/locally/) as suited to your\n   OS / python package manager\n3. Install [dgl](https://www.dgl.ai/pages/start.html) as suited to your\n   OS / python package manager / CUDA version\n4. Install [torch-geometric](https://github.com/rusty1s/pytorch_geometric)\n5. Install other requirements via `pip install -r requirements.txt` within your\n   copy of this repository. This will include mainly `numpy`, `scipy`, `pandas`, `matplotlib`, `seaborn`, `scikit-learn`.\n\nIn the `requirements.txt` file  we list the versions we have used for our experiments. Newer versions of standard packages will likely work fine.\n\n\n## Get the datasets\n\nThe three datasets of our paper are available [on zenodo](https://zenodo.org/record/3764770).\nDownload the zip files and extract them into the `data` subdirectory, such that the structure looks exactly like this:\n\n- `data/dblp-easy`\n- `data/dblp-hard`\n- `data/pharmabio`\n\n## Example call to run an experiment\n\nThe following exemplary command will run an experiment with a GraphSAGE model with two graph convolutoinal layers and a hidden dimension of 32 on the `dblp-easy` dataset starting evaluation at task corresponding to year 2004 while using 200 annual epochs.\n\n```\npython3 run_experiment.py --seed 42 --backend dgl --model gs-mean --n_hidden 32 --start warm --lr \"0.005\" --history 3 --n_layers 1 --weight_decay 0 --dropout 0.5 --initial_epochs 0 --annual_epochs 200 --dataset \"dblp-easy\" --t_start 2004 --save \"results.csv\"                       \n```\n\nThe results.csv file can be reused for multiple runs (e.g. with different seeds, different models, different datasets), the script appends new results to the file.\nConsult `python3 run_experiment.py -h` for more information. The other variant of our run script `run_experiment_new.py` is similar, but operates on preprocessed tasks (see below).\n\n\n## Tabularize results\n\nTo bring the results into a human readable form, we provide a `tabularize.py` script.\nThis script takes one or more results files as input and groups them depending on the `-g` parameter, which can be multiple attributes.\nExample: *Aggregate results by dataset, history size, model, restart configuration, and learning rate*.\n\n```\npython3 tabularize.py results.csv -g dataset history model start initial_lr\n```\n\nThe script `tabularize_forward_transfer.py` uses the exact grouping as we use for the results of the paper and also computes Forward Transfer (averaged difference between warm and cold restarts).\nNote that each configuration must have a value for both `start=warm` and `start=cold`, such that Forward Transfer can be computed.\n\n\n## Visualize results\n\nYou can visualize with the `visualize.py` script:\n\n```\npython3 visualize.py --style \"window size %RF\" --hue model --col dataset --row start --save plot.png results.csv\n```\n\nwhere results.csv is the file where you've aggregated the results. You can also provide multiple results files, then they will be concatenated before plotting.\n\n## Preprocessing tasks for multiple experiments\n\nConstructing tasks dynamically may take some time during experiments.\nThe tasks can be preprocessed with the script `preprocess_datasets.py`\n**Important:** the Argument t_zero must be one task **before** the first evaluation task, i.e., if you want to start evaluation at time 2004, you must preprocess tasks starting at time 2003.\n\nExample to preprocess tasks for dblp-easy starting at year 2003 with a history size of 3 for models implemented via `dgl`:\n\n```\npython3 preprocess_dataset.py data/dblp-easy` --t_zero 2003 --history 3 --backend dgl data/dblp-easy\n```\n\nIn `scripts/preprocess_all_datasets.bash`, you find a shorthand to preprocess all datasets in all history size configurations from the paper for both backends.\nThis shorthand should be started with the repository's root as working directory and expects the directory structure of `data/` as described above.\n\nThen, you need to use the version of the run script that uses preprocessed tasks, namely `run_experiment_new.py`.\nThe interface of the script is nearly the same as the one of `run_experiment.py`. \nOne difference is that reproducing our ablation study for comparison with once-trained static models is only possible with `run_experiment.py`.\n\n## Full reproduction of the paper's experiments\n\nIn the `experiments/` directory, you find bash scripts to re-run all our experiments.\n\n## Issues?\n\n**Note:** Such that the python/bash scripts within this repository work properly, you must call them from the root directory of this repository.\n\nIf there are any problems with using this repository, feel free to file an issue.\n\n## File Descriptions\n\n| File                              | Description                                                                 |\n| -                                 | -                                                                           |\n| analysis                          | scripts to perform analyses                                                 |\n| datasets.py                       | dataset loading                                                             |\n| lifelong_learning.py              | lifelong learning module                                                    |\n| drift_magnitude.py                | drift magnitude module                                                      |\n| preprocess_dataset.py             | Create a Lifelong Learning Graph Dataset by preprocessing tasks             |\n| experiments                       | Bash scripts to reproduce experiments                                       |\n| scripts                           | Other bash scripts to preprocess/compute tdiff distribution                 |\n| models                            | GNN implementations                                                         |\n| README.md                         | this file                                                                   |\n| requirements.txt                  | dependencies                                                                |\n| run_experiment.py                 | main entry point for running a single experiment                            |\n| run_experiment_new.py             | main entry point for running a single experiment **with preprocessed data** |\n| tabularize.py                     | aggregate results into table                                                |\n| tabularize_forward_transfer.py    | aggregate results into table including Forward Transfer computation         |\n| visualize.py                      | visualize results                                                           |\n\n\n## Notes\n\n- The experiments for inductive vs transductive learning can be found in a different [repository](https://github.com/lgalke/gnn-pretraining-evaluation).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgalke%2Flifelong-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flgalke%2Flifelong-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgalke%2Flifelong-learning/lists"}