# chung-1014/mthm503_classification architecture

> Architecture diagram of the GitHub repository chung-1014/mthm503_classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chung-1014/mthm503_classification
- Repository: https://github.com/chung-1014/mthm503_classification

## Overview

This repository is a teaching product for reproducible supervised and unsupervised machine-learning workflows, in laboratory and coursework modes. Users select a mode and configuration, run DVC-managed stages that prepare and load data, then explore it and train/evaluate classifiers or cluster observations; the workflows produce Quarto reports and analysis outputs. The graph separates data access, supervised work, unsupervised work, and reporting. Some pipeline wiring and unsampled capabilities are included only where the README documents them; exact stage-to-stage links are therefore limited.

Main entry points: [`sql`](https://github.com/chung-1014/mthm503_classification/tree/main/sql) (SQL queries), [`src/supervised/supervised_core.py`](https://github.com/chung-1014/mthm503_classification/blob/main/src/supervised/supervised_core.py) (Classification methods), [`src/utils.py`](https://github.com/chung-1014/mthm503_classification/blob/main/src/utils.py) (Data access helpers), [`scripts/supervised/01_load_data_cw.py`](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/01_load_data_cw.py) (Supervised data load)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_duckdb[("Coursework database")]
  node_sql["SQL queries"]
  node_sup_prepare["Supervised preparation"]
  node_sup_lab_prepare["Lab preparation"]
  node_sup_load["Supervised data load<br/>[01_load_data_cw.py]"]
  node_unsup_prepare["Unsupervised preparation"]
  node_unsup_lab_prepare["Lab preparation"]
  node_unsup_load["Unsupervised data load<br/>[01_load_data_cw.py]"]
  node_utils["Data access helpers<br/>[utils.py]"]
end

subgraph group_sup["Supervised workflow"]
  node_sup_eda["Supervised exploration<br/>[02_eda.py]"]
  node_sup_split["Feature and split<br/>[03_split.py]"]
  node_sup_model["Classifier training<br/>[04_classify.py]"]
  node_sup_evaluate["Model evaluation<br/>[05_evaluate.py]"]
  node_sup_core["Classification methods<br/>[supervised_core.py]"]
  node_sup_stubs["Classification fallbacks<br/>[stubs.py]"]
end

subgraph group_unsup["Unsupervised workflow"]
  node_unsup_eda["Unsupervised exploration<br/>[02_eda.py]"]
  node_unsup_cluster["Clustering analysis<br/>[03_cluster.py]"]
  node_unsup_core["Clustering methods"]
  node_unsup_stubs["Clustering fallbacks<br/>[stubs.py]"]
end

subgraph group_report["Reports and orchestration"]
  node_config["Mode configuration<br/>[params.yaml]"]
  node_dvc["DVC workflows<br/>[dvc.yaml]"]
  node_templates["Quarto report templates"]
end

node_user(("Student"))

node_user -->|"runs workflow"| node_dvc
node_user -->|"selects mode"| node_config
node_dvc -.->|"uses parameters"| node_config
node_dvc -.->|"builds reports"| node_templates
node_sup_prepare -->|"reads query"| node_sql
node_sup_prepare -.->|"prepares data"| node_duckdb
node_sup_lab_prepare -.->|"reads query"| node_sql
node_sup_load -->|"reads query"| node_sql
node_sup_load -->|"loads query data"| node_utils
node_sup_load -->|"queries database"| node_duckdb
node_sup_eda -->|"uses methods"| node_sup_core
node_sup_split -->|"prepares and splits"| node_sup_core
node_sup_model -->|"trains and predicts"| node_sup_core
node_sup_evaluate -->|"computes metrics"| node_sup_core
node_sup_core -->|"falls back to"| node_sup_stubs
node_unsup_prepare -.->|"reads query"| node_sql
node_unsup_prepare -.->|"loads data"| node_utils
node_unsup_lab_prepare -->|"reads query"| node_sql
node_unsup_lab_prepare -->|"loads PostgreSQL"| node_utils
node_unsup_load -->|"reads query"| node_sql
node_unsup_load -->|"loads query data"| node_utils
node_unsup_load -->|"queries database"| node_duckdb
node_unsup_eda -->|"uses methods"| node_unsup_core
node_unsup_eda -->|"uses helpers"| node_utils
node_unsup_cluster -->|"clusters and plots"| node_unsup_core
node_unsup_core -->|"falls back to"| node_unsup_stubs

click node_config "https://github.com/chung-1014/mthm503_classification/blob/main/params.yaml"
click node_dvc "https://github.com/chung-1014/mthm503_classification/blob/main/dvc.yaml"
click node_duckdb "https://github.com/chung-1014/mthm503_classification/blob/main/data/coursework_2027.duckdb"
click node_sql "https://github.com/chung-1014/mthm503_classification/tree/main/sql"
click node_sup_prepare "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/00_prepare_data_cw.py"
click node_sup_lab_prepare "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/00_prepare_data_lab.py"
click node_sup_load "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/01_load_data_cw.py"
click node_sup_eda "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/02_eda.py"
click node_sup_split "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/03_split.py"
click node_sup_model "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/04_classify.py"
click node_sup_evaluate "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/05_evaluate.py"
click node_sup_core "https://github.com/chung-1014/mthm503_classification/blob/main/src/supervised/supervised_core.py"
click node_sup_stubs "https://github.com/chung-1014/mthm503_classification/blob/main/src/supervised/stubs.py"
click node_unsup_prepare "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/00_prepare_data_cw.py"
click node_unsup_lab_prepare "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/00_prepare_data_lab.py"
click node_unsup_load "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/01_load_data_cw.py"
click node_unsup_eda "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/02_eda.py"
click node_unsup_cluster "https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/03_cluster.py"
click node_unsup_core "https://github.com/chung-1014/mthm503_classification/blob/main/src/unsupervised/unsupervised_core.py"
click node_unsup_stubs "https://github.com/chung-1014/mthm503_classification/blob/main/src/unsupervised/stubs.py"
click node_utils "https://github.com/chung-1014/mthm503_classification/blob/main/src/utils.py"
click node_templates "https://github.com/chung-1014/mthm503_classification/tree/main/reports/templates"

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_duckdb,node_sql,node_sup_prepare,node_sup_lab_prepare,node_sup_load,node_unsup_prepare,node_unsup_lab_prepare,node_unsup_load,node_utils toneBlue
class node_sup_eda,node_sup_split,node_sup_model,node_sup_evaluate,node_sup_core,node_sup_stubs toneAmber
class node_unsup_eda,node_unsup_cluster,node_unsup_core,node_unsup_stubs toneMint
class node_config,node_dvc,node_templates toneRose
class node_user toneIndigo
```

## Components

### Data preparation

- [Coursework database](https://github.com/chung-1014/mthm503_classification/blob/main/data/coursework_2027.duckdb): `data/coursework_2027.duckdb`
- [SQL queries](https://github.com/chung-1014/mthm503_classification/tree/main/sql): `sql`
- [Supervised preparation](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/00_prepare_data_cw.py): `scripts/supervised/00_prepare_data_cw.py`
- [Lab preparation](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/00_prepare_data_lab.py): `scripts/supervised/00_prepare_data_lab.py`
- [Supervised data load](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/01_load_data_cw.py): `scripts/supervised/01_load_data_cw.py`
- [Unsupervised preparation](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/00_prepare_data_cw.py): `scripts/unsupervised/00_prepare_data_cw.py`
- [Lab preparation](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/00_prepare_data_lab.py): `scripts/unsupervised/00_prepare_data_lab.py`
- [Unsupervised data load](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/01_load_data_cw.py): `scripts/unsupervised/01_load_data_cw.py`
- [Data access helpers](https://github.com/chung-1014/mthm503_classification/blob/main/src/utils.py): `src/utils.py`

### Supervised workflow

- [Supervised exploration](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/02_eda.py): `scripts/supervised/02_eda.py`
- [Feature and split](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/03_split.py): `scripts/supervised/03_split.py`
- [Classifier training](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/04_classify.py): `scripts/supervised/04_classify.py`
- [Model evaluation](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/supervised/05_evaluate.py): `scripts/supervised/05_evaluate.py`
- [Classification methods](https://github.com/chung-1014/mthm503_classification/blob/main/src/supervised/supervised_core.py): `src/supervised/supervised_core.py`
- [Classification fallbacks](https://github.com/chung-1014/mthm503_classification/blob/main/src/supervised/stubs.py): `src/supervised/stubs.py`

### Unsupervised workflow

- [Unsupervised exploration](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/02_eda.py): `scripts/unsupervised/02_eda.py`
- [Clustering analysis](https://github.com/chung-1014/mthm503_classification/blob/main/scripts/unsupervised/03_cluster.py): `scripts/unsupervised/03_cluster.py`
- [Clustering methods](https://github.com/chung-1014/mthm503_classification/blob/main/src/unsupervised/unsupervised_core.py): `src/unsupervised/unsupervised_core.py`
- [Clustering fallbacks](https://github.com/chung-1014/mthm503_classification/blob/main/src/unsupervised/stubs.py): `src/unsupervised/stubs.py`

### Reports and orchestration

- [Mode configuration](https://github.com/chung-1014/mthm503_classification/blob/main/params.yaml): `params.yaml`
- [DVC workflows](https://github.com/chung-1014/mthm503_classification/blob/main/dvc.yaml): `dvc.yaml`
- [Quarto report templates](https://github.com/chung-1014/mthm503_classification/tree/main/reports/templates): `reports/templates`

### Other components

- **Student**

## Connections

- Student → DVC workflows: runs workflow (evidence: `README.md`)
- Student → Mode configuration: selects mode (evidence: `README.md`)
- DVC workflows → Mode configuration: uses parameters
- DVC workflows → Quarto report templates: builds reports (evidence: `README.md`)
- Supervised preparation → SQL queries: reads query (evidence: `scripts/supervised/00_prepare_data_cw.py`)
- Supervised preparation → Coursework database: prepares data
- Lab preparation → SQL queries: reads query
- Supervised data load → SQL queries: reads query (evidence: `scripts/supervised/01_load_data_cw.py`)
- Supervised data load → Data access helpers: loads query data (evidence: `scripts/supervised/01_load_data_cw.py`)
- Supervised data load → Coursework database: queries database (evidence: `scripts/supervised/01_load_data_cw.py`)
- Supervised exploration → Classification methods: uses methods (evidence: `scripts/supervised/02_eda.py`)
- Feature and split → Classification methods: prepares and splits (evidence: `scripts/supervised/03_split.py`)
- Classifier training → Classification methods: trains and predicts (evidence: `scripts/supervised/04_classify.py`)
- Model evaluation → Classification methods: computes metrics (evidence: `scripts/supervised/05_evaluate.py`)
- Classification methods → Classification fallbacks: falls back to (evidence: `src/supervised/supervised_core.py`)
- Unsupervised preparation → SQL queries: reads query
- Unsupervised preparation → Data access helpers: loads data (evidence: `scripts/unsupervised/00_prepare_data_cw.py`)
- Lab preparation → SQL queries: reads query (evidence: `scripts/unsupervised/00_prepare_data_lab.py`)
- Lab preparation → Data access helpers: loads PostgreSQL (evidence: `scripts/unsupervised/00_prepare_data_lab.py`)
- Unsupervised data load → SQL queries: reads query (evidence: `scripts/unsupervised/01_load_data_cw.py`)
- Unsupervised data load → Data access helpers: loads query data (evidence: `scripts/unsupervised/01_load_data_cw.py`)
- Unsupervised data load → Coursework database: queries database (evidence: `scripts/unsupervised/01_load_data_cw.py`)
- Unsupervised exploration → Clustering methods: uses methods (evidence: `scripts/unsupervised/02_eda.py`)
- Unsupervised exploration → Data access helpers: uses helpers (evidence: `scripts/unsupervised/02_eda.py`)
- Clustering analysis → Clustering methods: clusters and plots (evidence: `scripts/unsupervised/03_cluster.py`)
- Clustering methods → Clustering fallbacks: falls back to (evidence: `src/unsupervised/unsupervised_core.py`)
