# dylanbahenda/nilm-load-disagregation-xai architecture

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

- Interactive diagram: https://gitdiagram.com/dylanbahenda/nilm-load-disagregation-xai
- Repository: https://github.com/dylanbahenda/nilm-load-disagregation-xai

## Overview

This is a course project for non-intrusive load monitoring, with a notebook-centered workflow that predicts appliance power from aggregate mains readings and compares model explanations. Dataset preparation cleans and resamples raw measurements into a pickle; the notebook loads data, engineers features, trains a decision tree and 1D-CNN, and performs sensitivity analysis and interpretation. Utility functions support evaluation, plotting, and Grad-CAM. The notebook’s internal wiring was not sampled, so its documented stages are shown without asserting unverified calls between them.

Main entry points: [`Load_Disaggregation_XAI.ipynb`](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb) (NILM workflow notebook), [`scripts/nilm_utils.py`](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py) (XAI comparison), [`scripts/prepare_dataset.py`](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/prepare_dataset.py) (Clean and resample), [`data/house2_df.pkl`](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/data/house2_df.pkl) (House dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data_prep["Data Preparation"]
  node_preparation["Clean and resample<br/>[prepare_dataset.py]"]
  node_prepared_data[("House dataset<br/>[house2_df.pkl]")]
end

subgraph group_modeling["Modeling and Analysis"]
  node_notebook["NILM workflow notebook"]
  node_feature_engineering["Feature engineering"]
  node_decision_tree["Decision tree"]
  node_cnn["1D-CNN"]
  node_sensitivity["Parameter sensitivity"]
  node_evaluation["Model metrics<br/>[nilm_utils.py]"]
  node_prediction_plots["Prediction plots<br/>[nilm_utils.py]"]
end

subgraph group_xai["Explainability"]
  node_tree_explanation["Decision paths<br/>[nilm_utils.py]"]
  node_gradcam["Grad-CAM<br/>[nilm_utils.py]"]
  node_xai_comparison["XAI comparison<br/>[nilm_utils.py]"]
end

node_raw_measurements[("Raw measurements")]

node_raw_measurements -->|"loads"| node_preparation
node_preparation -->|"exports"| node_prepared_data
node_prepared_data -->|"loads"| node_notebook
node_notebook -->|"performs"| node_feature_engineering
node_notebook -->|"trains"| node_decision_tree
node_notebook -->|"trains"| node_cnn
node_notebook -->|"analyzes"| node_sensitivity
node_notebook -->|"uses utilities"| node_evaluation
node_notebook -->|"uses utilities"| node_prediction_plots
node_notebook -->|"uses utilities"| node_tree_explanation
node_notebook -->|"uses utilities"| node_gradcam
node_notebook -->|"uses utilities"| node_xai_comparison
node_xai_comparison -->|"computes heatmap"| node_gradcam
node_xai_comparison -->|"renders path"| node_tree_explanation

click node_preparation "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/prepare_dataset.py"
click node_prepared_data "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/data/house2_df.pkl"
click node_notebook "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb"
click node_feature_engineering "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb"
click node_decision_tree "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb"
click node_cnn "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb"
click node_sensitivity "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb"
click node_evaluation "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py"
click node_prediction_plots "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py"
click node_tree_explanation "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py"
click node_gradcam "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py"
click node_xai_comparison "https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_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_preparation,node_prepared_data toneBlue
class node_notebook,node_feature_engineering,node_decision_tree,node_cnn,node_sensitivity,node_evaluation,node_prediction_plots,node_raw_measurements toneAmber
class node_tree_explanation,node_gradcam,node_xai_comparison toneMint
```

## Components

### Data Preparation

- [Clean and resample](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/prepare_dataset.py): `scripts/prepare_dataset.py`
- [House dataset](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/data/house2_df.pkl): `data/house2_df.pkl`

### Modeling and Analysis

- [NILM workflow notebook](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb): `Load_Disaggregation_XAI.ipynb`
- [Feature engineering](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb): `Load_Disaggregation_XAI.ipynb`
- [Decision tree](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb): `Load_Disaggregation_XAI.ipynb`
- [1D-CNN](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb): `Load_Disaggregation_XAI.ipynb`
- [Parameter sensitivity](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/Load_Disaggregation_XAI.ipynb): `Load_Disaggregation_XAI.ipynb`
- [Model metrics](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py): `scripts/nilm_utils.py`
- [Prediction plots](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py): `scripts/nilm_utils.py`

### Explainability

- [Decision paths](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py): `scripts/nilm_utils.py`
- [Grad-CAM](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py): `scripts/nilm_utils.py`
- [XAI comparison](https://github.com/dylanbahenda/nilm-load-disagregation-xai/blob/main/scripts/nilm_utils.py): `scripts/nilm_utils.py`

### Other components

- **Raw measurements**

## Connections

- Raw measurements → Clean and resample: loads (evidence: `scripts/prepare_dataset.py`)
- Clean and resample → House dataset: exports (evidence: `scripts/prepare_dataset.py`)
- House dataset → NILM workflow notebook: loads (evidence: `README.md`)
- NILM workflow notebook → Feature engineering: performs (evidence: `README.md`)
- NILM workflow notebook → Decision tree: trains (evidence: `README.md`)
- NILM workflow notebook → 1D-CNN: trains (evidence: `README.md`)
- NILM workflow notebook → Parameter sensitivity: analyzes (evidence: `README.md`)
- NILM workflow notebook → Model metrics: uses utilities (evidence: `README.md`)
- NILM workflow notebook → Prediction plots: uses utilities (evidence: `README.md`)
- NILM workflow notebook → Decision paths: uses utilities (evidence: `README.md`)
- NILM workflow notebook → Grad-CAM: uses utilities (evidence: `README.md`)
- NILM workflow notebook → XAI comparison: uses utilities (evidence: `README.md`)
- XAI comparison → Grad-CAM: computes heatmap (evidence: `scripts/nilm_utils.py`)
- XAI comparison → Decision paths: renders path (evidence: `scripts/nilm_utils.py`)
