# gurhoshiaa/hybrid_stacked_ids architecture

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

- Interactive diagram: https://gitdiagram.com/gurhoshiaa/hybrid_stacked_ids
- Repository: https://github.com/gurhoshiaa/hybrid_stacked_ids

## Overview

This is a reproducible CIC-IDS2017 intrusion-detection research project, not a serving application. Its principal workflow samples and preprocesses network-flow data, trains four base learners and a logistic-regression stack, then evaluates multiclass predictions. Separate research branches study unseen attacks, autoencoder loss and thresholds, component/PCA ablations, SHAP interpretation, and inference latency. The graph reflects the documented workflow and sampled source; unsampled analysis details are included only where the README identifies their purpose.

Main entry points: [`src/run_primary_pipeline.py`](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/run_primary_pipeline.py) (Pipeline runner), [`results`](https://github.com/gurhoshiaa/hybrid_stacked_ids/tree/main/results) (Results artifacts), [`src/02_train_stack.py`](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py) (Stack training), [`src/01_preprocess.py`](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/01_preprocess.py) (Preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Primary pipeline"]
  node_runner["Pipeline runner"]
  node_preprocess["Preprocessing<br/>[01_preprocess.py]"]
  node_processed["Processed data"]
end

subgraph group_models["Detection models"]
  node_stack["Stack training<br/>[02_train_stack.py]"]
  node_base["Base learners<br/>[02_train_stack.py]"]
  node_autoencoder["Benign autoencoder<br/>[02_train_stack.py]"]
  node_meta["Stacking classifier<br/>[02_train_stack.py]"]
  node_savedmodels["Trained model artifacts"]
end

subgraph group_evaluation["Evaluation and reporting"]
  node_auc["AUC evaluation<br/>[03_evaluate_auc.py]"]
  node_confusion["Confusion analysis"]
  node_roc["ROC analysis"]
  node_artifacts["Results artifacts"]
  node_tables["Result table export"]
end

subgraph group_research["Research analyses"]
  node_shap["SHAP interpretation"]
  node_threshold["Adaptive thresholds"]
  node_loss["Autoencoder loss study"]
  node_unseen["Unseen attack rotations"]
  node_component["Component ablation"]
  node_pca["PCA ablation"]
  node_latency["Inference benchmarking"]
  node_plots["Experiment plots"]
  node_pca_plot["PCA plots"]
  node_latency_plot["Latency plots<br/>[08_plot_latency.py]"]
end

node_researcher(("Researcher"))
node_cicids["CIC-IDS2017 CSVs"]

node_researcher -->|"runs"| node_runner
node_runner -->|"runs"| node_preprocess
node_preprocess -->|"loads"| node_cicids
node_preprocess -->|"saves"| node_processed
node_runner -->|"runs"| node_stack
node_preprocess -->|"provides data"| node_stack
node_stack -->|"trains"| node_base
node_stack -->|"trains"| node_autoencoder
node_stack -->|"trains"| node_meta
node_base -->|"provides outputs"| node_meta
node_autoencoder -->|"provides error"| node_meta
node_stack -->|"saves"| node_savedmodels
node_runner -->|"runs"| node_auc
node_runner -->|"runs"| node_confusion
node_runner -->|"runs"| node_roc
node_auc -->|"loads"| node_savedmodels
node_auc -->|"exports metrics"| node_artifacts
node_confusion -.->|"exports analysis"| node_artifacts
node_roc -.->|"exports curves"| node_artifacts
node_researcher -->|"runs"| node_shap
node_shap -->|"loads XGBoost"| node_savedmodels
node_researcher -->|"runs"| node_threshold
node_researcher -->|"runs"| node_loss
node_researcher -->|"runs"| node_unseen
node_researcher -->|"runs"| node_component
node_researcher -->|"runs"| node_pca
node_researcher -->|"runs"| node_latency
node_researcher -->|"runs"| node_plots
node_researcher -->|"runs"| node_pca_plot
node_researcher -->|"runs"| node_latency_plot
node_researcher -->|"runs"| node_tables
node_loss -->|"uses saved data"| node_processed
node_unseen -->|"loads"| node_cicids
node_component -->|"loads"| node_savedmodels
node_tables -.->|"exports tables"| node_artifacts
node_plots -.->|"writes plots"| node_artifacts
node_pca_plot -.->|"writes plots"| node_artifacts
node_latency_plot -.->|"writes plots"| node_artifacts

click node_runner "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/run_primary_pipeline.py"
click node_preprocess "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/01_preprocess.py"
click node_stack "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py"
click node_base "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py"
click node_autoencoder "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py"
click node_meta "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py"
click node_savedmodels "https://github.com/gurhoshiaa/hybrid_stacked_ids/tree/main/models"
click node_auc "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/03_evaluate_auc.py"
click node_confusion "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/04_normalized_confusion.py"
click node_roc "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/05_plot_roc_curves.py"
click node_artifacts "https://github.com/gurhoshiaa/hybrid_stacked_ids/tree/main/results"
click node_shap "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/10_shap_analysis.py"
click node_threshold "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/11_adaptive_threshold_analysis.py"
click node_loss "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/12_compare_ae_loss.py"
click node_unseen "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/13_unseen_split_rotation.py"
click node_component "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/14_component_ablation.py"
click node_pca "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/14_pca_ablation_analysis.py"
click node_latency "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/09_benchmark_latency.py"
click node_plots "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/06_plot_component_ablation.py"
click node_pca_plot "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/07_plot_pca_ablation.py"
click node_latency_plot "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/08_plot_latency.py"
click node_tables "https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/15_export_result_tables.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_runner,node_preprocess,node_processed toneBlue
class node_stack,node_base,node_autoencoder,node_meta,node_savedmodels toneAmber
class node_auc,node_confusion,node_roc,node_artifacts,node_tables toneMint
class node_shap,node_threshold,node_loss,node_unseen,node_component,node_pca,node_latency,node_plots,node_pca_plot,node_latency_plot toneRose
class node_researcher,node_cicids toneIndigo
```

## Components

### Primary pipeline

- [Pipeline runner](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/run_primary_pipeline.py): `src/run_primary_pipeline.py`
- [Preprocessing](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/01_preprocess.py): `src/01_preprocess.py`
- **Processed data**

### Detection models

- [Stack training](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py): `src/02_train_stack.py`
- [Base learners](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py): `src/02_train_stack.py`
- [Benign autoencoder](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py): `src/02_train_stack.py`
- [Stacking classifier](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/02_train_stack.py): `src/02_train_stack.py`
- [Trained model artifacts](https://github.com/gurhoshiaa/hybrid_stacked_ids/tree/main/models): `models`

### Evaluation and reporting

- [AUC evaluation](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/03_evaluate_auc.py): `src/03_evaluate_auc.py`
- [Confusion analysis](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/04_normalized_confusion.py): `src/04_normalized_confusion.py`
- [ROC analysis](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/05_plot_roc_curves.py): `src/05_plot_roc_curves.py`
- [Results artifacts](https://github.com/gurhoshiaa/hybrid_stacked_ids/tree/main/results): `results`
- [Result table export](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/15_export_result_tables.py): `src/15_export_result_tables.py`

### Research analyses

- [SHAP interpretation](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/10_shap_analysis.py): `src/10_shap_analysis.py`
- [Adaptive thresholds](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/11_adaptive_threshold_analysis.py): `src/11_adaptive_threshold_analysis.py`
- [Autoencoder loss study](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/12_compare_ae_loss.py): `src/12_compare_ae_loss.py`
- [Unseen attack rotations](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/13_unseen_split_rotation.py): `src/13_unseen_split_rotation.py`
- [Component ablation](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/14_component_ablation.py): `src/14_component_ablation.py`
- [PCA ablation](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/14_pca_ablation_analysis.py): `src/14_pca_ablation_analysis.py`
- [Inference benchmarking](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/09_benchmark_latency.py): `src/09_benchmark_latency.py`
- [Experiment plots](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/06_plot_component_ablation.py): `src/06_plot_component_ablation.py`
- [PCA plots](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/07_plot_pca_ablation.py): `src/07_plot_pca_ablation.py`
- [Latency plots](https://github.com/gurhoshiaa/hybrid_stacked_ids/blob/main/src/08_plot_latency.py): `src/08_plot_latency.py`

### Other components

- **Researcher**
- **CIC-IDS2017 CSVs**

## Connections

- Researcher → Pipeline runner: runs (evidence: `README.md`)
- Pipeline runner → Preprocessing: runs (evidence: `src/run_primary_pipeline.py`)
- Preprocessing → CIC-IDS2017 CSVs: loads (evidence: `src/01_preprocess.py`)
- Preprocessing → Processed data: saves (evidence: `src/01_preprocess.py`)
- Pipeline runner → Stack training: runs (evidence: `src/run_primary_pipeline.py`)
- Preprocessing → Stack training: provides data (evidence: `README.md`)
- Stack training → Base learners: trains (evidence: `src/02_train_stack.py`)
- Stack training → Benign autoencoder: trains (evidence: `README.md`)
- Stack training → Stacking classifier: trains (evidence: `src/02_train_stack.py`)
- Base learners → Stacking classifier: provides outputs (evidence: `src/02_train_stack.py`)
- Benign autoencoder → Stacking classifier: provides error (evidence: `src/02_train_stack.py`)
- Stack training → Trained model artifacts: saves (evidence: `README.md`)
- Pipeline runner → AUC evaluation: runs (evidence: `src/run_primary_pipeline.py`)
- Pipeline runner → Confusion analysis: runs (evidence: `src/run_primary_pipeline.py`)
- Pipeline runner → ROC analysis: runs (evidence: `src/run_primary_pipeline.py`)
- AUC evaluation → Trained model artifacts: loads (evidence: `src/03_evaluate_auc.py`)
- AUC evaluation → Results artifacts: exports metrics (evidence: `README.md`)
- Confusion analysis → Results artifacts: exports analysis
- ROC analysis → Results artifacts: exports curves
- Researcher → SHAP interpretation: runs (evidence: `README.md`)
- SHAP interpretation → Trained model artifacts: loads XGBoost (evidence: `src/10_shap_analysis.py`)
- Researcher → Adaptive thresholds: runs (evidence: `README.md`)
- Researcher → Autoencoder loss study: runs (evidence: `README.md`)
- Researcher → Unseen attack rotations: runs (evidence: `README.md`)
- Researcher → Component ablation: runs (evidence: `README.md`)
- Researcher → PCA ablation: runs (evidence: `README.md`)
- Researcher → Inference benchmarking: runs (evidence: `README.md`)
- Researcher → Experiment plots: runs (evidence: `README.md`)
- Researcher → PCA plots: runs (evidence: `README.md`)
- Researcher → Latency plots: runs (evidence: `README.md`)
- Researcher → Result table export: runs (evidence: `README.md`)
- Autoencoder loss study → Processed data: uses saved data (evidence: `src/12_compare_ae_loss.py`)
- Unseen attack rotations → CIC-IDS2017 CSVs: loads (evidence: `src/13_unseen_split_rotation.py`)
- Component ablation → Trained model artifacts: loads (evidence: `src/14_component_ablation.py`)
- Result table export → Results artifacts: exports tables
- Experiment plots → Results artifacts: writes plots
- PCA plots → Results artifacts: writes plots
- Latency plots → Results artifacts: writes plots
