This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} |
NewerOlder