Inference and visualization of community structure in attributed hypergraphs
This repository provides a statistical framework for incorporating node attribute data into the inference of community structure in a hypergraph, employing a stochastic block model called HyperNEO [1].
I provide code for the HyperNEO in Python.
I confirmed that the code runs in Python 3.9.0. See requirements.txt for the libraries used in our code.
(1) Clone this repository:
git clone git@github.com:kazuibasou/hyperneo.git
(2) Run the command at hyperneo/
:
mkdir data figs
Use four empirical attributed hypergraphs publicly available.
(1) Download preprocessed_real_data.zip
in the data set [2] and unzip it.
(2) Find the files workspace1.npz
, workspace1_meta.csv
, hospital.npz
, and hospital_meta.csv
in the unzipped folder.
(3) Make folders named workplace
and hospital
in the folder hyperneo/data/
.
(4) Put the files workspace1.npz
and workspace1_meta.csv
in the folder hyperneo/data/workplace/
.
(5) Put the files hospital.npz
and hospital_meta.csv
in the folder hyperneo/data/hospital/
.
Download contact-high-school.zip
in the data set [3] and unzip it in the folder hyperneo/data/
.
Download contact-primary-school.zip
in the data set [4] and unzip it in the folder hyperneo/data/
.
This generates the following structure of the directory.
hyperneo/data/
├ contact-high-school/
├ contact-primary-school/
├ hospital/
└ workplace/
Run the following command at hyperneo/
:
python3 main.py
Perform inference and visualization of community structure in the workplace hypergraph by default.
Uncomment any one of lines 7--10 in hyperneo/main.py
to change the data set.
The figures visualizing inferred community structure in the given hypergraph will be saved in hyperneo/figs/
.
See hyperneo/hyperneo.ipynb
for more details.
[1] Kazuki Nakajima and Takeaki Uno. Inferring community structure in attributed hypergraphs using stochastic block models. 2024. [arXiv].
[2] Nicolo Ruggeri, 2023, "Real and Synthetic data for Hypergraph Benchmarking (processed for the Hy-MMSBM generative model)", [link], Edmond, V1.
[3] Austin R. Benson. contact-high-school dataset (labeled). [link].
[4] Austin R. Benson. contact-primary-school dataset (labeled). [link].
This source code is released under the MIT License, see LICENSE.txt.
- Kazuki Nakajima (https://kazuibasou.github.io)
- nakajima@tmu.ac.jp