# engineersamet/fraud-detection-from-kaggle architecture

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

- Interactive diagram: https://gitdiagram.com/engineersamet/fraud-detection-from-kaggle
- Repository: https://github.com/engineersamet/fraud-detection-from-kaggle

## Overview

This repository is a credit-card fraud detection system with an offline training/evaluation workflow and a Streamlit interface for transaction scoring. The main workflow prepares imbalanced transaction data, trains and evaluates candidate models, selects decision thresholds, and analyzes model explanations; a separate deployment pipeline loads saved models and produces transaction decisions. The graph reflects documented capabilities, but unsampled portions of the training and interface code limit certainty about some internal calls.

Main entry points: [`main.py`](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/main.py) (Training workflow), [`predict_fraud.py`](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/predict_fraud.py) (Transaction prediction), [`app.py`](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/app.py) (Streamlit application), [`get_lgbm_thresholds.py`](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/get_lgbm_thresholds.py) (Champion thresholds)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model development"]
  node_preprocessing["Data preprocessing<br/>[preprocessing.py]"]
  node_imbalance["Class weighting<br/>[imbalance.py]"]
  node_modeling["Model training<br/>[modeling.py]"]
  node_training_run["Training workflow<br/>[main.py]"]
  node_thresholds["Threshold tuning<br/>[thresholding.py]"]
  node_threshold_script["Champion thresholds"]
end

subgraph group_inference["Fraud inference"]
  node_web_app["Streamlit application<br/>[app.py]"]
  node_predictor["Transaction prediction<br/>[predict_fraud.py]"]
end

subgraph group_analysis["Evaluation and interpretation"]
  node_evaluation["Metrics and validation<br/>[evaluation.py]"]
  node_shap["SHAP interpretation<br/>[shap_analysis.py]"]
  node_utilities["Experiment utilities<br/>[utils.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_models["Saved models"]
  node_results["Analysis results"]
end

node_operator(("Analyst"))
node_transactions["Transaction data"]

node_operator -.->|"runs training"| node_training_run
node_transactions -.->|"supplies data"| node_training_run
node_training_run -->|"prepares data"| node_preprocessing
node_training_run -->|"applies weighting"| node_imbalance
node_training_run -->|"trains models"| node_modeling
node_training_run -->|"evaluates models"| node_evaluation
node_training_run -->|"tunes cutoffs"| node_thresholds
node_training_run -->|"analyzes explanations"| node_shap
node_training_run -->|"uses utilities"| node_utilities
node_threshold_script -->|"prepares data"| node_preprocessing
node_threshold_script -->|"optimizes cutoffs"| node_thresholds
node_training_run -.->|"saves models"| node_models
node_training_run -.->|"writes results"| node_results
node_operator -.->|"submits transactions"| node_web_app
node_web_app -->|"requests predictions"| node_predictor
node_predictor -->|"loads models"| node_models
node_transactions -.->|"provides transaction"| node_predictor
node_predictor -.->|"returns decisions"| node_web_app

click node_preprocessing "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/preprocessing.py"
click node_imbalance "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/imbalance.py"
click node_modeling "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/modeling.py"
click node_training_run "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/main.py"
click node_thresholds "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/thresholding.py"
click node_threshold_script "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/get_lgbm_thresholds.py"
click node_evaluation "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/evaluation.py"
click node_shap "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/shap_analysis.py"
click node_utilities "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/utils.py"
click node_web_app "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/app.py"
click node_predictor "https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/predict_fraud.py"
click node_models "https://github.com/engineersamet/fraud-detection-from-kaggle/tree/master/outputs/fraud_detection_final/models"
click node_results "https://github.com/engineersamet/fraud-detection-from-kaggle/tree/master/outputs/fraud_detection_final/results"

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_preprocessing,node_imbalance,node_modeling,node_training_run,node_thresholds,node_threshold_script toneBlue
class node_web_app,node_predictor toneAmber
class node_evaluation,node_shap,node_utilities toneMint
class node_models,node_results toneRose
class node_operator,node_transactions toneIndigo
```

## Components

### Model development

- [Data preprocessing](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/preprocessing.py): `src/preprocessing.py`
- [Class weighting](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/imbalance.py): `src/imbalance.py`
- [Model training](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/modeling.py): `src/modeling.py`
- [Training workflow](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/main.py): `main.py`
- [Threshold tuning](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/thresholding.py): `src/thresholding.py`
- [Champion thresholds](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/get_lgbm_thresholds.py): `get_lgbm_thresholds.py`

### Fraud inference

- [Streamlit application](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/app.py): `app.py`
- [Transaction prediction](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/predict_fraud.py): `predict_fraud.py`

### Evaluation and interpretation

- [Metrics and validation](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/evaluation.py): `src/evaluation.py`
- [SHAP interpretation](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/shap_analysis.py): `src/shap_analysis.py`
- [Experiment utilities](https://github.com/engineersamet/fraud-detection-from-kaggle/blob/master/src/utils.py): `src/utils.py`

### Model artifacts

- [Saved models](https://github.com/engineersamet/fraud-detection-from-kaggle/tree/master/outputs/fraud_detection_final/models): `outputs/fraud_detection_final/models`
- [Analysis results](https://github.com/engineersamet/fraud-detection-from-kaggle/tree/master/outputs/fraud_detection_final/results): `outputs/fraud_detection_final/results`

### Other components

- **Analyst**
- **Transaction data**

## Connections

- Analyst → Training workflow: runs training
- Transaction data → Training workflow: supplies data
- Training workflow → Data preprocessing: prepares data (evidence: `main.py`)
- Training workflow → Class weighting: applies weighting (evidence: `main.py`)
- Training workflow → Model training: trains models (evidence: `main.py`)
- Training workflow → Metrics and validation: evaluates models (evidence: `main.py`)
- Training workflow → Threshold tuning: tunes cutoffs (evidence: `main.py`)
- Training workflow → SHAP interpretation: analyzes explanations (evidence: `main.py`)
- Training workflow → Experiment utilities: uses utilities (evidence: `main.py`)
- Champion thresholds → Data preprocessing: prepares data (evidence: `get_lgbm_thresholds.py`)
- Champion thresholds → Threshold tuning: optimizes cutoffs (evidence: `get_lgbm_thresholds.py`)
- Training workflow → Saved models: saves models
- Training workflow → Analysis results: writes results
- Analyst → Streamlit application: submits transactions
- Streamlit application → Transaction prediction: requests predictions (evidence: `app.py`)
- Transaction prediction → Saved models: loads models (evidence: `predict_fraud.py`)
- Transaction data → Transaction prediction: provides transaction
- Transaction prediction → Streamlit application: returns decisions (evidence: `app.py`)
