# h-n-chavda/root-cause-detection architecture

> Architecture diagram of the GitHub repository h-n-chavda/root-cause-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/h-n-chavda/root-cause-detection
- Repository: https://github.com/h-n-chavda/root-cause-detection

## Overview

This repository implements causal-graph recovery with the PC algorithm: process data becomes a graph, which can be compared with a reference graph. The documented method separates skeleton discovery from edge orientation, and the documented datasets include two ultra-processed-food cases and Tennessee Eastman. The sampled runner shows loading, graph summarization and optional evaluation; the sampled algorithm excerpt shows skeleton discovery and collider orientation. Meek-rule propagation and the README’s broader run behavior are documented but not visible in the excerpts.

Main entry points: [`PC_Algorithm/main.py`](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/main.py) (PC runner), [`PC_Algorithm/utils.py`](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py) (PC algorithm), [`PC_Algorithm/DatasetUF.csv`](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/DatasetUF.csv) (Process datasets), [`PC_Algorithm/datasetTE.csv`](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/datasetTE.csv) (Tennessee data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Inputs"]
  node_process_data["Process datasets<br/>[DatasetUF.csv]"]
  node_te_data["Tennessee data<br/>[datasetTE.csv]"]
  node_reference_graphs["Reference graphs<br/>[UFGroundTruth.txt]"]
end

subgraph group_recovery["Graph Recovery"]
  node_runner["PC runner<br/>[main.py]"]
  node_data_loader["Dataset loader<br/>[utils.py]"]
  node_pc_algorithm["PC algorithm<br/>[utils.py]"]
  node_skeleton["Skeleton discovery<br/>[utils.py]"]
  node_independence_test["Independence tests<br/>[utils.py]"]
  node_orientation["Edge orientation<br/>[utils.py]"]
  node_graph_summary["Graph summary<br/>[utils.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_ground_truth_loader["Reference loader<br/>[utils.py]"]
  node_metrics["Graph metrics<br/>[utils.py]"]
  node_metric_format["Metric formatter<br/>[utils.py]"]
  node_terminal["Printed report"]
end

node_user(("Researcher"))

node_user -->|"runs"| node_runner
node_process_data -->|"loads"| node_data_loader
node_te_data -.->|"loads"| node_data_loader
node_runner -->|"calls"| node_data_loader
node_data_loader -->|"returns data"| node_pc_algorithm
node_runner -->|"calls"| node_pc_algorithm
node_runner -->|"calls"| node_graph_summary
node_runner -->|"calls"| node_ground_truth_loader
node_reference_graphs -->|"loads"| node_ground_truth_loader
node_runner -->|"calls"| node_metrics
node_runner -->|"calls"| node_metric_format
node_pc_algorithm -->|"discovers"| node_skeleton
node_skeleton -->|"tests"| node_independence_test
node_pc_algorithm -->|"orients"| node_orientation
node_runner -->|"prints"| node_terminal
node_graph_summary -->|"reports graph"| node_terminal
node_metric_format -->|"reports metrics"| node_terminal

click node_process_data "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/DatasetUF.csv"
click node_te_data "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/datasetTE.csv"
click node_reference_graphs "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/UFGroundTruth.txt"
click node_runner "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/main.py"
click node_data_loader "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_pc_algorithm "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_skeleton "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_independence_test "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_orientation "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_graph_summary "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_ground_truth_loader "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_metrics "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"
click node_metric_format "https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_process_data,node_te_data,node_reference_graphs toneBlue
class node_runner,node_data_loader,node_pc_algorithm,node_skeleton,node_independence_test,node_orientation,node_graph_summary toneAmber
class node_ground_truth_loader,node_metrics,node_metric_format,node_terminal toneMint
class node_user toneIndigo
```

## Components

### Inputs

- [Process datasets](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/DatasetUF.csv): `PC_Algorithm/DatasetUF.csv`
- [Tennessee data](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/datasetTE.csv): `PC_Algorithm/datasetTE.csv`
- [Reference graphs](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/UFGroundTruth.txt): `PC_Algorithm/UFGroundTruth.txt`

### Graph Recovery

- [PC runner](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/main.py): `PC_Algorithm/main.py`
- [Dataset loader](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- [PC algorithm](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- [Skeleton discovery](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- [Independence tests](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- [Edge orientation](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- [Graph summary](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`

### Evaluation

- [Reference loader](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- [Graph metrics](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- [Metric formatter](https://github.com/h-n-chavda/root-cause-detection/blob/main/PC_Algorithm/utils.py): `PC_Algorithm/utils.py`
- **Printed report**

### Other components

- **Researcher**

## Connections

- Researcher → PC runner: runs
- Process datasets → Dataset loader: loads
- Tennessee data → Dataset loader: loads
- PC runner → Dataset loader: calls
- Dataset loader → PC algorithm: returns data
- PC runner → PC algorithm: calls
- PC runner → Graph summary: calls
- PC runner → Reference loader: calls
- Reference graphs → Reference loader: loads
- PC runner → Graph metrics: calls
- PC runner → Metric formatter: calls
- PC algorithm → Skeleton discovery: discovers
- Skeleton discovery → Independence tests: tests
- PC algorithm → Edge orientation: orients
- PC runner → Printed report: prints
- Graph summary → Printed report: reports graph
- Metric formatter → Printed report: reports metrics
