Skip to content

SalehDadjouy/python-grey-model

Repository files navigation

Colorado GHG Emissions Forecasting Pipeline GM(1,1)

This repository contains the Jupyter Notebook and raw data for the analysis "CO GHG Grey model projection," presented at the ISU-NISS Conference on AI and Statistics in September 2025.

This single notebook (.ipynb file) contains a complete, end-to-end Python pipeline. When the single code cell is run, it performs the entire workflow from raw data ingestion to final visualization and saving the results.

Pipeline Workflow

Running the notebook cell will execute the following steps:

  1. Data Preparation (prepare_data function):

    • Loads the raw data from the 11-6-2024_Colorado_GHG_Inventory_Data.xlsx file.
    • Applies a custom aggregation logic (aggregate_sectors) to map dozens of subsectors into 10 core analysis sectors.
    • Pivots the data and saves a clean, analysis-ready file: GHGReady_normalized.csv.
  2. Forecasting & Analysis (run_forecasting_pipeline function):

    • Descriptive Analysis: Generates historical plots (total trend, stacked bar, cumulative).
    • Backtesting: Runs the GM(1,1) model on a training set (<=2015) and validates it on a test set (2016-2020) to generate RMSE/MAE metrics.
    • Baseline Forecast: Re-trains the model on all historical data (2005-2020) to forecast a "business-as-usual" baseline to 2050.
    • Policy Application: Applies a dictionary of 7 complex, sector-specific mitigation policies to create a "Policy-Modified Forecast."
    • Save Results: Saves all final data (full_forecast_results.csv), metrics (validation_metrics.csv), and final forecast plots (aggregated_forecast.png, individual_sector_forecasts.png) to the /results folder.

How to Run This Project

  1. Clone or Download: Get all the files from this repository.
  2. Install Requirements: This project requires Python 3.x and several libraries. You can install them via pip:
    pip install pandas numpy matplotlib seaborn scikit-learn openpyxl jupyter
  3. Ensure Raw Data is Present: Place the raw data file, 11-6-2024_Colorado_GHG_Inventory_Data.xlsx, in the same directory as the notebook.
  4. Run the Notebook:
    • Open the CO GHG Grey model projection ISU 2025 Conference.ipynb file in Jupyter Notebook, JupyterLab, or VS Code.
    • Run the single, large code cell.

The notebook will automatically create the /results folder, print the validation metrics to the console, and save all output plots and CSVs.

About

A Python implementation of the GM(1,1) Grey Model for forecasting, as used in my 2025 ISU-NISS conference presentation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors