Productivity
A Python Library for Social Event Detection
Social Event Detection (SED) is a cutting-edge research area in AI and NLP that focuses on:
SocialED is your all-in-one Python toolkit for Social Event Detection that offers:
SocialED includes 19 social event detection algorithms. For consistency and accessibility, SocialED is developed on top of DGL and PyTorch, and follows the API design of PyOD and PyGOD. See examples below for detecting outliers with SocialED in 7 lines!
SocialED plays a crucial role in various downstream applications, including:
SocialED
āāā LICENSE
āāā MANIFEST.in
āāā README.rst
āāā docs
āāā SocialED
ā āāā __init__.py
ā āāā datasets
ā āāā detector
ā āāā utils
ā āāā tests
ā āāā metrics
āāā requirements.txt
āāā setup.cfg
āāā setup.py
It is recommended to use pip for installation. Please make sure the latest version is installed, as PyGOD is updated frequently:
.. code-block:: bash
pip install SocialED # normal install pip install --upgrade SocialED # or update if needed
Alternatively, you could clone and run setup.py file:
.. code-block:: bash
# Set up the environment
conda create -n SocialED python=3.8
conda activate SocialED
# Installation
git clone https://github.com/RingBDStack/SocialED.git
cd SocialED
pip install -r requirements.txt
pip install .
Required Dependencies\ :
The library integrates methods ranging from classic approaches like LDA and BiLSTM to specialized techniques such as KPGNN, QSGNN, FinEvent, and HISEvent. Despite significant advancements in detection methods, deploying these approaches or conducting comprehensive evaluations has remained challenging due to the absence of a unified framework. SocialED addresses this gap by providing a standardized platform for researchers and practitioners in the SED field.
SocialED implements the following algorithms:
Methods | Year | Backbone | Scenario | Supervision | Paper |
---|---|---|---|---|---|
LDA | 2003 | Topic | Offline | Unsupervised | Blei2003lda |
BiLSTM | 2005 | Deep learning | Offline | Supervised | Graves2005bilstm |
Word2Vec | 2013 | Word embeddings | Offline | Unsupervised | Mikolov2013word2vec |
GloVe | 2014 | Word embeddings | Offline | Unsupervised | Pennington2014glove |
WMD | 2015 | Similarity | Offline | Unsupervised | Kusner2015wmd |
BERT | 2018 | PLMs | Offline | Unsupervised | Devlin2018bert |
SBERT | 2019 | PLMs | Offline | Unsupervised | Reimers2019sbert |
EventX | 2020 | Community | Offline | Unsupervised | Liu2020eventx |
CLKD | 2021 | GNNs | Online | Supervised | Ren2021clkd |
KPGNN | 2021 | GNNs | Online | Supervised | Cao2021kpgnn |
FinEvent | 2022 | GNNs | Online | Supervised | Peng2022finevent |
QSGNN | 2022 | GNNs | Online | Supervised | Ren2022qsgnn |
ETGNN | 2023 | GNNs | Offline | Supervised | Ren2023etgnn |
HCRC | 2023 | GNNs | Online | Unsupervised | Guo2023hcrc |
UCLSED | 2023 | GNNs | Offline | Supervised | Ren2023uclsad |
RPLMSED | 2024 | PLMs | Online | Supervised | Li2024rplmsed |
HISEvent | 2024 | Community | Online | Unsupervised | Cao2024hisevent |
ADPSEMEvent | 2024 | Community | Online | Unsupervised | Yang2024adpsemevent |
HyperSED | 2024 | Community | Online | Unsupervised | Yu2024hypersed |
Below is a summary of all datasets supported by SocialED:
Dataset | Language | Events | Texts | Long tail |
---|---|---|---|---|
Event2012 | English | 503 | 68,841 | No |
Event2018 | French | 257 | 64,516 | No |
Arabic_Twitter | Arabic | 7 | 9,070 | No |
MAVEN | English | 164 | 10,242 | No |
CrisisLexT26 | English | 26 | 27,933 | No |
CrisisLexT6 | English | 6 | 60,082 | No |
CrisisMMD | English | 7 | 18,082 | No |
CrisisNLP | English | 11 | 25,976 | No |
HumAID | English | 19 | 76,484 | No |
Mix_Data | English | 5 | 78,489 | No |
KBP | English | 100 | 85,569 | No |
Event2012_100 | English | 100 | 15,019 | Yes |
Event2018_100 | French | 100 | 19,944 | Yes |
Arabic_7 | Arabic | 7 | 3,022 | Yes |
Event2012: A comprehensive dataset containing 68,841 annotated English tweets spanning 503 distinct event categories. The data was collected over a continuous 29-day period, providing rich temporal context for event analysis.
Event2018: A French language dataset comprising 64,516 annotated tweets across 257 event categories. The collection period covers 23 consecutive days, offering valuable insights into French social media event patterns.
Arabic_Twitter: A specialized dataset of 9,070 annotated Arabic tweets focusing on seven major catastrophic events. This collection enables research into crisis-related social media behavior in Arabic-speaking regions.
MAVEN: A diverse English dataset containing 10,242 annotated texts distributed across 164 event types. Carefully curated to support development of domain-agnostic event detection models.
CrisisLexT26: An emergency-focused collection of 27,933 tweets covering 26 distinct crisis events. This dataset enables research into social media dynamics during critical situations.
CrisisLexT6: A focused dataset of 60,082 tweets documenting 6 major crisis events. Provides deep insights into public communication patterns during large-scale emergencies.
CrisisMMD: A multimodal dataset featuring 18,082 manually annotated tweets from 7 major natural disasters in 2017. Covers diverse events including earthquakes, hurricanes, wildfires, and floods across multiple geographical regions.
CrisisNLP: A comprehensive crisis-related collection of 25,976 tweets spanning 11 distinct events. Includes human-annotated data, lexical resources, and specialized tools for crisis information analysis.
HumAID: An extensive dataset of 76,484 manually annotated tweets documenting 19 major natural disasters between 2016-2019. Provides broad coverage of various disaster types across different geographical and temporal contexts.
Mix_data: A rich composite dataset integrating multiple crisis-related collections:
KBP: A structured dataset containing 85,569 texts across 100 event types, designed for benchmarking information extraction systems and event knowledge base population.
Event2012_100: A carefully curated subset containing 15,019 tweets distributed across 100 events. Features natural class imbalance with event sizes ranging from 55 to 2,377 tweets (imbalance ratio ~43).
Event2018_100: A French language subset comprising 19,944 tweets across 100 events. Exhibits significant class imbalance with event sizes from 27 to 4,189 tweets (imbalance ratio ~155).
Arabic_7: A focused Arabic dataset containing 3,022 tweets distributed across 100 events. Shows natural variation in event sizes from 7 to 312 tweets (imbalance ratio ~44).
CrisisLexT7: A dataset of 1,959 tweets across 7 events. Features a natural imbalance with event sizes ranging from 15 to 989 tweets (imbalance ratio ~66).
Dataset | Language | Events | Texts | Long tail |
---|---|---|---|---|
Event2012 | English | 503 | 68,841 | No |
Event2018 | French | 257 | 64,516 | No |
Arabic_Twitter | Arabic | 7 | 9,070 | No |
MAVEN | English | 164 | 10,242 | No |
CrisisLexT26 | English | 26 | 27,933 | No |
CrisisLexT6 | English | 6 | 60,082 | No |
CrisisMMD | English | 7 | 18,082 | No |
CrisisNLP | English | 11 | 25,976 | No |
HumAID | English | 19 | 76,484 | No |
Mix_Data | English | 5 | 78,489 | No |
KBP | English | 100 | 85,569 | No |
Event2012_100 | English | 100 | 15,019 | Yes |
Event2018_100 | French | 100 | 19,944 | Yes |
Arabic_7 | Arabic | 7 | 3,022 | Yes |
CrisisLexT7 | English | 7 | 1,959 | Yes |
SocialED is compatible with Python 3.8 and above, and leverages well-established deep learning frameworks like PyTorch and Hugging Face Transformers for efficient model training and inference, supporting both CPU and GPU environments. In addition to these core frameworks, SocialED also integrates NumPy, SciPy, and scikit-learn for data manipulation, numerical operations, and machine learning tasks, ensuring versatility and performance across a range of workflows.
Inspired by the API designs of established frameworks, we developed a unified API for all detection algorithms in SocialED:
preprocess
provides a flexible framework for handling various preprocessing tasks, such as graph construction and tokenizationfit
trains the detection algorithms on the preprocessed data, adjusting model parameters and generating necessary statistics for predictionsdetection
uses the trained model to identify events from the input data, returning the detected eventsevaluate
assesses the performance of the detection results by comparing predictions with ground truth data, providing metrics like precision, recall and F1-scorefrom SocialED.dataset import MAVEN # Load the dataset
dataset = MAVEN().load_data() # Load "arabic_twitter" dataset
from SocialED.detector import KPGNN # Import KPGNN model
args = args_define().args # Get training arguments
kpgnn = KPGNN(args, dataset) # Initialize KPGNN model
kpgnn.preprocess() # Preprocess data
kpgnn.fit() # Train the model
pres, trus = kpgnn.detection() # Detect events
kpgnn.evaluate(pres, trus) # Evaluate detection results
SocialED is built with a modular design to improve reusability and reduce redundancy. It organizes social event detection into distinct modules:
preprocessing
modeling
evaluation
The library provides several utility functions including:
utils.tokenize_text
and utils.construct_graph
for data preprocessingmetric
for evaluation metricsutils.load_data
for built-in datasets99% code coverage
Expanding Algorithms and Datasets
Enhancing Intelligent Functions
Supporting Real-time Detection
š Kun Zhang
Beihang University
š§ zhangkun23@buaa.edu.cn
š Xiaoyan Yu
Beijing Institute of Technology
š§ xiaoyan.yu@bit.edu.cn
š Pu Li
Kunming University of Science and Technology
š§ lip@stu.kust.edu.cn
š Ye Tian
Laboratory for Advanced Computing and Intelligence Engineering
š§ sweetwild@mail.ustc.edu.cn
š Hao Peng (Corresponding author)
Beihang University
š§ penghao@buaa.edu.cn
š Philip S. Yu
University of Illinois at Chicago
š§ psyu@uic.edu
@misc{zhang2024socialedpythonlibrarysocial,
title={SocialED: A Python Library for Social Event Detection},
author={Kun Zhang and Xiaoyan Yu and Pu Li and Hao Peng and Philip S. Yu},
year={2024},
eprint={2412.13472},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2412.13472},
}
D.M. Blei, A.Y. Ng, and M.I. Jordan. Latent Dirichlet allocation. Journal of Machine Learning Research, 3(Jan):993-1022, 2003.
A. Graves and J. Schmidhuber. Framewise phoneme classification with bidirectional LSTM and other neural network architectures. Neural Networks, 18(5-6):602-610, 2005.
T. Mikolov, K. Chen, G. Corrado, and J. Dean. Efficient estimation of word representations in vector space. In International Conference on Learning Representations, pages 1-12, 2013.
J. Pennington, R. Socher, and C.D. Manning. GloVe: Global Vectors for Word Representation. In Proceedings of EMNLP, pages 1532-1543, 2014.
M. Kusner, Y. Sun, N. Kolkin, and K. Weinberger. From word embeddings to document distances. In International Conference on Machine Learning, pages 957-966, 2015.
J. Devlin, M.W. Chang, K. Lee, and K. Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of NAACL-HLT, pages 4171-4186, 2019.
N. Reimers and I. Gurevych. Sentence-BERT: Sentence embeddings using Siamese BERT-networks. In Proceedings of EMNLP-IJCNLP, pages 3980-3990, 2019.
B. Liu, F.X. Han, D. Niu, L. Kong, K. Lai, and Y. Xu. Story forest: Extracting events and telling stories from breaking news. ACM Transactions on Knowledge Discovery from Data, 14(3):1-28, 2020.
J. Ren, H. Peng, L. Jiang, Z. Liu, J. Wu, and P.S. Yu. Toward cross-lingual social event detection with hybrid knowledge distillation. ACM Transactions on Knowledge Discovery from Data, 18(9):1-36, 2024.
Y. Cao, H. Peng, J. Wu, Y. Dou, J. Li, and P.S. Yu. Knowledge-preserving incremental social event detection via heterogeneous GNNs. In Proceedings of The Web Conference, pages 3383-3395, 2021.
H. Peng, R. Zhang, S. Li, et al. Reinforced, incremental and cross-lingual event detection from social messages. IEEE Transactions on Pattern Analysis and Machine Intelligence, 45(1):980-998, 2022.
J. Ren, L. Jiang, H. Peng, Y. Cao, J. Wu, P.S. Yu, and L. He. From known to unknown: Quality-aware self-improving graph neural network for open set social event detection. In Proceedings of CIKM, pages 1696-1705, 2022.
J. Ren, L. Jiang, H. Peng, Z. Liu, J. Wu, and P.S. Yu. Evidential temporal-aware graph-based social event detection via Dempster-Shafer theory. In IEEE ICWS, pages 331-336, 2022.
Y. Guo, Z. Zang, H. Gao, X. Xu, R. Wang, L. Liu, and J. Li. Unsupervised social event detection via hybrid graph contrastive learning and reinforced incremental clustering. Knowledge-Based Systems, 284:111225, 2024.
J. Ren, L. Jiang, H. Peng, Z. Liu, J. Wu, and P.S. Yu. Uncertainty-guided boundary learning for imbalanced social event detection. IEEE Transactions on Knowledge and Data Engineering, 2023.
P. Li, X. Yu, H. Peng, Y. Xian, L. Wang, L. Sun, J. Zhang, and P.S. Yu. Relational prompt-based pre-trained language models for social event detection. ACM Transactions on Information Systems, 43(1):1-43, 2024.
Y. Cao, H. Peng, Z. Yu, and P.S. Yu. Hierarchical and incremental structural entropy minimization for unsupervised social event detection. In Proceedings of AAAI, 38(8):8255-8264, 2024.
Z. Yang, Y. Wei, H. Li, et al. Adaptive Differentially Private Structural Entropy Minimization for Unsupervised Social Event Detection. In Proceedings of CIKM, pages 2950-2960, 2024.
X. Yu, Y. Wei, S. Zhou, Z. Yang, L. Sun, H. Peng, L. Zhu, and P.S. Yu. Towards effective, efficient and unsupervised social event detection in the hyperbolic space. In Proceedings of AAAI, 2025.