Package: pygdebias
PyGDebias: Attributed Network Datasets and Fairness-Aware Graph Mining Algorithms1. Citation2. API Cheatsheet3. Installations3.1 Manually3.2pip4. Usage & Examples5. Collected Datasets6. Collected Algorithms7. Performance Leaderboards7.1  Group Fairness7.1.1 GNN-based ones:7.1.2 Non-GNN-based ones:7.2 Counterfactual Fairness7.3 Individual Fairness7.4 Degree-Related FairnessFolder StructureHow to ContributeAuthors & Acknowledgements10. Contact11. ReferencesPyGDebias: Attributed Network Datasets and Fairness-Aware Graph Mining AlgorithmsGraph mining algorithms have been playing a critical role in a plethora of areas. However, most of the existing ones lack fairness consideration. Consequently, they may deliver biased predictions toward certain demographic subgroups or individuals. To better understand existing debiasing techniques and facilitate the deployment of fairness-aware graph mining algorithms, we developed this libraryPyGDebiasfeatured for built-in datasets and implementations of popular fairness-aware graph mining algorithms for the study of algorithmic fairness on graphs.Specifically, this open-source libraryPyGDebiasaims to provide a systematic schema to load datasets and compare different debiasing techniques for graph learning algorithms. Specifically, 26 graph datasets (including 24 commonly used ones and two newly constructed ones, AMiner-L and AMiner-S) are collected, and 13 algorithms are implemented in this library.1. CitationOur survey paper "Fairness in Graph Mining: A Survey" has been released on arxiv[PDF]. If you findPyGDebiashelpful, we would appreciate citations to the following paper:@article{dong2022fairness,
  title={Fairness in Graph Mining: A Survey},
  author={Dong, Yushun and Ma, Jing and Chen, Chen and Li, Jundong},
  journal={arXiv preprint arXiv:2204.09888},
  year={2022}
}or:Dong, Y., Ma, J., Chen, C., & Li, J. (2022). Fairness in Graph Mining: A Survey. arXiv preprint arXiv:2204.09888.2. API CheatsheetWe summarize the basic API of the implemented graph mining algorithms as below.fit(): Execute the training process for the initiated graph mining algorithm.predict(): Evaluate the trained graph mining algorithm on the test set.3. InstallationsHere, we provide guidelines for setting up the library. There are basically 2 ways to install it3.1 Manually# Set up the environmentcondacreate-nPyGDebiaspython=3.9
condaactivatePyGDebias# Installationgitclonehttps://github.com/yushundong/PyGDebias.git
pipinstalltorch==1.12.0+cu116-fhttps://download.pytorch.org/whl/torch_stable.html
pipinstallPyGDebias/-fhttps://data.pyg.org/whl/torch-1.12.0%2Bcu116.html-fhttps://download.pytorch.org/whl/torch_stable.html3.2pippipinstalltorch==1.12.0+cu116-fhttps://download.pytorch.org/whl/torch_stable.html
pipinstallpygdebias-fhttps://data.pyg.org/whl/torch-1.12.0%2Bcu116.html-fhttps://download.pytorch.org/whl/torch_stable.html4. Usage & Examplesfromdataloadingimportload_datafromPyGDebias.GUIDEimportGUIDE# Load a dataset.# Available choices: 'credit', 'german', 'recidivism', 'facebook', 'pokec_z', 'pokec_n', 'nba', 'twitter', 'google+', 'LCC', 'LCC_small', 'cora', 'citeseer', 'pubmed', 'amazon', 'yelp', 'epinion', 'ciao', 'dblp', 'filmtrust', 'lastfm', 'ml-100k', 'ml-1m', 'ml-20m', 'oklahoma', 'unc28'.adj,features,labels,idx_train,idx_val,idx_test,sens,sens_idx=load_data('credit')# Initiate the model (with default parameters).model=GUIDE()# Train the model.model.fit(adj,features,idx_train,idx_val,idx_test,labels,sens)# Evaluate the model.model.predict()5. Collected Datasets26 graph datasets are collected in this library, including 24 commonly used ones and two newly constructed ones (Aminer-L and Aminer-S).
We provide their descriptions as follows.Facebook: Facebook has anonymized features for each node representative of various attributes of a person’s Facebook profile.Pokec_z & Pokec_n:  The two datasets are sampled from Pokec by province. Pokec contains anonymized data of the whole social network in 2012, in which the profiles contain gender, age, hobbies, interest, education, working field and etc.NBA: This dataset is an extension of a Kaggle dataset containing around 400 NBA basketball players. Features include the performance statistics of players in the 2016-2017 season and other various information e.g., nationality, age, and salary.German: The dataset is a credit graph which has 1,000 nodes representing clients in a German bank that are connected based on the similarity of their credit accounts.Credit: Credit contains individuals which are connected based on the similarity of their spending and payment patterns.Recidivism: Recidivism has 18,876 nodes representing defendants who got released on bail at the U.S state courts during 1990-2009, where defendants are connected based on the similarity of past criminal records and demographics.Google+: The dataset is created by data collected from a social networking platform developed by Google.AMiner-L&AMiner-S:AMiner-LandAMiner-Sare co-author networks with sensitive attributes ready for algorithmic fairness study on graphs. Specifically, we construct AMiner-L (titled 'LCC' in our built-in data loader) and AMiner-S (titled 'LCC_small' in our built-in data loader) based on the AMiner network [1]. To construct the two datasets, we first filter out the nodes in the AMiner network with incomplete information. Then we adopt two different approaches to sample a connected network from the filtered dataset: AMiner-L is a subgraph sampled with random walk, while AMiner-S is the largest connected component of the filtered AMiner network. In both datasets, nodes represent the researchers in different fields, and edges denote the co-authorship between researchers. The sensitive attribute is the continent of the affiliation each researcher belongs to, and the labels of nodes represent the primary research field of each researcher.Cora: The Cora dataset is a collection of computer science research papers categorized into different topics.Citeseer: The CiteSeer dataset is a digital library of scientific articles, primarily focused on computer science, featuring citation relationships and widely utilized for research in information retrieval and citation network analysis.Pubmed: Pubmed contains citation networks that consider articles as nodes and descriptions of articles as their nodal attributes.Amazon: The dataset constitutes a respective knowledge graph with entities and relations crawled from Amazon. The collection consists of four different domains: CDs and Vinyl, Clothing, Cell Phones, and Beauty.Yelp: The Yelp dataset is a large collection of user-generated reviews and associated ratings for businesses, encompassing various industries and geographical locations.Ciao: The Ciao dataset is a comprehensive collection of product reviews and ratings from the Ciao shopping website.DBLP: The DBLP dataset is a bibliographic database containing computer science research publications, authors, and their relationships.Filmtrust: The Filmtrust dataset is a collection of movie ratings and trust relationships between users.Lastfm: The Last.fm dataset is a music dataset that contains user listening histories, artist information, and user preferences.ML100k: The ML-100K dataset is a widely used benchmark dataset in the field of recommender systems, containing movie ratings and user information for evaluating collaborative filtering algorithms.ML1m: The ML-1M dataset is a movie rating dataset that contains one million ratings from users on various movies.ML20m: The ML-20M dataset is a larger movie rating dataset consisting of 20 million ratings from users on a vast collection of movies.Oklahoma: Oklahoma is a dataset composed of social networks of the University of Oklahoma. A link represents a friendship relation in
social media, and every user has a profile for vertex features, including student/faculty status, gender, and major,UNC: UNC is a dataset of social networks in the University of North Carolina at Chapel Hill.We provide their statistics as follows.#Nodes#Edges#FeaturesFacebook1,04553,498573Pokec_z67,796882,765276Pokec_n66,569729,129265NBA40316,57095German1,00024,97027Credit30,000200,52613Recidivism18,876403,97718Google+290,4683,6012,532AMiner-L129,726591,0395,694AMiner-S39,42452,4605,694Cora2,7084,7511,433Citeseer3,3124,1943,703Pubmed19,71788,648500Amazon2,549 (item) 2 (genre)2,549N/AYelp2,834 (item) 2 (genre)2,834N/ACiao7,375 (user)  106,797 (product)57,544N/ADBLP22,166 (user)  296,277 (product)355,813N/AFilmtrust1,508 (user) 2,071 (item)35,497N/ALastfm1,892 (customer) 17,632 (producer)92,800N/AML100k943 (user) 1,682 (item)100,0004ML1m6,040 (user) 3,952 (item)1,000,2094ML20m138,493 (user) 27,278 (item)20,000,263N/AOklahoma3,11173,230N/AUNC4,01865,287N/A6. Collected Algorithms13 different methods in total are implemented in this library. We provide an overview of their characteristics as follows.FairGNN: FairGNN is a GNN model designed to address fairness issues in graph-based tasks by incorporating fairness regularization techniques, ensuring equitable treatment of different groups in the learned representations and predictions.EDITS: EDITS approximates the inputs’ discrimination via Wasserstein distance and directly minimizes it between sensitive and nonsensitive groups by pruning the graph topology and node features.CrossWalk:  CrossWalk is a method that enhances fairness in graph algorithms by biasing random walks to cross group boundaries and extends the range of the weighting including multi-hop neighbors.UGE: UGE learns node embeddings from an underlying bias-free graph, which is not influenced by sensitive node attributes to deal with the unbiased graph embedding problem.FairVGNN: FairVGNN is an advanced model that intelligently masks feature channels linked to sensitive attributes and dynamically fine-tunes encoder weights to reduce the impact of sensitive information, resulting in a fairer and unbiased machine learning algorithm.FairEdit: NIFTY goes beyond simply removing biases from the input graph during training. It takes a proactive approach by introducing artificial nodes and edges to address biases comprehensively, resulting in a more balanced and unbiased learning process.NIFTY: NIFTY is a groundbreaking approach designed to improve counterfactual fairness and stability of node representations. It achieves this through the utilization of a novel triplet-based objective function and layer-wise weight normalization using the Lipschitz constant, ensuring enhanced performance and reliability.GEAR: GEAR tackles graph unfairness through two key mechanisms: counterfactual graph augmentation and an adversarial learning approach that focuses on learning embeddings that are insensitive to sensitive attributes. These techniques collectively contribute to the effective mitigation of unfairness in graph-based models.InFoRM: InFoRM utilizes the similarity matrix of nodes to assess the individual fairness of GNNs. By incorporating a variant of the (d1, d2)-Lipschitz property, it addresses the challenge of achieving individual fairness solely based on node features, considering the interconnectedness of nodes in a graph.REDRESS: REDRESS introduces a plug-and-play framework that leverages individual fairness measures from a ranking perspective. This approach optimizes the training of Graph Neural Networks (GNNs) to simultaneously maximize utility and promote ranking-based individual fairness. By learning to rank, the framework ensures consistent relative ranking orders of node pairs in both input and output spaces.GUIDE: GUIDE is an innovative GNN framework that leverages the similarity matrix of individuals to learn personalized attention mechanisms. This enables the achievement of individual fairness while minimizing disparities at the group level.RawlsGCN: RawlsGCN integrates the Rawlsian difference principle into GCN, mitigating degree-related unfairness and improving its overall performance.MethodsDebiasing TechniqueFairness NotionsPaper & CodeFairGNN [2]Adversarial LearningGroup Fairness[Paper][Code]EDITS [3]Edge RewiringGroup Fairness[Paper][Code]FairWalk [4]RebalancingGroup Fairness[Paper][Code]CrossWalk [5]RebalancingGroup Fairness[Paper][Code]UGE [6]Edge RewiringGroup Fairness[Paper][Code]FairVGNN [7]Adversarial LearningGroup Fairness[Paper][Code]FairEdit [8]Edge RewiringGroup Fairness[Paper][Code]NIFTY [9]Optimization with RegularizationGroup/Counterfactual Fairness[Paper][Code]GEAR [10]Edge RewiringGroup/Counterfactual Fairness[Paper][Code]InFoRM [11]Optimization with RegularizationIndividual Fairness[Paper][Code]REDRESS [12]Optimization with RegularizationIndividual Fairness[Paper][Code]GUIDE [13]Optimization with RegularizationIndividual Fairness[Paper][Code]RawlsGCN [14]RebalancingDegree-Related Fairness[Paper][Code]7. Performance LeaderboardsWe summarize the performances of the implemented 13 graph mining algorithms/frameworks by fairness notions, including group fairness, individual fairness, counterfactual fairness, and degree-related fairness.7.1  Group Fairness7.1.1 GNN-based ones:We present the evaluation results of both utility (including AUCROC, F1 score, and accuracy) and fairness (including $\Delta_{SP}$ and $\Delta_{EO}$) on Credit and Recidivism below.CreditCreditCreditCreditCreditRecidivismRecidivismRecidivismRecidivismRecidivismAUCROCF1Acc$\Delta_{SP}$$\Delta_{EO}$AUCROCF1Acc$\Delta_{SP}$$\Delta_{EO}$GCN_Vanilla0.722±0.0050.876±0.0020.784±0.0040.160±0.1100.108±0.0730.865±0.0200.672±0.0310.804±0.0140.094±0.0120.130±0.023FairGNN0.729±0.0040.879±0.0020.790±0.0040.022±0.0070.020±0.0050.929±0.0020.820±0.0040.880±0.0020.073±0.0060.046±0.006NIFTY0.717±0.0000.876±0.0000.782±0.0010.019±0.0190.014±0.0100.841±0.0060.403±0.0080.716±0.0020.017±0.0010.006±0.003EDITS0.667±0.0120.876±0.0000.779±0.0000.005±0.0020.004±0.0020.847±0.0260.607±0.0580.773±0.0290.026±0.0120.013±0.001FairVGNN0.654±0.0340.865±0.0180.772±0.0150.030±0.0400.023±0.0320.826±0.0090.722±0.0150.796±0.0200.090±0.0090.089±0.014FairEdit0.666±0.0670.809±0.0320.716±0.0320.107±0.0460.098±0.0450.884±0.0070.798±0.0090.852±0.0070.070±0.0020.044±0.0027.1.2 Non-GNN-based ones:We present the evaluation results of fairness (including classification accuracy on the learned embeddings) on Pokec_z and Pokec_n below.Classification Acc of Gender on Pokec_zClassification Acc of Gender on Pokec_nFairWalk0.4962 ± 0.00310.5016 ± 0.0036CrossWalk0.4943 ± 0.00070.5047 ± 0.0036UGE-C0.4908 ± 0.000080.5002 ± 0.00017.2 Counterfactual FairnessWe present the evaluation results of both utility (including AUCROC, F1 score, and accuracy) and fairness (including $\Delta_{SP}$, $\Delta_{EO}$, $\delta_{CF}$, and $R^2$) on Credit and Recidivism below.CreditCreditCreditCreditCreditCreditCreditRecidivismRecidivismRecidivismRecidivismRecidivismRecidivismRecidivismAUCROCF1Acc$\Delta_{SP}$$\Delta_{EO}$$\delta_{CF}$$R^2$AUCROCF1Acc$\Delta_{SP}$$\Delta_{EO}$$\delta_{CF}$$R^2$GCN_Vanilla0.684 ± 0.0190.794± 0.0270.698± 0.0280.108± 0.0310.087± 0.0350.042± 0.0290.022± 0.0140.885 ± 0.0180.782 ± 0.0230.838 ± 0.0170.075 ± 0.0140.023 ± 0.0190.132 ± 0.0590.075 ± 0.028NIFTY-GCN0.685 ± 0.0070.792± 0.0070.697± 0.0070.106± 0.0210.097± 0.0240.004± 0.0040.017± 0.0030.799 ± 0.0510.669 ± 0.0500.752 ± 0.0650.036 ± 0.0220.019 ± 0.0150.031 ± 0.0170.025 ± 0.018GEAR-GCN0.740 ± 0.0080.835± 0.0080.755± 0.0110.104± 0.0130.086± 0.0180.001± 0.0010.010± 0.0030.896 ± 0.0160.800 ± 0.0310.852 ± 0.0260.058 ± 0.0170.019 ± 0.0230.003 ± 0.0020.038 ± 0.0127.3 Individual FairnessWe present the evaluation results of both utility (including AUCROC) and fairness (including IF, GDIF, and Ranking-based IF) on Credit and Recidivism below.CreditCreditCreditCreditRecidivismRecidivismRecidivismRecidivismAUCROCIF (in $10^3$)GDIFRanking-based IFAUCIF (in $10^3$)GDIFRanking-Based IFGCN0.666±0.023190.408±135.4121.628±0.5960.611±0.0030.962±0.0011.32e6±6.19e51.12±0.0010.965±0.001InFoRM0.645±0.01023.560±8.7602.422±0.1430.621±0.0140.651±0.04311.606±4.281.106±0.1330.971±0.001REDRESS0.570±0.0058.827e11±1.95e113.048±0.3010.913±0.0050.687±0.0674.0393e12±6.84e121.816±0.5940.980±0.002GUIDE0.632±0.0080.337±0.0631.003±0.0020.665±0.0100.797±0.0249.629±0.8311.006±0.0030.972±0.0017.4 Degree-Related FairnessWe present the evaluation results of both utility (including accuracy) and fairness (including bias according to Rawlsian difference principle) on Amazon-Photo dataset below.AccuracyBias (according to Rawlsian difference principle)GCN0.8262 ±0.00900.5033±0.1552RawlsGCN0.8708 ± 0.01340.0782±0.0071Folder Structure.├── LICENSE├── MANIFEST.in├── README.md├── docs├── pygdebias│   ├──init.py│   ├── datasets│   ├── debiasing│   └── metrics├── requirements.txt├── setup.cfg└── setup.pyHow to ContributeYou are welcome to become part of this project. Seecontribute guidefor more information.Authors & AcknowledgementsYushun Dong, Song Wang, Zaiyi Zheng, Zhenyu Lei, Jing Ma, Chen Chen, Jundong LiWe extend our heartfelt appreciation to everyone who has contributed to and will contribute to this work.10. ContactReach out to us by submitting an issue report or sending an email toyd6eb@virginia.edu.11. References[1]Tang, J., Zhang, J., Yao, L., Li, J., Zhang, L., & Su, Z. (2008, August). Arnetminer: extraction and mining of academic social networks. In Proceedings of the 14th ACM SIGKDD international conference on Knowledge discovery and data mining (pp. 990-998).[2]Dai, E., & Wang, S. (2021, March). Say no to the discrimination: Learning fair graph neural networks with limited sensitive attribute information. InProceedings of the 14th ACM International Conference on Web Search and Data Mining(pp. 680-688).[3]Dong, Y., Liu, N., Jalaian, B., & Li, J. (2022, April). Edits: Modeling and mitigating data bias for graph neural networks. InProceedings of the ACM Web Conference 2022(pp. 1259-1269).[4]Rahman, T., Surma, B., Backes, M., & Zhang, Y. (2019). Fairwalk: Towards fair graph embedding. InProceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence 2022(pp. 3289-3295).[5]Khajehnejad, A., Khajehnejad, M., Babaei, M., Gummadi, K. P., Weller, A., & Mirzasoleiman, B. (2022, June). CrossWalk: fairness-enhanced node representation learning. In Proceedings of the AAAI Conference on Artificial Intelligence (Vol. 36, No. 11, pp. 11963-11970).[6]Wang, N., Lin, L., Li, J., & Wang, H. (2022, April). Unbiased graph embedding with biased graph observations. InProceedings of the ACM Web Conference 2022(pp. 1423-1433).[7]Wang, Y., Zhao, Y., Dong, Y., Chen, H., Li, J., & Derr, T. (2022). Improving Fairness in Graph Neural Networks via Mitigating Sensitive Attribute Leakage. InProceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining(pp. 1938–1948).[8]Loveland, D., Pan, J., Bhathena, A. F., & Lu, Y. (2022). FairEdit: Preserving Fairness in Graph Neural Networks through Greedy Graph Editing. arXiv preprint arXiv:2201.03681.[9]Agarwal, C., Lakkaraju, H., & Zitnik, M. (2021, December). Towards a unified framework for fair and stable graph representation learning. In Uncertainty in Artificial Intelligence (pp. 2114-2124). PMLR.[10]Ma, J., Guo, R., Wan, M., Yang, L., Zhang, A., & Li, J. (2022, February). Learning fair node representations with graph counterfactual fairness. In Proceedings of the Fifteenth ACM International Conference on Web Search and Data Mining (pp. 695-703).[11]Kang, J., He, J., Maciejewski, R., & Tong, H. (2020, August). Inform: Individual fairness on graph mining. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (pp. 379-389).[12]Dong, Y., Kang, J., Tong, H., & Li, J. (2021, August). Individual fairness for graph neural networks: A ranking based approach. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining (pp. 300-310).[13]Song, W., Dong, Y., Liu, N., & Li, J. (2022, August). GUIDE: Group Equality Informed Individual Fairness in Graph Neural Networks. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (pp. 1625-1634).[14]Kang, J., Zhu, Y., Xia, Y., Luo, J., & Tong, H. (2022, April). Rawlsgcn: Towards rawlsian difference principle on graph convolutional network. In Proceedings of the ACM Web Conference 2022 (pp. 1214-1225).