# vishwesh-01/unbswhybrid architecture

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

- Interactive diagram: https://gitdiagram.com/vishwesh-01/unbswhybrid
- Repository: https://github.com/vishwesh-01/unbswhybrid

## Overview

##### Main Components
- Data Source (UNSW-NB15 Excel file)
- Data Preprocessing
– Categorical encoding (LabelEncoders)
– Scaling (MinMaxScaler)
– SMOTE oversampling (optional)
- Split (Train/Test)
- Model Training Pipeline
– CNN layers → LSTM layers → Dense layers
– Early stopping, class weights
- Artifacts
– cnn_lstm_unsw_model.h5
– scaler.pkl, preprocess_info.pkl
- Inference & MAC Spoofing Detection

##### Relationships & Data Flow
- Dataset → Preprocessing → SMOTE? → Split → Reshape
- Reshaped data → Model build & training → Evaluation → Save artifacts
- Artifacts + Incoming sample → Inference → MAC spoofing check → Output

##### Architectural Patterns
- Linear, pipelined ML workflow
- Modular separation: data-prep, training, inference
- Configurable parameters loaded at runtime (batch size, LR, etc.)

##### Key Technologies & Frameworks
- Python 3.11
- TensorFlow 2.18 (Keras API)
- scikit-learn, imbalanced-learn, pandas
- Jupyter Notebook / Python script entry points

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Left half: Pipeline
    subgraph "Left: Data-to-Inference Pipeline"
        direction TB
        DS["UNSW-NB15 Excel File"]:::dataset
        Pre["Preprocessing\n(LabelEncoders, MinMaxScaler)"]:::preprocess
        DecisionSMOTE{"SMOTE?\n(apply oversampling)"}:::decision
        Split["Train/Test Split"]:::preprocess
        Reshape["Reshape to (43×1) tensor"]:::preprocess
        Train["Model Training\n(CNN→LSTM→Dense)\nEarlyStopping, ClassWeights"]:::model
        Save["Save Artifacts\ncnn_lstm_unsw_model.h5\nscaler.pkl\npreprocess_info.pkl"]:::artifact
        Inference["Inference\n+ MAC Spoofing?"]:::inference
        MAC{"MAC Spoofed?"}:::decision
        Output["Detection Result"]:::preprocess

        DS -->|load data| Pre
        Pre -->|feature engineering| DecisionSMOTE
        DecisionSMOTE -->|yes| Pre
        DecisionSMOTE -->|no| Split
        Pre --> Split
        Split --> Reshape
        Reshape --> Train
        Train -->|evaluate & save| Save
        Save -->|load artifacts| Inference
        Inference --> MAC
        MAC -->|yes| Output
        MAC -->|no| Output
    end

    %% Right half: Model Architecture Detail
    subgraph "Right: CNN-LSTM Model Architecture"
        direction TB
        C1["Conv1D\nfilters=64\nkernel_size=3\nReLU"]:::layer
        P1["MaxPool1D\npool_size=2"]:::layer
        C2["Conv1D\nfilters=128\nkernel_size=3\nReLU"]:::layer
        P2["MaxPool1D\npool_size=2"]:::layer
        LSTM["LSTM Layer\nunits=100\ntanh"]:::layer
        D1["Dense\nunits=64\nReLU"]:::layer
        D2["Dense\nunits=2\nSoftmax"]:::layer

        C1 --> P1 --> C2 --> P2 --> LSTM --> D1 --> D2
    end

    %% Click Events
    click DS "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click Pre "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click DecisionSMOTE "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click Split "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click Reshape "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click Train "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click Save "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click Inference "https://github.com/vishwesh-01/unbswhybrid/blob/main/newnotebook (1).ipynb"
    click README "https://github.com/vishwesh-01/unbswhybrid/blob/main/README.md"

    %% Styles
    classDef dataset fill:#AEDFF7,stroke:#036,stroke-width:1px;
    classDef preprocess fill:#C7EFCF,stroke:#028a02,stroke-width:1px;
    classDef decision fill:#FFF69F,stroke:#aa9400,stroke-width:1px;
    classDef model fill:#F7C59F,stroke:#d16f00,stroke-width:1px;
    classDef artifact fill:#E0E0E0,stroke:#828282,stroke-width:1px;
    classDef inference fill:#D1C4E9,stroke:#5e35b1,stroke-width:1px;
    classDef layer fill:#FFE0B2,stroke:#e65100,stroke-width:1px;
```
