Skip to content

Instantly share code, notes, and snippets.

@Dirga36
Created July 8, 2026 08:48
Show Gist options
  • Select an option

  • Save Dirga36/f502445419bf44ac07477b2c52120555 to your computer and use it in GitHub Desktop.

Select an option

Save Dirga36/f502445419bf44ac07477b2c52120555 to your computer and use it in GitHub Desktop.
import numpy as np
from statsmodels.tsa.holtwinters import ExponentialSmoothing
def forecast_storage_demand(historical_usage, periods_ahead=24):
"""
Forecast storage utilization for the next N hours using
Holt-Winters exponential smoothing.
"""
model = ExponentialSmoothing(
historical_usage,
trend="add",
seasonal="add",
seasonal_periods=24
).fit()
forecast = model.forecast(periods_ahead)
return forecast
def should_scale(forecast, current_capacity, safety_margin=0.15):
peak_demand = np.max(forecast)
threshold = current_capacity * (1 - safety_margin)
return peak_demand > threshold
# Example usage
historical_usage = load_hourly_usage_metrics() # returns array of TB used per hour
forecast = forecast_storage_demand(historical_usage)
if should_scale(forecast, current_capacity=500):
provision_additional_capacity(target_tb=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment