# chen729689ougk/industrial-predictive-maintenance architecture

> Architecture diagram of the GitHub repository chen729689ougk/industrial-predictive-maintenance, 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/chen729689ougk/industrial-predictive-maintenance
- Repository: https://github.com/chen729689ougk/industrial-predictive-maintenance

## Overview

This is an end-to-end industrial predictive-maintenance project: it explores machine-failure data, trains and evaluates classifiers, tunes decision thresholds to favor recall, explains predictions with SHAP, and serves failure-risk predictions through FastAPI. The production API loads the exported HistGradientBoosting pipeline and its threshold, then returns a probability, classification, and risk message. The dataset itself is referenced by the code and README but is absent from the supplied tree. Some analysis scripts are represented by their documented capabilities; their internal wiring was not sampled.

Main entry points: [`src/api.py`](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/api.py) (FastAPI prediction API), [`src/export_hgb_model.py`](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/export_hgb_model.py) (HGB model export), [`src/optimize_threshold.py`](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/optimize_threshold.py) (Threshold optimization), [`src/train_model.py`](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/train_model.py) (Initial training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_exploration["Data exploration"]
  node_inspect["Dataset inspection<br/>[inspect_data.py]"]
  node_eda["Exploratory analysis"]
end

subgraph group_modeling["Model development"]
  node_train["Initial training<br/>[train_model.py]"]
  node_comparison["Model comparison<br/>[compare_models.py]"]
  node_threshold_comparison["Threshold comparison"]
  node_threshold_opt["Threshold optimization"]
  node_export["HGB model export"]
  node_rf_model["Initial model artifact"]
  node_rf_threshold["Initial threshold"]
end

subgraph group_assessment["Assessment and explanations"]
  node_fair_eval["Fair model evaluation"]
  node_final_eval["Final evaluation"]
  node_global_shap["Global SHAP analysis<br/>[explain_model.py]"]
  node_local_shap["Local SHAP analysis"]
end

subgraph group_serving["Prediction service"]
  node_hgb_model["Production HGB model"]
  node_hgb_threshold["Production threshold"]
  node_api["FastAPI prediction API<br/>[api.py]"]
end

node_dataset["AI4I dataset"]
node_operator(("API consumer"))

node_dataset -->|"reads data"| node_inspect
node_dataset -->|"analyzes data"| node_eda
node_dataset -->|"trains on"| node_train
node_dataset -->|"compares on"| node_comparison
node_dataset -->|"compares on"| node_threshold_comparison
node_dataset -->|"optimizes on"| node_threshold_opt
node_dataset -->|"evaluates on"| node_fair_eval
node_dataset -->|"evaluates on"| node_final_eval
node_dataset -->|"explains data"| node_global_shap
node_dataset -->|"selects case"| node_local_shap
node_train -->|"saves model"| node_rf_model
node_threshold_opt -->|"saves model"| node_rf_model
node_threshold_opt -->|"saves threshold"| node_rf_threshold
node_export -->|"reads data"| node_dataset
node_export -->|"exports model"| node_hgb_model
node_export -->|"exports threshold"| node_hgb_threshold
node_api -->|"loads model"| node_hgb_model
node_api -->|"loads threshold"| node_hgb_threshold
node_operator -->|"submits measurements"| node_api
node_api -->|"returns risk"| node_operator

click node_inspect "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/inspect_data.py"
click node_eda "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/notebooks/01_exploratory_data_analysis.ipynb"
click node_train "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/train_model.py"
click node_comparison "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/compare_models.py"
click node_threshold_comparison "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/compare_treshold.py"
click node_threshold_opt "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/optimize_threshold.py"
click node_fair_eval "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/evaluate_model_fairly.py"
click node_final_eval "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/evaluate_final_model.py"
click node_global_shap "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/explain_model.py"
click node_local_shap "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/explain_local_prediction.py"
click node_export "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/export_hgb_model.py"
click node_rf_model "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/predictive_maintenance_pipeline.joblib"
click node_rf_threshold "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/decision_threshold.json"
click node_hgb_model "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/predictive_maintenance_hgb_pipeline.joblib"
click node_hgb_threshold "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/decision_threshold_hgb.json"
click node_api "https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/api.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_inspect,node_eda toneBlue
class node_train,node_comparison,node_threshold_comparison,node_threshold_opt,node_export,node_rf_model,node_rf_threshold toneAmber
class node_fair_eval,node_final_eval,node_global_shap,node_local_shap,node_operator toneMint
class node_hgb_model,node_hgb_threshold,node_api toneRose
class node_dataset toneIndigo
```

## Components

### Data exploration

- [Dataset inspection](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/inspect_data.py): `src/inspect_data.py`
- [Exploratory analysis](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/notebooks/01_exploratory_data_analysis.ipynb): `notebooks/01_exploratory_data_analysis.ipynb`

### Model development

- [Initial training](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/train_model.py): `src/train_model.py`
- [Model comparison](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/compare_models.py): `src/compare_models.py`
- [Threshold comparison](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/compare_treshold.py): `src/compare_treshold.py`
- [Threshold optimization](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/optimize_threshold.py): `src/optimize_threshold.py`
- [HGB model export](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/export_hgb_model.py): `src/export_hgb_model.py`
- [Initial model artifact](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/predictive_maintenance_pipeline.joblib): `models/predictive_maintenance_pipeline.joblib`
- [Initial threshold](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/decision_threshold.json): `models/decision_threshold.json`

### Assessment and explanations

- [Fair model evaluation](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/evaluate_model_fairly.py): `src/evaluate_model_fairly.py`
- [Final evaluation](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/evaluate_final_model.py): `src/evaluate_final_model.py`
- [Global SHAP analysis](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/explain_model.py): `src/explain_model.py`
- [Local SHAP analysis](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/explain_local_prediction.py): `src/explain_local_prediction.py`

### Prediction service

- [Production HGB model](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/predictive_maintenance_hgb_pipeline.joblib): `models/predictive_maintenance_hgb_pipeline.joblib`
- [Production threshold](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/models/decision_threshold_hgb.json): `models/decision_threshold_hgb.json`
- [FastAPI prediction API](https://github.com/chen729689ougk/industrial-predictive-maintenance/blob/main/src/api.py): `src/api.py`

### Other components

- **AI4I dataset**
- **API consumer**

## Connections

- AI4I dataset → Dataset inspection: reads data (evidence: `src/inspect_data.py`)
- AI4I dataset → Exploratory analysis: analyzes data (evidence: `README.md`)
- AI4I dataset → Initial training: trains on (evidence: `src/train_model.py`)
- AI4I dataset → Model comparison: compares on (evidence: `src/compare_models.py`)
- AI4I dataset → Threshold comparison: compares on (evidence: `src/compare_treshold.py`)
- AI4I dataset → Threshold optimization: optimizes on (evidence: `src/optimize_threshold.py`)
- AI4I dataset → Fair model evaluation: evaluates on (evidence: `src/evaluate_model_fairly.py`)
- AI4I dataset → Final evaluation: evaluates on (evidence: `src/evaluate_final_model.py`)
- AI4I dataset → Global SHAP analysis: explains data (evidence: `src/explain_model.py`)
- AI4I dataset → Local SHAP analysis: selects case (evidence: `src/explain_local_prediction.py`)
- Initial training → Initial model artifact: saves model (evidence: `src/train_model.py`)
- Threshold optimization → Initial model artifact: saves model (evidence: `src/optimize_threshold.py`)
- Threshold optimization → Initial threshold: saves threshold (evidence: `src/optimize_threshold.py`)
- HGB model export → AI4I dataset: reads data (evidence: `src/export_hgb_model.py`)
- HGB model export → Production HGB model: exports model (evidence: `src/export_hgb_model.py`)
- HGB model export → Production threshold: exports threshold (evidence: `src/export_hgb_model.py`)
- FastAPI prediction API → Production HGB model: loads model (evidence: `src/api.py`)
- FastAPI prediction API → Production threshold: loads threshold (evidence: `src/api.py`)
- API consumer → FastAPI prediction API: submits measurements (evidence: `README.md`)
- FastAPI prediction API → API consumer: returns risk (evidence: `src/api.py`)
