# aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction architecture

> Architecture diagram of the GitHub repository aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction
- Repository: https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction

## Overview

#### Purpose and execution model
This is a notebook-driven machine-learning solution for the Flipkart Gridlock Hackathon 2.0: predict Bengaluru traffic demand from tabular traffic, weather, road, vehicle, and landmark data. There is no deployed service or package entry point; the operational entry points are Jupyter/Colab notebooks:
- `model/notebook.ipynb`
- `model/demo.ipynb`

#### Input and output contract
Training and inference consume competition CSV datasets:
- `Data/train.csv`
- `Data/test.csv`

The pipeline produces competition-format predictions, represented by:
- `output/sample_submission.csv`

The README notes official data restrictions, so the committed CSVs should be treated as the repository’s local data boundary rather than a guaranteed complete production dataset.

#### Data preparation and feature stage
Notebook execution loads train/test data, treats missing values, encodes categorical fields, and derives model features, especially temporal features. The resulting feature matrix is the shared boundary between preprocessing and model training/inference. The stated model uses 13 features.
- `model/notebook.ipynb`
- `Data/train.csv`
- `Data/test.csv`

#### Validation and generalization boundary
Model selection is based on 5-fold GroupKFold cross-validation rather than random splitting. Group-aware folds isolate related observations between train and validation partitions, making out-of-fold (OOF) predictions and R² the central reliability checks. The reported validated OOF R² is 0.91624.
- `model/notebook.ipynb`
- `model/demo.ipynb`

#### Model training stage
The estimator is a LightGBM regressor. Each fold trains with early stopping against its held-out group-aware validation subset; optimal boosting iterations are selected per fold. Fold models generate validation predictions for OOF scoring and test predictions for final aggregation.
- `model/notebook.ipynb`
- `requirements.txt`

#### Prediction and submission stage
After cross-validation, the workflow applies the trained fold models to the transformed test set, combines predictions, and writes a submission CSV matching the competition schema. `output/sample_submission.csv` is the artifact/schema reference, not a standalone inference application.
- `output/sample_submission.csv`
- `model/notebook.ipynb`

#### Runtime and external dependencies
Execution requires Python in Jupyter Notebook or Google Colab, with NumPy, Pandas, scikit-learn, and LightGBM. External entities are data providers/competition stakeholders—Flipkart, Bengaluru Traffic Police (ASTraM), and MapMyIndia—not runtime APIs. The linked Colab notebook is an alternative hosted runtime.
- `requirements.txt`
- `README.md`

#### Architectural constraints
The repository is experimentation-centric: transformation logic, validation, training, evaluation, and export are coupled inside notebooks rather than reusable modules. Reproducibility depends on notebook cell order, local CSV availability, and installed library versions; no model artifact registry, scheduled pipeline, real-time API, or serving infrastructure is present.
- `model/notebook.ipynb`
- `model/demo.ipynb`

Main entry points: [`model/notebook.ipynb`](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb) (Fold models), [`requirements.txt`](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/requirements.txt) (Python ML dependencies), [`model/demo.ipynb`](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/demo.ipynb) (Demo notebook), [`README.md`](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/README.md) (Repository guidance)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Notebook runtime"]
  node_notebook["Training notebook<br/>Jupyter workflow<br/>[notebook.ipynb]"]
  node_demo["Demo notebook<br/>Jupyter workflow<br/>[demo.ipynb]"]
  node_dependencies["Python ML dependencies<br/>runtime dependencies<br/>[requirements.txt]"]
  node_readme["Repository guidance<br/>documentation<br/>[README.md]"]
end

subgraph group_data["Local competition data"]
  node_train_csv[("Training CSV<br/>competition dataset<br/>[train.csv]")]
  node_test_csv[("Test CSV<br/>competition dataset<br/>[test.csv]")]
end

subgraph group_workflow["ML workflow"]
  node_preprocessing["Feature preparation<br/>notebook stage<br/>[notebook.ipynb]"]
  node_feature_matrix["13-feature matrices<br/>preprocessing boundary<br/>[notebook.ipynb]"]
  node_groupkfold["5-fold GroupKFold<br/>validation strategy<br/>[notebook.ipynb]"]
  node_lightgbm["LightGBM fold training<br/>regression model<br/>[notebook.ipynb]"]
  node_fold_models["Fold models<br/>model ensemble<br/>[notebook.ipynb]"]
end

subgraph group_artifacts["Evaluation and output"]
  node_oof_predictions["OOF predictions<br/>validation artifact<br/>[notebook.ipynb]"]
  node_r2_score["OOF R²: 0.91624<br/>generalization metric<br/>[notebook.ipynb]"]
  node_test_predictions["Aggregated test predictions<br/>prediction artifact<br/>[notebook.ipynb]"]
  node_submission["Submission CSV<br/>competition output"]
