Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,12 +15,13 @@ def load_data_predictions():
|
|
15 |
'DNN3': 'Neural Network 3',
|
16 |
'DNN4': 'Neural Network 4',
|
17 |
'DNN_Ensemble': 'Neural Network Ensemble',
|
18 |
-
'LEAR56': 'Regularized Linear Model
|
19 |
-
'LEAR84': 'Regularized Linear Model
|
20 |
-
'LEAR112': 'Regularized Linear Model
|
21 |
-
'LEAR730': 'Regularized Linear Model
|
22 |
'LEAR_Ensemble': 'Regularized Linear Model Ensemble',
|
23 |
-
'Persis': 'Persistence Model'
|
|
|
24 |
})
|
25 |
df['Date'] = pd.to_datetime(df['Date'], dayfirst=True)
|
26 |
df_filtered = df.dropna(subset=['Real Price'])
|
@@ -34,15 +35,20 @@ max_date_allowed_pred = df_filtered['Date'].max().date()
|
|
34 |
end_date = df['Date'].max().date()
|
35 |
start_date = end_date - pd.Timedelta(days=7)
|
36 |
|
|
|
|
|
|
|
|
|
|
|
37 |
st.title("Belgium: Electricity Price Forecasting")
|
38 |
|
39 |
# Sidebar for inputs
|
40 |
with st.sidebar:
|
41 |
st.write("### Variables Selection for Graph")
|
42 |
st.write("Select which variables you'd like to include in the graph. This will affect the displayed charts and available data for download.")
|
43 |
-
selected_variables = st.multiselect("Select variables to display:", options=['Real Price', 'Neural Network 1', 'Neural Network 2', 'Neural Network 3', 'Neural Network 4', 'Neural Network Ensemble', 'Regularized Linear Model
|
44 |
st.write("### Model Selection for Scatter Plot")
|
45 |
-
model_selection = st.selectbox("Select which model's predictions to display:", options=['Neural Network 1', 'Neural Network 2', 'Neural Network 3', 'Neural Network 4', 'Neural Network Ensemble', 'Regularized Linear Model
|
46 |
|
47 |
st.write("### Date Range for Metrics Calculation")
|
48 |
st.write("Select the date range to calculate the metrics for the predictions. This will influence the accuracy metrics displayed below. The complete dataset ranges from 10/03/2024 until today.")
|
@@ -99,14 +105,14 @@ else:
|
|
99 |
if start_date_pred and end_date_pred:
|
100 |
st.header("Accuracy Metrics")
|
101 |
#st.write(f"The accuracy metrics are calculated from {start_date_pred} to {end_date_pred}, this intervale can be changed in the sidebar.")
|
102 |
-
st.write(f"The accuracy metrics are calculated from **{start_date_pred}** to **{end_date_pred}**. This interval can be changed in the sidebar
|
103 |
filtered_df = df_filtered[(df_filtered['Date'] >= pd.Timestamp(start_date_pred)) & (df_filtered['Date'] <= pd.Timestamp(end_date_pred))]
|
104 |
|
105 |
# List of models for convenience
|
106 |
models = [
|
107 |
'Neural Network 1', 'Neural Network 2', 'Neural Network 3', 'Neural Network 4', 'Neural Network Ensemble',
|
108 |
-
'Regularized Linear Model
|
109 |
-
'Persistence Model'
|
110 |
]
|
111 |
|
112 |
# Placeholder for results
|
@@ -166,6 +172,20 @@ with col2:
|
|
166 |
""")
|
167 |
|
168 |
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
st.write("## Access Predictions")
|
171 |
st.write("If you are interested in accessing the predictions made by the models, please contact Margarida Mascarenhas (KU Leuven PhD Student) at [email protected]")
|
|
|
15 |
'DNN3': 'Neural Network 3',
|
16 |
'DNN4': 'Neural Network 4',
|
17 |
'DNN_Ensemble': 'Neural Network Ensemble',
|
18 |
+
'LEAR56': 'Regularized Linear Model 1',
|
19 |
+
'LEAR84': 'Regularized Linear Model 2',
|
20 |
+
'LEAR112': 'Regularized Linear Model 3',
|
21 |
+
'LEAR730': 'Regularized Linear Model 4',
|
22 |
'LEAR_Ensemble': 'Regularized Linear Model Ensemble',
|
23 |
+
'Persis': 'Persistence Model',
|
24 |
+
'Hybrid_Ensemble': 'Hybrid Ensemble'
|
25 |
})
|
26 |
df['Date'] = pd.to_datetime(df['Date'], dayfirst=True)
|
27 |
df_filtered = df.dropna(subset=['Real Price'])
|
|
|
35 |
end_date = df['Date'].max().date()
|
36 |
start_date = end_date - pd.Timedelta(days=7)
|
37 |
|
38 |
+
models_corr_matrix = ['Neural Network 1', 'Neural Network 2', 'Neural Network 3',
|
39 |
+
'Neural Network 4', 'Regularized Linear Model 1',
|
40 |
+
'Regularized Linear Model 2', 'Regularized Linear Model 3',
|
41 |
+
'Regularized Linear Model 4']
|
42 |
+
|
43 |
st.title("Belgium: Electricity Price Forecasting")
|
44 |
|
45 |
# Sidebar for inputs
|
46 |
with st.sidebar:
|
47 |
st.write("### Variables Selection for Graph")
|
48 |
st.write("Select which variables you'd like to include in the graph. This will affect the displayed charts and available data for download.")
|
49 |
+
selected_variables = st.multiselect("Select variables to display:", options=['Real Price', 'Neural Network 1', 'Neural Network 2', 'Neural Network 3', 'Neural Network 4', 'Neural Network Ensemble', 'Regularized Linear Model 1', 'Regularized Linear Model 2','Regularized Linear Model 3', 'Regularized Linear Model 4', 'Regularized Linear Model Ensemble', 'Hybrid Ensemble', 'Persistence Model'], default=['Real Price', 'Neural Network Ensemble', 'Regularized Linear Model Ensemble', 'Persistence Model'])
|
50 |
st.write("### Model Selection for Scatter Plot")
|
51 |
+
model_selection = st.selectbox("Select which model's predictions to display:", options=['Neural Network 1', 'Neural Network 2', 'Neural Network 3', 'Neural Network 4', 'Neural Network Ensemble', 'Regularized Linear Model 1', 'Regularized Linear Model 2','Regularized Linear Model 3', 'Regularized Linear Model 4', 'Regularized Linear Model Ensemble', 'Hybrid Ensemble', 'Persistence Model'], index=10) # Adjust the index as needed to default to your desired option
|
52 |
|
53 |
st.write("### Date Range for Metrics Calculation")
|
54 |
st.write("Select the date range to calculate the metrics for the predictions. This will influence the accuracy metrics displayed below. The complete dataset ranges from 10/03/2024 until today.")
|
|
|
105 |
if start_date_pred and end_date_pred:
|
106 |
st.header("Accuracy Metrics")
|
107 |
#st.write(f"The accuracy metrics are calculated from {start_date_pred} to {end_date_pred}, this intervale can be changed in the sidebar.")
|
108 |
+
st.write(f"The accuracy metrics are calculated from **{start_date_pred}** to **{end_date_pred}**. This interval can be changed in the sidebar. Evaluate the forecasting accuracy of our models with key performance indicators. The table summarizes the Mean Absolute Error (MAE), Symmetric Mean Absolute Percentage Error (SMAPE), and Root Mean Square Error (RMSE) for the selected models over your selected date range. Lower values indicate higher precision and reliability of the forecasts.")
|
109 |
filtered_df = df_filtered[(df_filtered['Date'] >= pd.Timestamp(start_date_pred)) & (df_filtered['Date'] <= pd.Timestamp(end_date_pred))]
|
110 |
|
111 |
# List of models for convenience
|
112 |
models = [
|
113 |
'Neural Network 1', 'Neural Network 2', 'Neural Network 3', 'Neural Network 4', 'Neural Network Ensemble',
|
114 |
+
'Regularized Linear Model 1', 'Regularized Linear Model 2', 'Regularized Linear Model 3', 'Regularized Linear Model 4', 'Regularized Linear Model Ensemble',
|
115 |
+
'Persistence Model', 'Hybrid Ensemble'
|
116 |
]
|
117 |
|
118 |
# Placeholder for results
|
|
|
172 |
""")
|
173 |
|
174 |
|
175 |
+
st.write("## Correlation Matrix")
|
176 |
+
|
177 |
+
|
178 |
+
models_df = df_filtered[models_corr_matrix]
|
179 |
+
corr_matrix = models_df.corr()
|
180 |
+
|
181 |
+
fig = go.Figure(data=go.Heatmap(
|
182 |
+
z=corr_matrix.values,
|
183 |
+
x=corr_matrix.columns,
|
184 |
+
y=corr_matrix.index))
|
185 |
+
fig.update_layout(
|
186 |
+
yaxis_autorange='reversed' # Ensure the y-axis starts from the top
|
187 |
+
)
|
188 |
+
st.plotly_chart(fig, use_container_width=True)
|
189 |
+
|
190 |
st.write("## Access Predictions")
|
191 |
st.write("If you are interested in accessing the predictions made by the models, please contact Margarida Mascarenhas (KU Leuven PhD Student) at [email protected]")
|