# futuregoose/ecommerce_purchase_prediction architecture

> Architecture diagram of the GitHub repository futuregoose/ecommerce_purchase_prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/futuregoose/ecommerce_purchase_prediction
- Repository: https://github.com/futuregoose/ecommerce_purchase_prediction

## Overview

##### Project Type and Purpose
- Type: Data‑science/ML analysis pipeline with an interpretability dashboard.
- Purpose: Ingest e‑commerce user activity data, clean and transform it, train and compare models (EBM, LightGBM), and expose results via an InterpretML dashboard for stakeholders.

##### Main Components
A. Data Source
– project_data.csv (raw dataset from UCI repository)
– Uppdragsbeskrivning.pdf (assignment spec – optional annotation)
B. Pre‑Processing Layer
– Data Cleaning Module (handling missing values, outliers)
– Feature Engineering Module (log, sqrt transforms)
– Scripts: goose_helpers.py as a utilities library
C. Sampling & Balancing
– Subsampling / Oversampling
– SMOTE
D. Modeling Layer
– Model Trainer 1: Explainable Boosting Machine (EBM)
– Model Trainer 2: LightGBM
E. Pipeline Orchestration
– Jupyter Notebook (ecommerce_purchase_prediction.ipynb) as the “driver” of the entire workflow
– requirements.txt / Python environment
F. Interpretability & Visualization
– InterpretML Dashboard (web UI component)
G. Stakeholder Interface
– Presentation slide deck (external to repo)
H. Assets & Documentation
– assets/ (any images, charts)
– README.md, LICENSE

##### Relationships and Data Flows
- The Jupyter Notebook orchestrates calls to goose_helpers.py utilities and each pipeline phase.
- The InterpretML Dashboard reads model outputs (trained artifacts) and feature importances to serve to stakeholders.

##### Architectural Patterns & Principles
- Pipeline Pattern: Distinct sequential stages (Ingest → Transform → Train → Serve).
- Single‑process Orchestration: Jupyter Notebook as the control plane.
- Modular Utilities: goose_helpers.py separates reusable code.
- Reproducibility: requirements.txt ensures consistent environment.

##### Technologies & Frameworks
- Python 3.x – pandas, numpy, scikit‑learn
- interpret‑ml for dashboard
- lightgbm
- ebm (Explainable Boosting Machine)
- Jupyter Notebook

##### Final Checklist
✓ Each component clearly labeled
✓ Technology annotations on or near blocks
✓ Boundary for execution environment (requirements.txt)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Layer"
        ds["project_data.csv"]:::data
        spec["Uppdragsbeskrivning.pdf"]:::data
    end

    subgraph "Pre-Processing Layer"
        dc["Data Cleaning (pandas)"]:::process
        fe["Feature Engineering (numpy)"]:::process
        gh["goose_helpers.py"]:::process
    end

    subgraph "Sampling & Balancing"
        sub["Subsampling/Oversampling"]:::process
        sm["SMOTE Oversampling"]:::process
    end

    subgraph "Modeling Layer"
        ebm["EBM (interpret-ml)"]:::model
        lgbm["LightGBM"]:::model
    end

    subgraph "Interpretability & Visualization"
        dash["InterpretML Dashboard"]:::serve
    end

    note["ecommerce_purchase_prediction.ipynb"]:::orchestrator

    subgraph "Python Environment"
        req["requirements.txt"]:::env
    end

    subgraph "Assets & Documentation"
        assets["assets/"]:::doc
        readme["README.md"]:::doc
        licence["LICENSE"]:::doc
    end

    user((Stakeholder)):::user

    %% Data flow
    ds -->|"load raw data"| dc
    spec -.->|optional spec| ds
    dc -->|"clean data"| fe
    fe -->|"produce features"| sub
    fe -->|"produce features"| sm
    sub -->|"balanced data"| ebm
    sm -->|"balanced data"| ebm
    sub -->|"balanced data"| lgbm
    sm -->|"balanced data"| lgbm
    ebm -->|"model output"| dash
    lgbm -->|"model output"| dash
    dash -->|"view results"| user

    %% Control flow from notebook
    note -->|"runs cleaning"| dc
    note -->|"runs feature engineering"| fe
    note -->|"imports utilities"| gh
    note -->|"performs sampling"| sub
    note -->|"performs SMOTE"| sm
    note -->|"trains EBM"| ebm
    note -->|"trains LightGBM"| lgbm
    note -->|"launches dashboard"| dash

    %% Environment relation
    req -.-> note

    %% Assets & docs relation
    assets -.-> dash
    readme -.-> note
    licence -.-> note

    %% Click Events
    click ds "https://github.com/futuregoose/ecommerce_purchase_prediction/blob/main/project_data.csv"
    click spec "https://github.com/futuregoose/ecommerce_purchase_prediction/blob/main/Uppdragsbeskrivning.pdf"
    click gh "https://github.com/futuregoose/ecommerce_purchase_prediction/blob/main/goose_helpers.py"
    click note "https://github.com/futuregoose/ecommerce_purchase_prediction/blob/main/ecommerce_purchase_prediction.ipynb"
    click req "https://github.com/futuregoose/ecommerce_purchase_prediction/blob/main/requirements.txt"
    click assets "https://github.com/futuregoose/ecommerce_purchase_prediction/tree/main/assets/"
    click readme "https://github.com/futuregoose/ecommerce_purchase_prediction/blob/main/README.md"
    click licence "https://github.com/futuregoose/ecommerce_purchase_prediction/tree/main/LICENSE"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000;
    classDef process fill:#90EE90,stroke:#000;
    classDef model fill:#FFA500,stroke:#000;
    classDef serve fill:#DDA0DD,stroke:#000;
    classDef orchestrator fill:#B0E0E6,stroke:#000;
    classDef env fill:#D3D3D3,stroke:#000,stroke-dasharray: 5 5;
    classDef doc fill:#F0F0F0,stroke:#000;
    classDef user fill:#FFC0CB,stroke:#000,shape:circle;
```
