mmmapms commited on
Commit
66f645e
·
verified ·
1 Parent(s): 01f14f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -5,24 +5,38 @@ import plotly.graph_objs as go
5
  import requests
6
  from io import StringIO
7
 
8
- # Function to load predictions from a GitHub repo
9
  @st.cache
10
  def load_data_predictions(github_token):
11
- # GitHub API URL for the CSV file
12
  url = 'https://api.github.com/repos/mmmapms/Forecast_DAM_V2/contents/Predictions.csv'
13
  headers = {'Authorization': f'token {github_token}'}
14
 
15
- # Make a GET request to the GitHub API
16
  response = requests.get(url, headers=headers)
17
 
18
  if response.status_code == 200:
19
- # GitHub API response contains the file content in base64 encoding
20
  file_content = response.json()['content']
21
  csv_content = StringIO(file_content)
22
 
23
  df = pd.read_csv(csv_content, encoding='utf-8')
24
- # Your renaming and preprocessing steps here
25
- df = df.rename(columns={...}) # Your column renaming logic
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  df['Date'] = pd.to_datetime(df['Date'], dayfirst=True)
27
  df_filtered = df.dropna(subset=['Real Price'])
28
  return df, df_filtered
@@ -30,7 +44,7 @@ def load_data_predictions(github_token):
30
  st.error("Failed to download data. Please check your GitHub token and repository details.")
31
  return pd.DataFrame(), pd.DataFrame()
32
 
33
- # Streamlit app UI for token input
34
  st.title("Belgium: Electricity Price Forecasting")
35
  github_token = st.secrets["GitHub_Token_Margarida"]
36
 
 
5
  import requests
6
  from io import StringIO
7
 
8
+
9
  @st.cache
10
  def load_data_predictions(github_token):
11
+
12
  url = 'https://api.github.com/repos/mmmapms/Forecast_DAM_V2/contents/Predictions.csv'
13
  headers = {'Authorization': f'token {github_token}'}
14
 
15
+
16
  response = requests.get(url, headers=headers)
17
 
18
  if response.status_code == 200:
19
+
20
  file_content = response.json()['content']
21
  csv_content = StringIO(file_content)
22
 
23
  df = pd.read_csv(csv_content, encoding='utf-8')
24
+
25
+ df = df.rename(columns={
26
+ 'Price': 'Real Price',
27
+ 'DNN1': 'Neural Network 1',
28
+ 'DNN2': 'Neural Network 2',
29
+ 'DNN3': 'Neural Network 3',
30
+ 'DNN4': 'Neural Network 4',
31
+ 'DNN_Ensemble': 'Neural Network Ensemble',
32
+ 'LEAR56': 'Regularized Linear Model 1',
33
+ 'LEAR84': 'Regularized Linear Model 2',
34
+ 'LEAR112': 'Regularized Linear Model 3',
35
+ 'LEAR730': 'Regularized Linear Model 4',
36
+ 'LEAR_Ensemble': 'Regularized Linear Model Ensemble',
37
+ 'Persis': 'Persistence Model',
38
+ 'Hybrid_Ensemble': 'Hybrid Ensemble'
39
+ })
40
  df['Date'] = pd.to_datetime(df['Date'], dayfirst=True)
41
  df_filtered = df.dropna(subset=['Real Price'])
42
  return df, df_filtered
 
44
  st.error("Failed to download data. Please check your GitHub token and repository details.")
45
  return pd.DataFrame(), pd.DataFrame()
46
 
47
+
48
  st.title("Belgium: Electricity Price Forecasting")
49
  github_token = st.secrets["GitHub_Token_Margarida"]
50