spartan2

March 30, 2026 · View on GitHub

spartan2 is a toolkit of data mining algorithms for big graphs and time series, covering three core tasks:

  • Anomaly Detection — spot fraud, surges, and outliers
  • Forecasting — predict future patterns in time series
  • Summarization — compress and describe large graph/time-series structures

Docs: readthedocs | Tutorials: spartan2-tutorials


Why spartan2?

Graphs and time series appear across many domains — social networks, finance, sensor networks, and healthcare. Treating them as sparse tensors (matrices are 2-mode tensors) enables algorithms that are:

  • Efficient — near-linear complexity by exploiting sparsity
  • Interpretable — results backed by mathematical guarantees
  • Accurate — validated on real-world benchmarks

The name spartan = sparse tensor analytics.


Installation

Requires Python ≥ 3.7. We recommend using a Conda environment.

conda create -n spartan python=3.7
conda activate spartan

For users

pip install spartan2

For contributors / running from source

# 1. Clone the repo
git clone git@github.com:BGT-M/spartan2.git

# 2. Install dependencies
conda install --force-reinstall -y --name spartan -c conda-forge --file requirements

# 3. Install in editable mode
pip install -e spartan2
Setting PYTHONPATH (if needed)

Add to ~/.bashrc:

export PYTHONPATH=/<path-to>/spartan2:$PYTHONPATH

Or inside Python:

import sys
sys.path.append("/<path-to>/spartan2")

Quick Start

import spartan as st

# Load a graph as a sparse tensor
graph = st.loadGraph("your_edge_list.csv", col_types=[int, int, float])

# Run anomaly detection (e.g. HoloScope)
model = st.HoloScope(graph)
model.run()
model.result()

See the tutorials repo for runnable Jupyter notebooks for each algorithm.


Algorithms

Graph Mining

AlgorithmTaskPaperYearTutorial
HoloScopeAnomaly Detection[1] HoloScope: Topology-and-Spike Aware Fraud Detection [pdf]2017notebook
EigenspokesAnomaly Detection[3] Eigenspokes: Surprising Patterns in Large Graphs [pdf]2010notebook
EagleMineAnomaly Detection[4] EagleMine: Vision-guided Micro-cluster Anomaly Detection [pdf]2021notebook
FraudarAnomaly Detection[5] Fraudar: Bounding Graph Fraud in the Face of Camouflage [pdf]2016notebook
EigenPulseAnomaly Detection[7] EigenPulse: Detecting Surges in Large Streaming Graphs [pdf]2019notebook
FlowScopeAnomaly Detection[8] FlowScope: Spotting Money Laundering Based on Graphs [pdf]2020notebook
CubeFlowAnomaly Detection[11] CubeFlow: Money Laundering Detection with Coupled Tensors [pdf]2021notebook
MonLADAnomaly Detection[13] MonLAD: Money Laundering Agents Detection in Transaction Streams [pdf]2022
SpecGreedyAnomaly Detection[12] SpecGreedy: Unified Dense Subgraph Detection [pdf]2020notebook
DPGSSummarization[6] DPGS: Degree-Preserving Graph Summarization [pdf]2021notebook
kGrassSummarization[9] GraSS: Graph Structure Summarization [pdf]2010notebook
IATSummarization[10] RSC: Mining and Modeling Temporal Activity in Social Media [pdf]2015notebook

Time Series

AlgorithmTaskPaperYearTutorial
BeatLexSummarization & Forecast[14] BEATLEX: Summarizing and Forecasting Time Series with Patterns [pdf]2017notebook
BeatGANAnomaly Detection[15] BeatGAN: Anomalous Rhythm Detection using Adversarially Generated Time Series [pdf]2019notebook — requires torch and tqdm; uses scipy Pan-Tompkins (no biosppy)

References

  1. Shenghua Liu, Bryan Hooi, and Christos Faloutsos. "HoloScope: Topology-and-Spike Aware Fraud Detection." CIKM 2017.
  2. Shenghua Liu, Bryan Hooi, Christos Faloutsos. "A Contrast Metric for Fraud Detection in Rich Graphs." IEEE TKDE, Vol 31, Issue 12, 2019.
  3. B. Aditya Prakash et al. "Eigenspokes: Surprising Patterns and Scalable Community Chipping in Large Graphs." PAKDD 2010.
  4. Wenjie Feng, Shenghua Liu, et al. "EagleMine: Vision-guided Micro-clusters Recognition and Collective Anomaly Detection." Future Generation Computer Systems, 2021. Also: "Beyond Outliers and On to Micro-Clusters." PAKDD 2019.
  5. Bryan Hooi, Hyun Ah Song, et al. "Fraudar: Bounding Graph Fraud in the Face of Camouflage." KDD 2016.
  6. Houquan Zhou, Shenghua Liu, et al. "DPGS: Degree-Preserving Graph Summarization." SDM 2021.
  7. Jiabao Zhang, Shenghua Liu, et al. "EigenPulse: Detecting Surges in Large Streaming Graphs with Row Augmentation." PAKDD 2019.
  8. Xiangfeng Li, Shenghua Liu, et al. "FlowScope: Spotting Money Laundering Based on Graphs." AAAI 2020.
  9. Kristen LeFevre and Evimaria Terzi. "GraSS: Graph Structure Summarization." SDM 2010.
  10. Alceu Ferraz Costa et al. "RSC: Mining and Modeling Temporal Activity in Social Media." KDD 2015.
  11. Xiaobing Sun, Jiabao Zhang, et al. "CubeFlow: Money Laundering Detection with Coupled Tensors." PAKDD 2021.
  12. Wenjie Feng, Shenghua Liu, et al. "SpecGreedy: Unified Dense Subgraph Detection." ECML-PKDD 2020.
  13. Xiaobing Sun, Wenjie Feng, Shenghua Liu, et al. "MonLAD: Money Laundering Agents Detection in Transaction Streams." WSDM 2022.
  14. Bryan Hooi, Shenghua Liu, et al. "BEATLEX: Summarizing and Forecasting Time Series with Patterns." ECML-PKDD 2017.
  15. Bin Zhou, Shenghua Liu, et al. "BeatGAN: Anomalous Rhythm Detection using Adversarially Generated Time Series." IJCAI 2019.
  16. Shenghua Liu, Bin Zhou, et al. "Time Series Anomaly Detection with Adversarial Reconstruction Networks." IEEE TKDE 2022.