isana25 commited on
Commit
1687946
·
verified ·
1 Parent(s): dd5e827

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -39,26 +39,32 @@ def forecast_plot(hours):
39
 
40
  # Plot forecasted energy load
41
  plt.figure(figsize=(12,6))
42
- plt.plot(forecast['ds_local'], forecast['yhat'], label='Forecast', color='orange')
43
- plt.fill_between(forecast['ds_local'], forecast['yhat_lower'], forecast['yhat_upper'], alpha=0.3, color='orange', label='Confidence Interval')
44
- plt.xlabel("Local Time (Europe/Berlin)")
45
- plt.ylabel("Energy Load (MW)")
46
- plt.title("⚡ German Energy Load Forecast (Zoomed into Future)")
47
  plt.legend()
48
- plt.grid(True)
 
49
  plt.tight_layout()
50
  plt.show() # Show plot immediately
51
 
52
- # Prepare the explanation text to highlight graph trends
53
- explanation = (
54
- f"**Forecast Highlights**:\n"
55
- f"- **Peak Energy Demand**: {peak_demand:.2f} MW at {peak_time.strftime('%Y-%m-%d %H:%M:%S')}.\n"
56
- f"- **Confidence Interval**: The forecasted energy load is expected to be between "
57
- f"{lower_bound:.2f} MW and {upper_bound:.2f} MW.\n"
58
- f"- The trend shows that the energy demand is expected to [increase/decrease], "
59
- f"with a potential peak at the specified time.\n"
60
- )
61
-
 
 
 
 
 
62
  # Return both the plot and explanation
63
  return plt, explanation
64
 
@@ -68,5 +74,6 @@ gr.Interface(
68
  inputs=gr.Slider(24, 168, step=24, label="Forecast Hours (1 to 7 days)"),
69
  outputs=[gr.Plot(), gr.Textbox()],
70
  title="⚡ Smart Energy Load Forecasting (Germany)",
71
- description="Predict the energy demand using Facebook Prophet. Select the number of hours to forecast (1-7 days)."
72
- ).launch()
 
 
39
 
40
  # Plot forecasted energy load
41
  plt.figure(figsize=(12,6))
42
+ plt.plot(forecast['ds_local'], forecast['yhat'], label='Forecast', color='#FF6347', linewidth=2) # Orange-ish color
43
+ plt.fill_between(forecast['ds_local'], forecast['yhat_lower'], forecast['yhat_upper'], alpha=0.3, color='#FF6347')
44
+ plt.xlabel("Local Time (Europe/Berlin)", fontsize=12, fontweight='bold')
45
+ plt.ylabel("Energy Load (MW)", fontsize=12, fontweight='bold')
46
+ plt.title("⚡ German Energy Load Forecast (Zoomed into Future)", fontsize=16, fontweight='bold')
47
  plt.legend()
48
+ plt.grid(True, linestyle='--', alpha=0.6)
49
+ plt.xticks(rotation=45)
50
  plt.tight_layout()
51
  plt.show() # Show plot immediately
52
 
53
+ # Prepare the explanation text with Markdown style formatting
54
+ explanation = f"""
55
+ ## 📊 **Forecast Highlights**
56
+ - **Peak Energy Demand**: {peak_demand:.2f} MW at **{peak_time.strftime('%Y-%m-%d %H:%M:%S')}**.
57
+ - **Confidence Interval**: The forecasted energy load is expected to be between
58
+ **{lower_bound:.2f} MW** and **{upper_bound:.2f} MW**.
59
+ - The trend shows that the energy demand is expected to [increase/decrease],
60
+ with a potential peak at the specified time.
61
+ \n\n
62
+ ## 🔍 **Key Observations**:
63
+ - The forecast suggests that **energy demand** will **reach its highest point** at **{peak_time.strftime('%H:%M')}**.
64
+ - This peak could be a critical time for grid management to prevent overloading.
65
+ - **Confidence interval** gives us a range, helping to understand the possible **fluctuations in demand**.
66
+ """
67
+
68
  # Return both the plot and explanation
69
  return plt, explanation
70
 
 
74
  inputs=gr.Slider(24, 168, step=24, label="Forecast Hours (1 to 7 days)"),
75
  outputs=[gr.Plot(), gr.Textbox()],
76
  title="⚡ Smart Energy Load Forecasting (Germany)",
77
+ description="Predict the energy demand using Facebook Prophet. Select the number of hours to forecast (1-7 days).",
78
+ theme="huggingface", # You can add more themes if desired
79
+ ).launch()