Created
July 8, 2026 08:48
-
-
Save Dirga36/f502445419bf44ac07477b2c52120555 to your computer and use it in GitHub Desktop.
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 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