How pericleshat/tacco works
1. What this repo is
TACCO is a research training codebase for disease subtyping from EHR data. Architecturally, it is a data-preparation + graph learning + clustering pipeline rather than a production service.
2. Primary data boundary
The main inputs live under data/raw_data/ and are split by dataset (cradle, mimic3). Each dataset folder contains:
- hyperedges-* for the clinical concept/patient-visit graph structure
- edge-labels-* for supervision or evaluation labels
- node-embeddings-* for precomputed feature vectors
- node_text.json for concept text used by the language model path
This is the clearest boundary between raw dataset artifacts and model-ready tensors.
3. Dataset preprocessing and conversion
preprocessing.py and convert_datasets_to_pygDataset.py form the ingest layer. Their role is to transform the raw EHR artifacts into a graph dataset format compatible with PyTorch Geometric. This is the handoff point from “files on disk” to “structured graph objects” used by training.
4. Text encoding subsystem
bert.py is the language-model side of the pipeline. It likely converts node_text.json into semantic embeddings for clinical concepts using Hugging Face transformers. This makes TACCO a hybrid model: graph structure plus text semantics.
5. Graph / hypergraph modeling
layers.py and models.py contain the core neural architecture. Based on the repo and paper, this layer stack is where patient visits and clinical concepts are embedded and co-clustered using hypergraph-aware message passing. models.py is the orchestration layer; layers.py is the reusable building-block layer.
6. Clustering objective
dec.py suggests a deep embedded clustering component, likely used to refine latent clusters during training. In architecture terms, this is the optimization head that turns learned embeddings into subtyping clusters rather than just representations.
7. Task-guided alignment
alignment.py is a distinct subsystem for aligning the two sides of the co-clustering problem: clinical concepts and patient visits. This is important because TACCO is not only learning node embeddings, but also enforcing consistency between the two node types.
8. Training entry points
There are two main executables:
- train_tacco.py: the main TACCO training pipeline
- train_hypehr.py: a hypergraph-related training path, likely a baseline or supporting model
These are the top-level runtime boundaries where data, model, and loss functions come together.
9. Experiment execution
demo.sh and KDD24.sh are the operational wrappers. demo.sh is a runnable example end-to-end, while KDD24.sh captures the paper’s reported configuration. Training outputs are written to /logs, so the repo is oriented around offline experimentation and reproducibility.
10. External dependencies that shape the architecture
The architecture depends heavily on:
- PyTorch for model training
- torch_geometric / torch-scatter / torch-sparse / torch-cluster for graph and hypergraph operations
- transformers for BERT-based text embeddings
- pandas / scikit-learn for data handling and evaluation
These dependencies indicate a compute-heavy graph-learning stack with GPU-oriented sparse operations.
11. End-to-end data flow
The typical flow is:
raw dataset files → preprocessing/conversion → graph dataset objects → optional BERT text embeddings → TACCO model forward pass → alignment + clustering losses → trained embeddings/clusters → logs/results.
If drawing the architecture, this is the main left-to-right pipeline.
12. Repo shape
There is no separate backend, API server, or deployment layer. The repository is a self-contained ML research system centered on offline training and evaluation, with docs/ only providing pipeline visualization.
Main entry points: train_tacco.py Train TACCO · convert_datasets_to_pygDataset.py To PyG · models.py TACCO model · preprocessing.py Preprocess
Components 18
Raw data
Dataset artifacts and concept graphs
- Cradle data · Raw EHR graph artifacts for the Cradle dataset
data/raw_data/cradle - MIMIC-3 data · Raw EHR graph artifacts for the MIMIC-3 dataset
data/raw_data/mimic3 - Hyperedges · Patient-visit and concept hypergraph structure
- Labels · Edge or task labels used for training and evaluation
- Embeddings · Precomputed node feature vectors
- Node text · Clinical concept text used for semantic encoding
Ingest
Preprocessing and dataset conversion
- Preprocess · Transforms raw EHR artifacts into model-ready inputs
src/preprocessing.py - To PyG · Converts datasets into PyTorch Geometric format
src/convert_datasets_to_pygDataset.py
Modeling
Graph learning, clustering, and alignment
- BERT encode · Encodes node text into semantic embeddings
src/bert.py - Layers · Reusable graph and hypergraph building blocks
src/layers.py - TACCO model · Main neural architecture and co-clustering workflow
src/models.py - DEC head · Deep embedded clustering objective and refinement
src/dec.py - Alignment · Aligns concept and visit representations
src/alignment.py
Training
Entry points and experiment wrappers
- Train TACCO · Main end-to-end training entry point
src/train_tacco.py - Train HYPEHR · Alternative hypergraph training path
src/train_hypehr.py - Demo run · Runnable example pipeline wrapper
src/demo.sh - Paper run · Paper configuration and experiment wrapper
src/KDD24.sh
Other components
- README · High-level project overview and usage notes
README.md
Connections 19
- Cradle data → Preprocess: input · Cradle artifacts are ingested for preprocessing
- MIMIC-3 data → Preprocess: input · MIMIC-3 artifacts are ingested for preprocessing
- Preprocess → To PyG: prepare · Preprocessing hands off structured inputs for conversion
- To PyG → Hyperedges: graph · Produces graph structure for training
- To PyG → Labels: labels · Carries supervision into the dataset format
- To PyG → Embeddings: features · Prepares or attaches node features
- Node text → BERT encode: encode · Text is transformed into semantic embeddings
- BERT encode → TACCO model: embeddings · Language-derived features enter the model
- Hyperedges → Layers: message passing · Graph structure drives representation learning
- Embeddings → Layers: features · Initial node features feed the graph layers
- Layers → TACCO model: representations · Layer outputs are assembled by the main model
- TACCO model → Alignment: align · Model representations are regularized across node types
- TACCO model → DEC head: cluster · Latent embeddings are refined into clusters
- Alignment → Train TACCO: loss · Alignment objective participates in TACCO training
- DEC head → Train TACCO: loss · Clustering objective participates in TACCO training
- Train TACCO → Demo run: run · Demo wrapper executes the main training flow
- Train TACCO → Paper run: run · Paper script launches the reported configuration
- Train HYPEHR → Paper run: alt run · Alternative training path can be invoked by experiment scripts
- Train TACCO → README: documented in · Repository usage is described in the README