end

node_dependencies -->|"supports execution"| node_notebook
node_dependencies -->|"supports execution"| node_demo
node_readme -.->|"documents usage"| node_notebook
node_train_csv -->|"loads"| node_preprocessing
node_test_csv -->|"loads"| node_preprocessing
node_preprocessing -->|"transforms into"| node_feature_matrix
node_feature_matrix -->|"splits training features"| node_groupkfold
node_groupkfold -->|"provides fold partitions"| node_lightgbm
node_lightgbm -->|"trains"| node_fold_models
node_fold_models -->|"predicts held-out folds"| node_oof_predictions
node_oof_predictions -->|"evaluates"| node_r2_score
node_feature_matrix -->|"supplies transformed test features"| node_fold_models
node_fold_models -->|"predicts test set"| node_test_predictions
node_test_predictions -->|"writes"| node_submission
node_demo -.->|"uses validation approach"| node_groupkfold

click node_notebook "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_demo "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/demo.ipynb"
click node_dependencies "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/requirements.txt"
click node_train_csv "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/Data/train.csv"
click node_test_csv "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/Data/test.csv"
click node_preprocessing "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_feature_matrix "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_groupkfold "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_lightgbm "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_fold_models "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_oof_predictions "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_r2_score "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_test_predictions "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb"
click node_submission "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/output/sample_submission.csv"
click node_readme "https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/README.md"

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_notebook,node_demo,node_dependencies,node_readme toneBlue
class node_train_csv,node_test_csv toneAmber
class node_preprocessing,node_feature_matrix,node_groupkfold,node_lightgbm,node_fold_models toneMint
class node_oof_predictions,node_r2_score,node_test_predictions,node_submission toneRose
```

## Components

### Notebook runtime

- [Training notebook](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): Jupyter workflow · Couples preparation, validation, training, and export. · `model/notebook.ipynb`
- [Demo notebook](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/demo.ipynb): Jupyter workflow · Alternative interactive workflow. · `model/demo.ipynb`
- [Python ML dependencies](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/requirements.txt): runtime dependencies · NumPy, Pandas, scikit-learn, and LightGBM. · `requirements.txt`
- [Repository guidance](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/README.md): documentation · Documents data restrictions and notebook-based execution. · `README.md`

### Local competition data

- [Training CSV](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/Data/train.csv): competition dataset · `Data/train.csv`
- [Test CSV](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/Data/test.csv): competition dataset · `Data/test.csv`

### ML workflow

- [Feature preparation](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): notebook stage · Handles missing values, categorical encoding, and temporal features. · `model/notebook.ipynb`
- [13-feature matrices](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): preprocessing boundary · Shared transformed train and test features. · `model/notebook.ipynb`
- [5-fold GroupKFold](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): validation strategy · Keeps related observations out of matching train and validation folds. · `model/notebook.ipynb`
- [LightGBM fold training](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): regression model · Uses held-out folds for early stopping and per-fold iteration selection. · `model/notebook.ipynb`
- [Fold models](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): model ensemble · Generate validation and test predictions. · `model/notebook.ipynb`

### Evaluation and output

- [OOF predictions](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): validation artifact · `model/notebook.ipynb`
- [OOF R²: 0.91624](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): generalization metric · `model/notebook.ipynb`
- [Aggregated test predictions](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/model/notebook.ipynb): prediction artifact · Combines predictions across fold models. · `model/notebook.ipynb`
- [Submission CSV](https://github.com/aditya-singh2005/flipkart-gridlock-2.0-bengaluru-traffic-ai-prediction/blob/main/output/sample_submission.csv): competition output · Schema reference and competition-format prediction artifact. · `output/sample_submission.csv`

## Connections

- Python ML dependencies → Training notebook: supports execution
- Python ML dependencies → Demo notebook: supports execution
- Repository guidance → Training notebook: documents usage
- Training CSV → Feature preparation: loads
- Test CSV → Feature preparation: loads
- Feature preparation → 13-feature matrices: transforms into
- 13-feature matrices → 5-fold GroupKFold: splits training features
- 5-fold GroupKFold → LightGBM fold training: provides fold partitions
- LightGBM fold training → Fold models: trains
- Fold models → OOF predictions: predicts held-out folds
- OOF predictions → OOF R²: 0.91624: evaluates
- 13-feature matrices → Fold models: supplies transformed test features
- Fold models → Aggregated test predictions: predicts test set
- Aggregated test predictions → Submission CSV: writes
- Demo notebook → 5-fold GroupKFold: uses validation approach
