Skip to content

Instantly share code, notes, and snippets.

View michael021997's full-sized avatar

michael021997

View GitHub Profile
"""
External Data Module - Section 2.1 of Technical Specification
Purpose: Ingest and preprocess external data sources at daily and/or weekly level
to enhance prediction capabilities.
Data Sources:
- Weather data (Open-Meteo API with NOAA models - free, no API key required)
- Stock market data (Yahoo Finance)
- Natural disaster data (USGS)
@michael021997
michael021997 / YoY_FuelBurnPredictor.py
Last active July 7, 2025 22:25
YoY_FuelBurn_IndexV2
try:
from prophet import Prophet
PROPHET_AVAILABLE = True
print("Prophet library available")
except ImportError:
PROPHET_AVAILABLE = False
print("Prophet library not available - install with: pip install prophet")
try:
@michael021997
michael021997 / val_yoy.py
Last active June 26, 2025 14:41
variants_final_0625.py
import pandas as pd
import numpy as np
from datetime import datetime
import os
def validate_yoy_with_excel_export(predictor, all_results=None, tolerance=0.001,
export_dir=None, verbose=True):
"""
Enhanced YoY validation with detailed Excel export for visual inspection
@michael021997
michael021997 / two_variants_rolling_autoV2.py
Last active June 26, 2025 18:26
two_variants_rolling_autoV2.py
"""
Enhanced Fuel Burn Prediction System - Version 3.0 (UPDATED: Auto-refresh seasonality, standardized metrics, Excel exports)
- Prophet + Seasonality approach (sophisticated forecasting)
- Simple Rolling Average approach (basic arithmetic mean)
- Standardized comprehensive evaluation metrics
- Auto-refreshed seasonality index
- Excel export functionality for all metrics and predictions
Data Processing & Validation
• Load 5 years historical fuel burn and economic data
• Calculate YoY percentage changes
"""
Prep Target YoY Fuel Burn monthly, NOT rolling 12 months
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
def calculate_monthly_yoy_fuel_burn(input_file, output_file=None):
"""
OUTPUTS:
combined_data_original.csv: Combined data from all CSV files, filtered to the last 15 years, in original frequencies.
combined_data_monthly.csv: The combined data converted to monthly frequency.
combined_data_monthly_enhanced.csv: The combined data converted to monthly frequency + derived economic categories/features from daily and weekly data (target_categories = ['Stock Market'] )
combined_data_daily.csv: The daily data.
combined_data_weekly.csv: The weekly data.
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats import pearsonr
import os
# Set style for plots
plt.style.use('seaborn-v0_8-whitegrid')
sns.set_palette('colorblind')
"""
Enhanced Fuel Burn Prediction Module (Part 1: Feature Engineering)
This combined module provides two approaches for predicting fuel burn metrics:
1. Original approach: Directly predict YoY Fuel Burn
2. New approach: Predict raw Fuel Burn values and derive YoY metrics
"""
import pandas as pd
import numpy as np
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
def calculate_monthly_yoy_fuel_burn(input_file, output_file=None):
"""
Calculate YoY monthly fuel burn from monthly historical data.
Args:
import pandas as pd
import numpy as np
from datetime import datetime
from dateutil.relativedelta import relativedelta
import matplotlib.pyplot as plt
from prophet_model import *
# Feature tracking dictionary to store information about each feature
feature_tracking = {}