NN implementation

#1
by akseljoonas HF Staff - opened
.DS_Store DELETED
Binary file (6.15 kB)
 
app.py CHANGED
@@ -2,6 +2,7 @@ import altair as alt
2
  import pandas as pd
3
  import plotly.graph_objects as go
4
  import streamlit as st
 
5
  from src.helper_functions import custom_metric_box, pollution_box
6
  from src.predict import get_data_and_predictions, update_data_and_predictions
7
 
@@ -44,7 +45,8 @@ col1, col2 = st.columns((1, 3))
44
  # Create a 3-column layout
45
  with col1:
46
  st.subheader("Current Weather")
47
-
 
48
  custom_metric_box(
49
  label="🥵 Temperature",
50
  value=f"{round(today['mean_temp'] * 0.1)} °C",
@@ -74,50 +76,38 @@ with col1:
74
  with col2:
75
  st.subheader("Current Pollution Levels")
76
  sub1, sub2 = st.columns((1, 1))
77
-
78
  # Ozone (O₃) Pollution Box
79
  with sub1:
80
  pollution_box(
81
  label="O<sub>3</sub>",
82
  value=f"{round(today['O3'])} µg/m³",
83
  delta=f"{round(int(today['O3']) - int(previous_day['O3']))} µg/m³",
84
- threshold=120,
85
  )
86
  with st.expander("Learn more about O3", expanded=False):
87
  st.markdown(
88
  """
89
- *Ozone (O<sub>3</sub>)* is a gas that occurs both in the Earth's upper atmosphere and at ground level.
90
-
91
- **Levels interpretation:**
92
- * <span style='color:#77C124'>**Good**</span> (< 120 µg/m³): Safe for most people. Ideal conditions for outdoor activities.
93
- * <span style='color:#E68B0A'>**Medium**</span> (120-240 µg/m³): May cause breathing discomfort for sensitive groups. People with respiratory conditions should limit prolonged outdoor exposure.
94
- * <span style='color:#E63946'>**Bad**</span> (> 240 µg/m³): Health alert! Everyone may experience breathing difficulties. Avoid outdoor activities, especially during peak sunlight hours.
95
-
96
- *Health Effects:* High levels can cause throat irritation, coughing, chest pain, and shortness of breath. Long-term exposure may lead to reduced lung function and chronic respiratory illness.
97
- """,
98
  unsafe_allow_html=True,
99
  )
100
-
101
  # Nitrogen Dioxide (NO₂) Pollution Box
102
  with sub2:
103
  pollution_box(
104
  label="NO<sub>2</sub>",
105
  value=f"{round(today['NO2'])} µg/m³",
106
  delta=f"{round(int(today['NO2']) - int(previous_day['NO2']))} µg/m³",
107
- threshold=40,
108
  )
109
  with st.expander("Learn more about NO2", expanded=False):
110
  st.markdown(
111
  """
112
- *Nitrogen Dioxide (NO<sub>2</sub>)* is primarily produced by vehicles and industrial processes.
113
-
114
- **Levels interpretation:**
115
- * <span style='color:#77C124'>**Good**</span> (< 40 µg/m³): Healthy air quality. No restrictions on outdoor activities.
116
- * <span style='color:#E68B0A'>**Medium**</span> (40-80 µg/m³): Moderate pollution. Sensitive individuals should consider reducing prolonged outdoor exertion.
117
- * <span style='color:#E63946'>**Bad**</span> (> 80 µg/m³): Poor air quality. Everyone should reduce outdoor activities, particularly near high-traffic areas.
118
-
119
- *Health Effects:* Can inflame airways, aggravate asthma, and increase susceptibility to respiratory infections. Long-term exposure may affect lung development in children and contribute to heart disease.
120
- """,
121
  unsafe_allow_html=True,
122
  )
123
 
@@ -128,12 +118,9 @@ with col2:
128
  def get_simple_color_scale(values, threshold):
129
  """Returns green for values below the threshold, orange for values between the threshold and 2x the threshold, and red for values above 2x the threshold."""
130
  return [
131
- "#77C124"
132
- if v < threshold
133
- else "#E68B0A"
134
- if v < 2 * threshold
135
- else "#E63946"
136
- for v in values
137
  ]
138
 
139
  # O3 Bar Plot (threshold: 40)
@@ -155,17 +142,13 @@ with col2:
155
  )
156
 
157
  # Add predicted values with reduced opacity
158
- predicted_o3_colors = get_simple_color_scale(
159
- o3_future_values, 40
160
- ) # Color for future values
161
  fig_o3.add_trace(
162
  go.Bar(
163
  x=df["Date"][-3:], # Dates for predicted values
164
  y=o3_future_values,
165
  name="O3 Predicted",
166
- marker=dict(
167
- color=predicted_o3_colors, opacity=0.5
168
- ), # Set opacity to 0.5 for predictions
169
  hovertemplate="%{x|%d-%b-%Y}<br>%{y} µg/m³<extra></extra>",
170
  )
171
  )
@@ -180,7 +163,7 @@ with col2:
180
  line=dict(color="White", width=3, dash="dash"),
181
  )
182
  )
183
-
184
  fig_o3.update_layout(
185
  plot_bgcolor="rgba(0, 0, 0, 0)",
186
  paper_bgcolor="rgba(0, 0, 0, 0)",
@@ -196,8 +179,7 @@ with col2:
196
  tickangle=-45,
197
  tickcolor="gray",
198
  ),
199
- showlegend=False, # Disable legend
200
- margin=dict(r=100) # Add right margin for legend
201
  )
202
 
203
  st.plotly_chart(fig_o3, key="fig_o3")
@@ -222,17 +204,13 @@ with col2:
222
  )
223
 
224
  # Add predicted values with reduced opacity
225
- predicted_no2_colors = get_simple_color_scale(
226
- no2_future_values, 120
227
- ) # Color for future values
228
  fig_no2.add_trace(
229
  go.Bar(
230
  x=df["Date"][-3:], # Dates for predicted values
231
  y=no2_future_values,
232
  name="NO2 Predicted",
233
- marker=dict(
234
- color=predicted_no2_colors, opacity=0.5
235
- ), # Set opacity to 0.5 for predictions
236
  hovertemplate="%{x|%d-%b-%Y}<br>%{y} µg/m³<extra></extra>",
237
  )
238
  )
@@ -263,8 +241,7 @@ with col2:
263
  tickangle=-45,
264
  tickcolor="gray",
265
  ),
266
- showlegend=False, # Disable legend
267
- margin=dict(r=100) # Add right margin for legend
268
  )
269
 
270
- st.plotly_chart(fig_no2, key="fig_no2")
 
2
  import pandas as pd
3
  import plotly.graph_objects as go
4
  import streamlit as st
5
+
6
  from src.helper_functions import custom_metric_box, pollution_box
7
  from src.predict import get_data_and_predictions, update_data_and_predictions
8
 
 
45
  # Create a 3-column layout
46
  with col1:
47
  st.subheader("Current Weather")
48
+
49
+
50
  custom_metric_box(
51
  label="🥵 Temperature",
52
  value=f"{round(today['mean_temp'] * 0.1)} °C",
 
76
  with col2:
77
  st.subheader("Current Pollution Levels")
78
  sub1, sub2 = st.columns((1, 1))
79
+
80
  # Ozone (O₃) Pollution Box
81
  with sub1:
82
  pollution_box(
83
  label="O<sub>3</sub>",
84
  value=f"{round(today['O3'])} µg/m³",
85
  delta=f"{round(int(today['O3']) - int(previous_day['O3']))} µg/m³",
86
+ threshold=120
87
  )
88
  with st.expander("Learn more about O3", expanded=False):
89
  st.markdown(
90
  """
91
+ *Ozone (O<sub>3</sub>)*: A harmful gas at ground level that can irritate the respiratory system and aggravate asthma.<br>
92
+ **Good/Bad**: "Good" means safe levels for most people, while "Bad" suggests harmful levels, especially for sensitive groups.
93
+ """,
 
 
 
 
 
 
94
  unsafe_allow_html=True,
95
  )
96
+
97
  # Nitrogen Dioxide (NO₂) Pollution Box
98
  with sub2:
99
  pollution_box(
100
  label="NO<sub>2</sub>",
101
  value=f"{round(today['NO2'])} µg/m³",
102
  delta=f"{round(int(today['NO2']) - int(previous_day['NO2']))} µg/m³",
103
+ threshold=40
104
  )
105
  with st.expander("Learn more about NO2", expanded=False):
106
  st.markdown(
107
  """
108
+ *Nitrogen Dioxide (NO<sub>2</sub>)*: A toxic gas that contributes to lung irritation and worsens asthma and other respiratory issues.<br>
109
+ **Good/Bad**: "Good" means safe air quality, while "Bad" indicates levels that could cause respiratory problems, especially for vulnerable individuals.
110
+ """,
 
 
 
 
 
 
111
  unsafe_allow_html=True,
112
  )
113
 
 
118
  def get_simple_color_scale(values, threshold):
119
  """Returns green for values below the threshold, orange for values between the threshold and 2x the threshold, and red for values above 2x the threshold."""
120
  return [
121
+ "#77C124" if v < threshold else
122
+ "#E68B0A" if v < 2 * threshold else
123
+ "#E63946" for v in values
 
 
 
124
  ]
125
 
126
  # O3 Bar Plot (threshold: 40)
 
142
  )
143
 
144
  # Add predicted values with reduced opacity
145
+ predicted_o3_colors = get_simple_color_scale(o3_future_values, 40) # Color for future values
 
 
146
  fig_o3.add_trace(
147
  go.Bar(
148
  x=df["Date"][-3:], # Dates for predicted values
149
  y=o3_future_values,
150
  name="O3 Predicted",
151
+ marker=dict(color=predicted_o3_colors, opacity=0.5), # Set opacity to 0.5 for predictions
 
 
152
  hovertemplate="%{x|%d-%b-%Y}<br>%{y} µg/m³<extra></extra>",
153
  )
154
  )
 
163
  line=dict(color="White", width=3, dash="dash"),
164
  )
165
  )
166
+
167
  fig_o3.update_layout(
168
  plot_bgcolor="rgba(0, 0, 0, 0)",
169
  paper_bgcolor="rgba(0, 0, 0, 0)",
 
179
  tickangle=-45,
180
  tickcolor="gray",
181
  ),
182
+ showlegend=False # Disable legend
 
183
  )
184
 
185
  st.plotly_chart(fig_o3, key="fig_o3")
 
204
  )
205
 
206
  # Add predicted values with reduced opacity
207
+ predicted_no2_colors = get_simple_color_scale(no2_future_values, 120) # Color for future values
 
 
208
  fig_no2.add_trace(
209
  go.Bar(
210
  x=df["Date"][-3:], # Dates for predicted values
211
  y=no2_future_values,
212
  name="NO2 Predicted",
213
+ marker=dict(color=predicted_no2_colors, opacity=0.5), # Set opacity to 0.5 for predictions
 
 
214
  hovertemplate="%{x|%d-%b-%Y}<br>%{y} µg/m³<extra></extra>",
215
  )
216
  )
 
241
  tickangle=-45,
242
  tickcolor="gray",
243
  ),
244
+ showlegend=False # Disable legend
 
245
  )
246
 
247
+ st.plotly_chart(fig_no2, key="fig_no2")
pages/admin.py CHANGED
@@ -5,8 +5,8 @@ import streamlit as st
5
  from sklearn.metrics import mean_squared_error
6
  from src.data_api_calls import get_combined_data
7
 
8
- USERNAME = "dragonkiller"
9
- PASSWORD = "donkey"
10
 
11
  st.title("Admin Panel")
12
 
 
5
  from sklearn.metrics import mean_squared_error
6
  from src.data_api_calls import get_combined_data
7
 
8
+ USERNAME = "admin"
9
+ PASSWORD = "password"
10
 
11
  st.title("Admin Panel")
12
 
past_pollution_data.csv CHANGED
@@ -1,36 +1,18 @@
1
  date,NO2,O3
2
- 2024-03-10,11.668918918918921,51.56918367346938
3
- 2024-03-11,10.072266666666666,47.56326086956521
4
- 2024-03-12,18.938266666666678,30.813999999999993
5
- 2024-03-13,16.765890410958903,41.9352
6
- 2024-03-14,16.93999999999999,40.3236
7
- 2024-03-15,15.422297297297296,46.98500000000001
8
- 2024-03-16,7.8115999999999985,72.5396
9
- 2024-03-17,18.312837837837836,55.46920000000001
10
- 2024-03-18,14.224266666666663,42.890800000000006
11
- 2024-03-19,23.020684931506846,48.69565217391303
12
- 2024-03-20,29.86027397260274,39.999387755102035
13
- 2024-03-21,21.25573333333333,51.676599999999986
14
- 2024-03-22,18.402266666666655,47.357
15
- 2024-03-23,20.759999999999998,48.91148936170213
16
- 2024-03-24,8.37305555555556,70.8304
17
- 2024-03-25,14.175479452054791,61.0036
18
- 2024-03-26,14.980533333333334,61.01260000000001
19
- 2024-03-27,20.856666666666666,45.10062500000001
20
- 2024-03-28,15.91,54.184200000000004
21
- 2024-03-29,11.761267605633797,73.31940000000002
22
- 2024-03-30,13.714054054054053,67.0428
23
- 2024-03-31,15.803835616438358,57.12458333333333
24
- 2024-04-01,13.02464788732394,48.08100000000001
25
- 2024-04-02,14.910800000000005,58.49
26
- 2024-04-03,15.47794520547946,59.6916
27
- 2024-04-04,13.879864864864864,61.80291666666668
28
- 2024-04-05,11.207777777777782,68.86779999999997
29
- 2024-04-06,17.002112676056335,51.04679999999998
30
- 2024-04-07,11.993066666666666,74.87919999999998
31
- 2024-04-08,13.275540540540538,68.55125000000001
32
- 2024-04-09,14.217246376811596,66.66978260869566
33
- 2024-04-10,10.244285714285716,68.9824
34
- 2024-04-11,12.350533333333333,70.38673469387756
35
- 2024-04-12,14.588219178082195,40.88354166666665
36
- 2024-04-13,11.41386666666667,44.19551020408163
 
1
  date,NO2,O3
2
+ 2023-10-18,10.8427027027027,39.81260000000001
3
+ 2023-10-19,17.97026666666666,31.779024390243908
4
+ 2023-10-20,17.233055555555563,18.7156
5
+ 2023-10-21,15.023599999999991,22.04
6
+ 2023-10-22,8.723378378378372,48.33439999999999
7
+ 2023-10-23,20.63426666666668,15.586000000000002
8
+ 2023-10-24,15.1156,24.62808510638297
9
+ 2023-10-25,22.88567567567568,27.117599999999992
10
+ 2023-10-26,21.53175675675676,13.3216
11
+ 2023-10-27,23.07226666666666,16.15416666666666
12
+ 2023-10-28,24.89121621621622,24.59040816326531
13
+ 2023-10-29,9.724428571428573,51.525200000000005
14
+ 2023-10-30,11.20205479452055,52.820600000000006
15
+ 2023-10-31,17.494666666666667,44.458541666666655
16
+ 2023-11-01,21.588095238095235,29.20631578947369
17
+ 2023-11-02,9.745714285714286,48.39760869565216
18
+ 2023-11-03,7.163243243243242,61.421599999999984
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
past_weather_data.csv CHANGED
@@ -15,167 +15,4 @@ date,temp,humidity,precip,windspeed,sealevelpressure,visibility,solarradiation
15
  2023-10-30,11.2,90.4,13.0,18.4,997.5,28.8,27.0
16
  2023-10-31,11.0,93.7,18.6,18.0,1000.7,17.9,29.8
17
  2023-11-01,12.4,88.5,4.9,25.9,997.8,32.6,31.5
18
- 2023-11-02,11.0,80.0,8.7,46.4,976.4,33.6,21.5
19
- 2023-11-03,9.6,83.3,7.9,32.4,981.6,31.0,40.1
20
- 2023-11-04,9.3,88.7,10.7,25.9,977.6,35.3,20.4
21
- 2023-11-05,10.5,88.4,5.6,25.2,977.1,29.0,25.6
22
- 2023-11-06,9.7,87.4,1.8,31.7,998.2,37.3,45.2
23
- 2023-11-07,9.7,85.1,0.4,22.3,1007.3,41.1,63.6
24
- 2023-11-08,9.3,91.9,17.0,28.8,1008.2,21.2,37.0
25
- 2023-11-09,9.7,89.2,8.5,22.3,999.0,24.2,37.3
26
- 2023-11-10,7.5,90.1,4.4,22.3,995.3,34.9,20.8
27
- 2023-11-11,7.5,87.1,5.7,14.8,1003.3,40.0,25.2
28
- 2023-11-12,5.7,96.8,0.1,14.8,1006.4,8.8,26.2
29
- 2023-11-13,9.5,90.3,5.2,31.7,1000.8,9.6,9.8
30
- 2023-11-14,12.1,84.6,11.9,29.5,1001.4,14.8,16.0
31
- 2023-11-15,11.1,84.6,5.3,18.4,1011.9,21.4,22.7
32
- 2023-11-16,7.5,95.7,3.4,18.4,1013.5,19.9,11.8
33
- 2023-11-17,5.1,93.8,0.0,11.2,1019.4,10.5,49.1
34
- 2023-11-18,7.5,97.6,12.2,25.9,1016.5,7.3,7.5
35
- 2023-11-19,12.6,87.1,5.7,25.9,1006.8,11.4,34.0
36
- 2023-11-20,10.5,91.5,8.6,22.3,1007.9,16.6,39.4
37
- 2023-11-21,7.4,97.0,0.2,18.4,1017.6,9.2,13.9
38
- 2023-11-22,4.2,95.1,0.2,18.4,1028.2,6.3,26.3
39
- 2023-11-23,11.2,88.4,1.0,25.9,1019.2,25.1,32.3
40
- 2023-11-24,6.7,77.4,4.5,29.5,1011.8,31.3,36.5
41
- 2023-11-25,5.4,83.6,1.9,25.9,1013.0,27.7,22.0
42
- 2023-11-26,4.8,94.3,0.9,14.8,1014.3,27.0,13.3
43
- 2023-11-27,4.4,96.7,17.0,18.4,998.8,11.5,4.1
44
- 2023-11-28,2.3,82.1,3.0,25.9,1005.0,41.3,46.0
45
- 2023-11-29,2.6,89.7,3.2,18.4,1001.9,39.2,26.9
46
- 2023-11-30,-0.1,99.8,0.0,7.6,1002.3,2.2,17.7
47
- 2023-12-01,-1.1,90.4,0.0,11.2,1007.7,9.0,31.2
48
- 2023-12-02,-0.6,92.7,0.0,14.8,1013.8,6.4,26.2
49
- 2023-12-03,1.0,89.9,1.8,22.3,1017.9,9.2,21.7
50
- 2023-12-04,1.7,85.6,3.8,22.3,1006.0,22.8,14.2
51
- 2023-12-05,1.8,96.7,2.8,18.4,1003.2,4.5,7.5
52
- 2023-12-06,2.9,91.2,0.2,11.2,1014.6,18.2,17.6
53
- 2023-12-07,0.0,96.3,0.0,22.3,1016.5,8.2,12.8
54
- 2023-12-08,5.1,94.5,0.6,18.4,1007.1,7.0,12.0
55
- 2023-12-09,7.9,91.5,7.7,25.9,1000.5,12.4,10.1
56
- 2023-12-10,9.7,79.9,9.8,36.0,999.9,15.8,24.1
57
- 2023-12-11,9.5,89.4,4.8,31.7,1000.7,15.2,13.1
58
- 2023-12-12,8.0,96.2,7.9,14.8,1002.2,18.3,21.2
59
- 2023-12-13,8.5,96.2,5.3,14.8,998.4,13.0,12.5
60
- 2023-12-14,5.6,88.0,0.0,14.8,1018.2,28.9,21.7
61
- 2023-12-15,8.3,84.5,0.0,14.8,1032.9,22.7,14.6
62
- 2023-12-16,8.6,88.7,0.0,18.4,1037.7,20.1,8.9
63
- 2023-12-17,8.9,86.0,0.0,22.3,1034.8,23.4,27.0
64
- 2023-12-18,7.7,88.6,0.0,25.9,1029.2,13.0,19.7
65
- 2023-12-19,8.0,97.4,11.2,33.5,1018.4,10.4,3.9
66
- 2023-12-20,8.4,84.9,0.4,33.5,1012.7,19.2,14.6
67
- 2023-12-21,10.2,82.3,7.0,48.2,999.6,24.9,7.5
68
- 2023-12-22,9.0,81.8,7.9,37.1,1003.4,26.0,12.3
69
- 2023-12-23,10.1,81.8,7.0,50.0,1007.5,35.8,14.4
70
- 2023-12-24,11.5,91.9,19.2,38.9,1003.4,14.0,3.9
71
- 2023-12-25,11.8,89.1,4.4,28.8,1005.6,27.4,15.1
72
- 2023-12-26,8.5,82.4,14.1,36.0,1012.6,32.4,10.9
73
- 2023-12-27,6.5,90.9,1.1,28.8,1013.5,23.5,6.4
74
- 2023-12-28,10.9,75.8,0.0,40.7,1008.0,33.2,18.2
75
- 2023-12-29,9.6,83.9,1.6,38.9,1005.8,32.7,16.1
76
- 2023-12-30,8.1,83.3,0.0,21.6,1009.5,39.1,20.2
77
- 2023-12-31,9.0,81.0,0.9,32.4,996.3,41.5,17.8
78
- 2024-01-01,7.6,85.0,11.1,32.4,1000.9,26.4,15.4
79
- 2024-01-02,10.3,92.0,20.5,43.2,988.9,15.6,6.5
80
- 2024-01-03,9.7,87.5,15.6,39.6,988.4,19.8,18.5
81
- 2024-01-04,7.7,94.9,10.1,14.4,1000.6,24.8,14.3
82
- 2024-01-05,7.2,94.5,8.3,22.3,996.6,21.5,4.6
83
- 2024-01-06,3.6,86.8,0.0,18.4,1010.7,34.4,5.8
84
- 2024-01-07,0.1,80.9,0.0,28.8,1024.5,36.0,21.2
85
- 2024-01-08,-1.6,70.2,0.0,29.5,1032.5,43.6,30.0
86
- 2024-01-09,-3.0,58.0,0.0,22.3,1033.8,45.0,40.6
87
- 2024-01-10,-3.2,59.9,0.0,14.8,1030.9,44.8,43.2
88
- 2024-01-11,-2.4,87.5,0.0,11.2,1034.3,14.8,24.0
89
- 2024-01-12,3.4,90.9,0.0,11.2,1033.0,22.8,13.1
90
- 2024-01-13,3.6,94.3,0.3,18.4,1022.7,8.0,6.4
91
- 2024-01-14,3.0,96.3,2.9,18.4,1009.6,10.5,11.2
92
- 2024-01-15,1.8,87.8,4.2,18.4,1003.3,33.3,21.4
93
- 2024-01-16,0.9,83.2,0.8,22.3,1007.1,38.4,38.0
94
- 2024-01-17,-1.4,82.8,0.0,18.4,993.7,29.4,20.5
95
- 2024-01-18,-1.8,91.5,0.0,14.8,1001.4,23.9,52.5
96
- 2024-01-19,1.6,84.9,1.3,18.4,1018.8,37.7,54.9
97
- 2024-01-20,-0.3,83.9,0.0,21.6,1026.5,18.3,43.7
98
- 2024-01-21,3.0,74.7,0.1,31.7,1017.4,41.0,14.1
99
- 2024-01-22,9.7,81.7,4.8,38.9,1006.8,21.1,37.8
100
- 2024-01-23,8.1,82.3,5.0,32.4,1019.3,15.7,31.1
101
- 2024-01-24,10.8,74.4,1.1,39.6,1018.9,18.0,31.1
102
- 2024-01-25,7.0,91.8,1.3,14.8,1026.9,7.9,22.5
103
- 2024-01-26,8.6,83.7,6.1,36.0,1024.5,19.4,55.3
104
- 2024-01-27,4.2,85.5,0.0,18.4,1034.7,19.9,52.4
105
- 2024-01-28,3.6,77.7,0.0,18.4,1028.0,33.0,56.0
106
- 2024-01-29,6.3,82.9,0.0,11.2,1025.5,35.2,48.5
107
- 2024-01-30,8.1,90.2,0.6,25.9,1027.1,24.3,21.9
108
- 2024-01-31,6.5,82.0,0.0,29.5,1030.8,41.5,15.3
109
- 2024-02-01,6.7,86.1,6.2,22.3,1029.3,14.6,70.9
110
- 2024-02-02,7.4,91.1,0.0,25.9,1027.3,13.5,20.5
111
- 2024-02-03,10.1,90.9,0.0,22.3,1024.7,27.4,21.4
112
- 2024-02-04,10.6,90.2,1.1,29.5,1021.0,22.7,13.6
113
- 2024-02-05,9.8,84.3,0.2,31.7,1017.9,19.8,29.9
114
- 2024-02-06,11.0,83.9,6.9,38.9,1008.3,18.6,26.0
115
- 2024-02-07,4.6,88.4,9.6,14.8,1005.2,22.6,44.5
116
- 2024-02-08,2.3,96.5,9.4,22.3,997.8,7.4,16.1
117
- 2024-02-09,10.6,90.7,7.5,22.3,983.9,30.5,28.8
118
- 2024-02-10,10.4,91.5,0.1,11.2,986.1,38.0,39.4
119
- 2024-02-11,9.0,94.9,3.3,18.4,989.9,11.8,27.2
120
- 2024-02-12,7.2,88.3,0.1,14.8,1003.5,24.7,42.4
121
- 2024-02-13,6.5,85.3,1.0,22.3,1014.8,29.3,52.7
122
- 2024-02-14,10.9,96.9,8.6,22.3,1014.0,8.8,14.6
123
- 2024-02-15,12.9,90.0,10.5,14.8,1013.0,27.8,39.9
124
- 2024-02-16,11.1,88.9,3.0,18.4,1013.2,34.4,24.4
125
- 2024-02-17,10.6,88.4,0.0,11.2,1029.4,25.5,35.5
126
- 2024-02-18,9.6,91.8,13.9,25.9,1024.3,18.5,19.3
127
- 2024-02-19,9.0,91.2,1.7,22.3,1026.1,16.8,23.3
128
- 2024-02-20,8.5,87.3,0.0,25.9,1025.9,14.5,55.2
129
- 2024-02-21,9.4,87.9,6.0,29.5,1011.9,23.5,30.6
130
- 2024-02-22,10.2,93.1,5.2,38.9,987.1,16.5,34.2
131
- 2024-02-23,6.2,82.1,11.8,31.7,989.5,37.7,52.8
132
- 2024-02-24,4.9,87.7,0.4,21.6,997.2,41.4,31.7
133
- 2024-02-25,6.5,85.8,1.4,18.4,999.8,33.2,75.6
134
- 2024-02-26,5.2,85.2,1.6,29.5,1005.8,36.5,27.3
135
- 2024-02-27,4.4,84.4,0.0,18.4,1018.4,32.7,105.8
136
- 2024-02-28,5.4,92.8,0.0,20.2,1019.6,10.0,48.9
137
- 2024-02-29,8.0,94.8,11.9,22.3,1008.7,11.0,21.6
138
- 2024-03-01,8.3,80.0,0.9,29.5,1000.5,38.7,73.2
139
- 2024-03-02,9.4,70.3,0.2,25.9,999.0,43.5,105.0
140
- 2024-03-03,11.4,71.8,0.0,21.6,1001.0,39.0,79.0
141
- 2024-03-04,8.1,80.4,0.0,18.0,1011.0,38.6,118.3
142
- 2024-03-05,5.6,95.1,1.5,7.6,1014.2,6.6,32.8
143
- 2024-03-06,6.7,88.8,0.0,11.2,1022.1,10.2,121.7
144
- 2024-03-07,5.2,84.0,0.0,29.5,1023.5,13.4,114.2
145
- 2024-03-08,5.3,69.6,0.0,32.4,1012.6,19.4,126.3
146
- 2024-03-09,7.9,69.7,0.0,25.9,1001.5,21.5,93.5
147
- 2024-03-10,9.4,69.0,0.0,25.9,997.0,22.3,59.3
148
- 2024-03-11,7.0,95.0,10.8,10.8,1001.9,5.0,19.6
149
- 2024-03-12,8.3,91.2,1.5,18.4,1012.2,6.5,72.7
150
- 2024-03-13,10.9,91.6,1.7,22.3,1013.7,21.4,29.9
151
- 2024-03-14,12.8,77.4,0.0,22.3,1010.8,37.2,132.8
152
- 2024-03-15,13.1,79.7,1.0,28.8,1006.8,32.2,34.5
153
- 2024-03-16,8.2,79.7,1.2,21.6,1018.3,34.5,78.8
154
- 2024-03-17,8.9,85.1,5.4,22.3,1019.7,29.4,68.9
155
- 2024-03-18,11.5,83.4,0.3,14.8,1015.7,20.8,111.5
156
- 2024-03-19,11.5,80.3,0.0,22.3,1017.7,33.8,103.3
157
- 2024-03-20,12.0,82.6,0.0,10.8,1019.0,20.2,118.4
158
- 2024-03-21,9.4,86.4,0.0,18.0,1023.4,27.9,59.5
159
- 2024-03-22,9.8,91.0,2.1,18.4,1016.4,8.9,30.4
160
- 2024-03-23,7.1,78.1,1.6,25.9,1008.4,31.3,111.4
161
- 2024-03-24,6.5,87.1,15.9,25.9,1004.2,21.2,67.1
162
- 2024-03-25,7.3,74.4,0.0,14.8,1004.9,28.5,142.8
163
- 2024-03-26,8.4,70.2,0.0,22.3,991.8,44.7,81.0
164
- 2024-03-27,9.7,76.8,0.2,18.4,986.0,40.9,118.5
165
- 2024-03-28,8.2,78.2,3.8,30.6,985.5,,98.0
166
- 2024-03-29,10.5,77.2,1.9,29.5,992.5,,117.4
167
- 2024-03-30,10.7,88.2,1.7,14.0,996.8,,33.0
168
- 2024-03-31,11.3,87.0,8.3,19.1,997.0,,118.9
169
- 2024-04-01,9.6,89.3,2.2,24.1,995.7,45.0,87.9
170
- 2024-04-02,9.2,89.5,5.9,27.0,1004.2,41.3,69.2
171
- 2024-04-03,11.0,90.8,7.3,25.2,1003.9,25.0,79.5
172
- 2024-04-04,11.9,82.5,13.2,31.7,1004.6,23.7,106.8
173
- 2024-04-05,13.6,83.6,2.9,31.7,1008.0,27.2,81.3
174
- 2024-04-06,17.4,69.6,0.0,25.9,1008.9,39.0,142.4
175
- 2024-04-07,17.2,60.0,0.3,29.5,1011.5,44.4,191.3
176
- 2024-04-08,15.2,83.4,0.5,14.8,1008.4,35.2,117.5
177
- 2024-04-09,12.1,77.2,3.6,32.4,1008.0,33.3,87.5
178
- 2024-04-10,11.5,65.3,1.7,18.4,1025.5,34.1,218.0
179
- 2024-04-11,13.1,82.4,0.4,22.3,1029.7,28.0,48.3
180
- 2024-04-12,15.9,77.4,0.0,29.5,1029.4,30.8,177.1
181
- 2024-04-13,9.4,86.4,0.0,18.0,1023.4,27.9,59.5
 
15
  2023-10-30,11.2,90.4,13.0,18.4,997.5,28.8,27.0
16
  2023-10-31,11.0,93.7,18.6,18.0,1000.7,17.9,29.8
17
  2023-11-01,12.4,88.5,4.9,25.9,997.8,32.6,31.5
18
+ 2023-11-02,11,80,8.7,46.4,976.4,33.6,21.5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pollution_data.csv CHANGED
@@ -1,33 +1,15 @@
1
  date,NO2,O3
2
- 2025-03-10,24.919333333333334,20.79696
3
- 2025-03-11,11.161066666666665,38.56911999999999
4
- 2025-03-12,13.623918918918923,33.15556451612904
5
- 2025-03-13,21.87824324324324,32.2690243902439
6
- 2025-03-14,16.020799999999998,29.73422764227643
7
- 2025-03-15,7.381486486486482,30.53209677419354
8
- 2025-03-16,5.901408450704226,28.3100826446281
9
- 2025-03-17,4.88472222222222,32.64704918032787
10
- 2025-03-18,10.625555555555557,31.403166666666667
11
- 2025-03-19,17.86186666666666,33.13487804878048
12
- 2025-03-20,40.07733333333333,38.95047999999999
13
- 2025-03-21,22.156712328767117,40.23235772357723
14
- 2025-03-22,13.245675675675677,36.57975409836066
15
- 2025-03-23,13.348493150684929,34.08422764227641
16
- 2025-03-24,14.885,29.136693548387104
17
- 2025-03-25,15.633918918918914,36.095967741935475
18
- 2025-03-26,11.872916666666667,30.601999999999993
19
- 2025-03-27,19.970799999999993,26.6366935483871
20
- 2025-03-28,36.30826666666667,34.62607999999999
21
- 2025-03-29,17.113835616438358,29.705365853658535
22
- 2025-03-30,9.202972972972969,29.544508196721306
23
- 2025-03-31,4.272,32.74226890756302
24
- 2025-04-01,6.463928571428573,30.599166666666672
25
- 2025-04-02,8.217500000000001,30.378512396694212
26
- 2025-04-03,6.883880597014924,34.092792792792785
27
- 2025-04-04,16.400958904109583,36.781382113821145
28
- 2025-04-05,8.853333333333332,34.26520661157024
29
- 2025-04-06,4.7411111111111115,31.658360655737706
30
- 2025-04-07,9.19283783783784,31.33639344262295
31
- 2025-04-08,9.031388888888891,33.822950819672144
32
- 2025-04-09,6.972162162162163,33.09658536585365
33
- 2025-04-10,4.2907142857142855,35.82308333333334
 
1
  date,NO2,O3
2
+ 2024-10-17,22.804605103280675,22.769159859976643
3
+ 2024-10-18,23.26858769887009,23.30733245729302
4
+ 2024-10-19,23.91006441223834,23.1717142857143
5
+ 2024-10-20,22.57323754789273,23.53784452296821
6
+ 2024-10-21,21.1457004830918,24.02069565217393
7
+ 2024-10-22,21.77657980456027,23.33588571428572
8
+ 2024-10-23,21.974793814433,22.21468879668051
9
+ 2024-10-24,25.51256756756757,20.91370967741937
10
+ 2024-10-25,21.72051282051282,22.33230769230769
11
+ 2024-10-26,24.46423484380123,18.70331123489324
12
+ 2024-10-27,27.53722134983982,20.80809239842384
13
+ 2024-10-28,23.337567567567568,26.82861788617886
14
+ 2024-10-29,16.53533209586906,23.28254887605004
15
+ 2024-10-30,22.26162162162162,18.03443548387097
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
predictions_history.csv CHANGED
@@ -1,205 +1,72 @@
1
  pollutant,date_predicted,date,prediction_value
2
- O3,2025-03-07,2025-03-10,29.12736491827365
3
- NO2,2025-03-07,2025-03-10,32.17283746918274
4
- O3,2025-03-08,2025-03-10,24.83746918273649
5
- NO2,2025-03-08,2025-03-10,29.18273649182736
6
- O3,2025-03-08,2025-03-11,48.17283746918274
7
- NO2,2025-03-08,2025-03-11,21.83746918273649
8
- O3,2025-03-09,2025-03-10,23.27364918273649
9
- NO2,2025-03-09,2025-03-10,28.18273649182736
10
- O3,2025-03-09,2025-03-11,43.82736491827365
11
- NO2,2025-03-09,2025-03-11,19.27364918273649
12
- O3,2025-03-09,2025-03-12,41.18273649182736
13
- NO2,2025-03-09,2025-03-12,7.82736491827365
14
- O3,2025-03-10,2025-03-11,43.85676124954634
15
- NO2,2025-03-10,2025-03-11,16.104179331534553
16
- O3,2025-03-10,2025-03-12,28.97324258455377
17
- NO2,2025-03-10,2025-03-12,2.675595876631019
18
- O3,2025-03-10,2025-03-13,50.33834675283215
19
- NO2,2025-03-10,2025-03-13,14.550902100392413
20
- O3,2025-03-11,2025-03-12,25.9523779513165
21
- NO2,2025-03-11,2025-03-12,5.774430711604062
22
- O3,2025-03-11,2025-03-13,37.943266736072744
23
- NO2,2025-03-11,2025-03-13,29.9866087474026
24
- O3,2025-03-11,2025-03-14,30.246424112755363
25
- NO2,2025-03-11,2025-03-14,7.714053127875932
26
- O3,2025-03-12,2025-03-13,39.15347103624773
27
- NO2,2025-03-12,2025-03-13,23.357751720510624
28
- O3,2025-03-12,2025-03-14,24.530112014407933
29
- NO2,2025-03-12,2025-03-14,20.425849596952602
30
- O3,2025-03-12,2025-03-15,25.669419663618136
31
- NO2,2025-03-12,2025-03-15,15.530170040340973
32
- O3,2025-03-13,2025-03-14,34.841974632208895
33
- NO2,2025-03-13,2025-03-14,17.23480705661393
34
- O3,2025-03-13,2025-03-15,16.230075346712777
35
- NO2,2025-03-13,2025-03-15,11.553101018528771
36
- O3,2025-03-13,2025-03-16,12.624739887205287
37
- NO2,2025-03-13,2025-03-16,7.642681078487097
38
- O3,2025-03-14,2025-03-15,22.365131907828072
39
- NO2,2025-03-14,2025-03-15,9.206815880750476
40
- O3,2025-03-14,2025-03-16,32.017319322990026
41
- NO2,2025-03-14,2025-03-16,4.702342763015687
42
- O3,2025-03-14,2025-03-17,42.47898074566649
43
- NO2,2025-03-14,2025-03-17,15.70823968427624
44
- O3,2025-03-15,2025-03-16,30.85376488004041
45
- NO2,2025-03-15,2025-03-16,12.453441978685218
46
- O3,2025-03-15,2025-03-17,29.114949145265868
47
- NO2,2025-03-15,2025-03-17,5.268687933737249
48
- O3,2025-03-15,2025-03-18,44.099121719367034
49
- NO2,2025-03-15,2025-03-18,14.849306779455823
50
- O3,2025-03-16,2025-03-17,36.25252428642855
51
- NO2,2025-03-16,2025-03-17,1.4750256174958913
52
- O3,2025-03-16,2025-03-18,38.67185924197556
53
- NO2,2025-03-16,2025-03-18,13.411510252962042
54
- O3,2025-03-16,2025-03-19,43.92144424141553
55
- NO2,2025-03-16,2025-03-19,22.924043705613457
56
- O3,2025-03-17,2025-03-18,20.593729497451083
57
- NO2,2025-03-17,2025-03-18,9.233383939306108
58
- O3,2025-03-17,2025-03-19,33.902081716854376
59
- NO2,2025-03-17,2025-03-19,17.035250016088494
60
- O3,2025-03-17,2025-03-20,56.13338974244566
61
- NO2,2025-03-17,2025-03-20,34.74925137364262
62
- O3,2025-03-18,2025-03-19,24.34677204803371
63
- NO2,2025-03-18,2025-03-19,24.214191960527593
64
- O3,2025-03-18,2025-03-20,7.97083270245124
65
- NO2,2025-03-18,2025-03-20,16.653190550698003
66
- O3,2025-03-18,2025-03-21,8.828820106189312
67
- NO2,2025-03-18,2025-03-21,3.2143497350615284
68
- O3,2025-03-19,2025-03-20,14.19915504166628
69
- NO2,2025-03-19,2025-03-20,40.367920343944874
70
- O3,2025-03-19,2025-03-21,8.055352596285765
71
- NO2,2025-03-19,2025-03-21,14.036055689494942
72
- O3,2025-03-19,2025-03-22,20.683555991473177
73
- NO2,2025-03-19,2025-03-22,-0.0935552468181555
74
- O3,2025-03-20,2025-03-21,22.577240569315755
75
- NO2,2025-03-20,2025-03-21,22.432680154231203
76
- O3,2025-03-20,2025-03-22,20.23852948376169
77
- NO2,2025-03-20,2025-03-22,11.41259533531298
78
- O3,2025-03-20,2025-03-23,22.832979536729955
79
- NO2,2025-03-20,2025-03-23,7.888808066058104
80
- O3,2025-03-21,2025-03-22,29.27186184325724
81
- NO2,2025-03-21,2025-03-22,21.27561105197099
82
- O3,2025-03-21,2025-03-23,23.143988800612934
83
- NO2,2025-03-21,2025-03-23,18.514420577624954
84
- O3,2025-03-21,2025-03-24,26.34383163970652
85
- NO2,2025-03-21,2025-03-24,9.275171108969094
86
- O3,2025-03-22,2025-03-23,23.00812920675076
87
- NO2,2025-03-22,2025-03-23,15.562277370570971
88
- O3,2025-03-22,2025-03-24,12.996197559099771
89
- NO2,2025-03-22,2025-03-24,5.920400650472168
90
- O3,2025-03-22,2025-03-25,24.158896251220572
91
- NO2,2025-03-22,2025-03-25,-6.051012335488707
92
- O3,2025-03-23,2025-03-24,15.70265619759315
93
- NO2,2025-03-23,2025-03-24,26.297361615928935
94
- O3,2025-03-23,2025-03-25,8.332549816083528
95
- NO2,2025-03-23,2025-03-25,13.670842154040486
96
- O3,2025-03-23,2025-03-26,16.640077837303092
97
- NO2,2025-03-23,2025-03-26,11.462778135172028
98
- O3,2025-03-24,2025-03-25,18.25717694098837
99
- NO2,2025-03-24,2025-03-25,27.234622346278005
100
- O3,2025-03-24,2025-03-26,17.54807704356461
101
- NO2,2025-03-24,2025-03-26,18.168652599687817
102
- O3,2025-03-24,2025-03-27,25.874950013940516
103
- NO2,2025-03-24,2025-03-27,3.541491205431615
104
- O3,2025-03-25,2025-03-26,26.688534177437624
105
- NO2,2025-03-25,2025-03-26,26.172909735803763
106
- O3,2025-03-25,2025-03-27,22.93922854687444
107
- NO2,2025-03-25,2025-03-27,17.04426781640162
108
- O3,2025-03-25,2025-03-28,37.00433182727376
109
- NO2,2025-03-25,2025-03-28,17.247288148167
110
- O3,2025-03-26,2025-03-27,23.496437048396636
111
- NO2,2025-03-26,2025-03-27,9.872558444066575
112
- O3,2025-03-26,2025-03-28,17.716182866254996
113
- NO2,2025-03-26,2025-03-28,7.405832864834853
114
- O3,2025-03-26,2025-03-29,33.928031024704914
115
- NO2,2025-03-26,2025-03-29,1.3356425602430129
116
- O3,2025-03-27,2025-03-28,18.0789893495609
117
- NO2,2025-03-27,2025-03-28,18.761355163500543
118
- O3,2025-03-27,2025-03-29,22.977101731471706
119
- NO2,2025-03-27,2025-03-29,5.264649543074441
120
- O3,2025-03-27,2025-03-30,36.92937655932295
121
- NO2,2025-03-27,2025-03-30,2.569373566235953
122
- O3,2025-03-28,2025-03-29,27.524148971900186
123
- NO2,2025-03-28,2025-03-29,19.1485078134881
124
- O3,2025-03-28,2025-03-30,33.07029361561123
125
- NO2,2025-03-28,2025-03-30,16.409390581100745
126
- O3,2025-03-28,2025-03-31,30.133600528481026
127
- NO2,2025-03-28,2025-03-31,16.63377069601797
128
- O3,2025-03-29,2025-03-30,26.462689686248368
129
- NO2,2025-03-29,2025-03-30,16.153029443852326
130
- O3,2025-03-29,2025-03-31,16.172149663837978
131
- NO2,2025-03-29,2025-03-31,17.84386761678244
132
- O3,2025-03-29,2025-04-01,28.038883473085395
133
- NO2,2025-03-29,2025-04-01,18.001427465080745
134
- O3,2025-03-30,2025-03-31,16.56578070101913
135
- NO2,2025-03-30,2025-03-31,12.841512127042206
136
- O3,2025-03-30,2025-04-01,22.04973178816912
137
- NO2,2025-03-30,2025-04-01,6.470749466590821
138
- O3,2025-03-30,2025-04-02,40.10754059007936
139
- NO2,2025-03-30,2025-04-02,5.260238354460856
140
- O3,2025-03-31,2025-04-01,24.99970385367518
141
- NO2,2025-03-31,2025-04-01,29.49563240424814
142
- O3,2025-03-31,2025-04-02,32.925366432171295
143
- NO2,2025-03-31,2025-04-02,21.08528292976339
144
- O3,2025-03-31,2025-04-03,34.65227806432316
145
- NO2,2025-03-31,2025-04-03,11.27957285246689
146
- O3,2025-04-01,2025-04-02,31.338953889921164
147
- NO2,2025-04-01,2025-04-02,9.294640606870104
148
- O3,2025-04-01,2025-04-03,26.34526907465127
149
- NO2,2025-04-01,2025-04-03,2.9112579889493126
150
- O3,2025-04-01,2025-04-04,34.32904595771874
151
- NO2,2025-04-01,2025-04-04,3.3062236947570725
152
- O3,2025-04-02,2025-04-03,20.37484627473415
153
- NO2,2025-04-02,2025-04-03,11.38854008691647
154
- O3,2025-04-02,2025-04-04,22.468836814322444
155
- NO2,2025-04-02,2025-04-04,17.648823824145026
156
- O3,2025-04-02,2025-04-05,38.60737590027399
157
- NO2,2025-04-02,2025-04-05,10.377586026633834
158
- O3,2025-04-03,2025-04-04,24.751156641679092
159
- NO2,2025-04-03,2025-04-04,8.1832337826329
160
- O3,2025-04-03,2025-04-05,30.653881777797142
161
- NO2,2025-04-03,2025-04-05,5.930226199118156
162
- O3,2025-04-03,2025-04-06,39.13759349011889
163
- NO2,2025-04-03,2025-04-06,3.124098380335983
164
- O3,2025-04-04,2025-04-05,31.26363040306683
165
- NO2,2025-04-04,2025-04-05,18.758274587589337
166
- O3,2025-04-04,2025-04-06,29.538996361827696
167
- NO2,2025-04-04,2025-04-06,16.415631516076708
168
- O3,2025-04-04,2025-04-07,33.42217106979134
169
- NO2,2025-04-04,2025-04-07,18.33858043667427
170
- O3,2025-04-05,2025-04-06,21.46606590783967
171
- NO2,2025-04-05,2025-04-06,11.069079275537549
172
- O3,2025-04-05,2025-04-07,16.974627609571066
173
- NO2,2025-04-05,2025-04-07,10.121135864507396
174
- O3,2025-04-05,2025-04-08,23.59865980201226
175
- NO2,2025-04-05,2025-04-08,8.865132211553512
176
- O3,2025-04-06,2025-04-07,18.51982788551233
177
- NO2,2025-04-06,2025-04-07,13.25807843915571
178
- O3,2025-04-06,2025-04-08,15.573212634149264
179
- NO2,2025-04-06,2025-04-08,15.474301950935176
180
- O3,2025-04-06,2025-04-09,27.320954486040108
181
- NO2,2025-04-06,2025-04-09,12.667124755491672
182
- O3,2025-04-07,2025-04-08,17.412329098434125
183
- NO2,2025-04-07,2025-04-08,16.86076406720009
184
- O3,2025-04-07,2025-04-09,17.66027075077956
185
- NO2,2025-04-07,2025-04-09,11.15509361078738
186
- O3,2025-04-07,2025-04-10,24.189150332489294
187
- NO2,2025-04-07,2025-04-10,2.3511603061021873
188
- O3,2025-04-08,2025-04-09,24.751293692949535
189
- NO2,2025-04-08,2025-04-09,14.9695000207066
190
- O3,2025-04-08,2025-04-10,15.39258599235248
191
- NO2,2025-04-08,2025-04-10,10.681758679689471
192
- O3,2025-04-08,2025-04-11,21.865457395477375
193
- NO2,2025-04-08,2025-04-11,5.189639157063457
194
- O3,2025-04-09,2025-04-10,21.415752542433893
195
- NO2,2025-04-09,2025-04-10,7.414993834257501
196
- O3,2025-04-09,2025-04-11,18.43157639079524
197
- NO2,2025-04-09,2025-04-11,13.55873029709923
198
- O3,2025-04-09,2025-04-12,34.53675335273856
199
- NO2,2025-04-09,2025-04-12,12.344843722837314
200
- O3,2025-04-10,2025-04-11,28.314367145255684
201
- NO2,2025-04-10,2025-04-11,18.384325902671144
202
- O3,2025-04-10,2025-04-12,29.281284097019913
203
- NO2,2025-04-10,2025-04-12,16.552657783375896
204
- O3,2025-04-10,2025-04-13,42.4379491717469
205
- NO2,2025-04-10,2025-04-13,12.477293479529983
 
1
  pollutant,date_predicted,date,prediction_value
2
+ O3,2024-10-14,2024-10-17,31.25335185244893
3
+ NO2,2024-10-14,2024-10-17,26.421736787446267
4
+ O3,2024-10-15,2024-10-17,22.00005767760448
5
+ NO2,2024-10-15,2024-10-17,28.59511317503212
6
+ O3,2024-10-16,2024-10-17,9.657466070999735
7
+ NO2,2024-10-16,2024-10-17,17.065168790519902
8
+ O3,2024-10-15,2024-10-18,6.561248
9
+ NO2,2024-10-15,2024-10-18,26.443672
10
+ O3,2024-10-16,2024-10-18,19.782418
11
+ NO2,2024-10-16,2024-10-18,36.453956
12
+ O3,2024-10-17,2024-10-18,16.08841798553393
13
+ NO2,2024-10-17,2024-10-18,32.0458143607889
14
+ O3,2024-10-16,2024-10-19,24.031357603260783
15
+ NO2,2024-10-16,2024-10-19,20.08389395558791
16
+ O3,2024-10-17,2024-10-19,21.031357603260783
17
+ NO2,2024-10-17,2024-10-19,27.08389395558791
18
+ O3,2024-10-17,2024-10-20,20.48486247979324
19
+ NO2,2024-10-17,2024-10-20,23.84300578029378
20
+ O3,2024-10-18,2024-10-19,22.304547122637445
21
+ NO2,2024-10-18,2024-10-19,20.80017116560889
22
+ O3,2024-10-18,2024-10-20,31.25335185244893
23
+ NO2,2024-10-18,2024-10-20,29.732316066240585
24
+ O3,2024-10-18,2024-10-21,28.67755196805434
25
+ NO2,2024-10-18,2024-10-21,35.04638743773354
26
+ O3,2024-10-19,2024-10-20,26.421736787446267
27
+ NO2,2024-10-19,2024-10-20,27.399885723190767
28
+ O3,2024-10-19,2024-10-21,17.065168790519902
29
+ NO2,2024-10-19,2024-10-21,18.992352714813563
30
+ O3,2024-10-19,2024-10-22,17.39682962048955
31
+ NO2,2024-10-19,2024-10-22,22.85061675885908
32
+ O3,2024-10-20,2024-10-21,22.00005767760448
33
+ NO2,2024-10-20,2024-10-21,18.27191592927812
34
+ O3,2024-10-20,2024-10-22,29.00940466937953
35
+ NO2,2024-10-20,2024-10-22,19.50739766963497
36
+ O3,2024-10-20,2024-10-23,20.062134354543343
37
+ NO2,2024-10-20,2024-10-23,23.65746607099973
38
+ O3,2024-10-21,2024-10-22,17.497382318189132
39
+ NO2,2024-10-21,2024-10-22,28.59511317503212
40
+ O3,2024-10-21,2024-10-23,16.519952190354232
41
+ NO2,2024-10-21,2024-10-23,30.192389708351826
42
+ O3,2024-10-21,2024-10-24,28.19940385112904
43
+ NO2,2024-10-21,2024-10-24,17.9525039623211
44
+ O3,2024-10-22,2024-10-23,16.093074246425157
45
+ NO2,2024-10-22,2024-10-23,25.217639978187005
46
+ O3,2024-10-22,2024-10-24,23.605545201596552
47
+ NO2,2024-10-22,2024-10-24,29.004701753536988
48
+ O3,2024-10-23,2024-10-24,26.56486295059828
49
+ NO2,2024-10-23,2024-10-24,20.15373733747257
50
+ O3,2024-10-24,2024-10-25,10.33808859423279
51
+ NO2,2024-10-24,2024-10-25,25.68519991558237
52
+ O3,2024-10-24,2024-10-26,16.000984317626852
53
+ NO2,2024-10-24,2024-10-26,25.760307451092384
54
+ O3,2024-10-24,2024-10-27,19.64377495640328
55
+ NO2,2024-10-24,2024-10-27,31.210576791105115
56
+ O3,2024-10-25,2024-10-26,20.48055947200643
57
+ NO2,2024-10-25,2024-10-26,23.95723903986424
58
+ O3,2024-10-25,2024-10-27,11.088152958498888
59
+ NO2,2024-10-25,2024-10-27,32.274494671100506
60
+ O3,2024-10-25,2024-10-28,-0.7175631399505704
61
+ NO2,2024-10-25,2024-10-28,40.86107800019054
62
+ O3,2024-10-28,2024-10-29,22.13652238154496
63
+ NO2,2024-10-28,2024-10-29,31.608886931951144
64
+ O3,2024-10-28,2024-10-30,15.841669224
65
+ NO2,2024-10-28,2024-10-30,34.564284711452984
66
+ O3,2024-10-28,2024-10-31,22.35944571003375
67
+ NO2,2024-10-28,2024-10-31,34.37482132111927
68
+ O3,2024-10-30,2024-10-31,15.98046542733637
69
+ NO2,2024-10-30,2024-10-31,29.77507241979599
70
+ O3,2024-10-30,2024-11-01,21.135906183680472
71
+ NO2,2024-10-30,2024-11-01,28.38872595850704
72
+ O3,2024-10-30,2024-11-02,19.67426015042635
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -10,5 +10,3 @@ http.client
10
  datetime
11
  huggingface-hub
12
  python-dotenv
13
- torch
14
- safetensors
 
10
  datetime
11
  huggingface-hub
12
  python-dotenv
 
 
src/data_api_calls.py CHANGED
@@ -14,11 +14,7 @@ WEATHER_DATA_FILE = "weather_data.csv"
14
  POLLUTION_DATA_FILE = "pollution_data.csv"
15
 
16
 
17
- def update_weather_data() -> None:
18
- """
19
- Updates weather data by fetching data.
20
- If the data file exists, it appends new data. If not, it creates a new file.
21
- """
22
  today = date.today().isoformat()
23
 
24
  if os.path.exists(WEATHER_DATA_FILE):
@@ -54,11 +50,7 @@ def update_weather_data() -> None:
54
  sys.exit()
55
 
56
 
57
- def update_pollution_data() -> None:
58
- """
59
- Updates pollution data for NO2 and O3.
60
- The new data is appended to the existing pollution data file.
61
- """
62
  O3 = []
63
  NO2 = []
64
  particles = ["NO2", "O3"]
@@ -121,21 +113,14 @@ def update_pollution_data() -> None:
121
  updated_data.to_csv(POLLUTION_DATA_FILE, index=False)
122
 
123
 
124
- def get_combined_data() -> pd.DataFrame:
125
- """
126
- Combines weather and pollution data for the last 7 days.
127
 
128
- Returns:
129
- pd.DataFrame: A DataFrame containing the combined weather and pollution data.
130
- """
131
  weather_df = pd.read_csv(WEATHER_DATA_FILE)
132
-
133
  today = pd.Timestamp.now().normalize()
134
  seven_days_ago = today - pd.Timedelta(days=7)
135
  weather_df["date"] = pd.to_datetime(weather_df["date"])
136
- weather_df = weather_df[
137
- (weather_df["date"] >= seven_days_ago) & (weather_df["date"] <= today)
138
- ]
139
 
140
  weather_df.insert(1, "NO2", None)
141
  weather_df.insert(2, "O3", None)
@@ -147,8 +132,6 @@ def get_combined_data() -> pd.DataFrame:
147
  weather_df = weather_df[columns]
148
  columns.insert(9, columns.pop(6))
149
  weather_df = weather_df[columns]
150
-
151
- print(weather_df)
152
 
153
  combined_df = weather_df
154
 
@@ -183,18 +166,11 @@ def get_combined_data() -> pd.DataFrame:
183
  combined_df["global_radiation"] = combined_df["global_radiation"].astype(int)
184
 
185
  pollution_df = pd.read_csv(POLLUTION_DATA_FILE)
 
186
  pollution_df["date"] = pd.to_datetime(pollution_df["date"])
187
- pollution_df = pollution_df[
188
- (pollution_df["date"] >= seven_days_ago) & (pollution_df["date"] <= today)
189
- ]
190
-
191
- print(pollution_df)
192
- combined_df = pd.merge(combined_df, pollution_df[["date", "NO2", "O3"]], on="date", how="left")
193
- combined_df = combined_df.drop(columns=["NO2_x", "O3_x"])
194
- combined_df = combined_df.rename(columns={"NO2_y": "NO2", "O3_y": "O3"})
195
- cols = ["date", "NO2", "O3", "wind_speed", "mean_temp", "global_radiation", "percipitation",
196
- "pressure", "minimum_visibility", "humidity", "weekday"]
197
- combined_df = combined_df[cols]
198
- print(combined_df)
199
 
200
  return combined_df
 
14
  POLLUTION_DATA_FILE = "pollution_data.csv"
15
 
16
 
17
+ def update_weather_data():
 
 
 
 
18
  today = date.today().isoformat()
19
 
20
  if os.path.exists(WEATHER_DATA_FILE):
 
50
  sys.exit()
51
 
52
 
53
+ def update_pollution_data():
 
 
 
 
54
  O3 = []
55
  NO2 = []
56
  particles = ["NO2", "O3"]
 
113
  updated_data.to_csv(POLLUTION_DATA_FILE, index=False)
114
 
115
 
116
+ def get_combined_data():
 
 
117
 
 
 
 
118
  weather_df = pd.read_csv(WEATHER_DATA_FILE)
119
+
120
  today = pd.Timestamp.now().normalize()
121
  seven_days_ago = today - pd.Timedelta(days=7)
122
  weather_df["date"] = pd.to_datetime(weather_df["date"])
123
+ weather_df = weather_df[(weather_df["date"] >= seven_days_ago) & (weather_df["date"] <= today)]
 
 
124
 
125
  weather_df.insert(1, "NO2", None)
126
  weather_df.insert(2, "O3", None)
 
132
  weather_df = weather_df[columns]
133
  columns.insert(9, columns.pop(6))
134
  weather_df = weather_df[columns]
 
 
135
 
136
  combined_df = weather_df
137
 
 
166
  combined_df["global_radiation"] = combined_df["global_radiation"].astype(int)
167
 
168
  pollution_df = pd.read_csv(POLLUTION_DATA_FILE)
169
+
170
  pollution_df["date"] = pd.to_datetime(pollution_df["date"])
171
+ pollution_df = pollution_df[(pollution_df["date"] >= seven_days_ago) & (pollution_df["date"] <= today)]
172
+
173
+ combined_df["NO2"] = pollution_df["NO2"]
174
+ combined_df["O3"] = pollution_df["O3"]
 
 
 
 
 
 
 
 
175
 
176
  return combined_df
src/features_pipeline.py CHANGED
@@ -6,6 +6,7 @@ import numpy as np
6
  import pandas as pd
7
  from dotenv import load_dotenv
8
  from huggingface_hub import hf_hub_download, login
 
9
  from src.past_data_api_calls import get_past_combined_data
10
 
11
  warnings.filterwarnings("ignore")
@@ -15,44 +16,11 @@ login(token=os.getenv("HUGGINGFACE_DOWNLOAD_TOKEN"))
15
 
16
 
17
  def create_features(
18
- data: pd.DataFrame,
19
- target_particle: str, # Added this parameter
20
- lag_days: int = 7,
21
- sma_days: int = 7,
22
- ) -> pd.DataFrame:
23
- """
24
- Create features for predicting air quality particles (NO2 or O3) based on historical weather data.
25
-
26
- This function performs several feature engineering tasks, including:
27
- - Creating lagged features for specified pollutants.
28
- - Calculating rolling mean (SMA) features.
29
- - Adding sine and cosine transformations of the weekday and month.
30
- - Incorporating historical data for the same date in the previous year.
31
-
32
- Parameters:
33
- ----------
34
- data : pd.DataFrame
35
- A DataFrame containing historical weather and air quality data with a 'date' column.
36
-
37
- target_particle : str
38
- The target particle for prediction, must be either 'O3' or 'NO2'.
39
-
40
- lag_days : int, optional
41
- The number of days for which lagged features will be created. Default is 7.
42
-
43
- sma_days : int, optional
44
- The window size for calculating the simple moving average (SMA). Default is 7.
45
-
46
- Returns:
47
- -------
48
- pd.DataFrame
49
- A DataFrame containing the transformed features, ready for modeling.
50
-
51
- Raises:
52
- ------
53
- ValueError
54
- If target_particle is not 'O3' or 'NO2'.
55
- """
56
  lag_features = [
57
  "NO2",
58
  "O3",
 
6
  import pandas as pd
7
  from dotenv import load_dotenv
8
  from huggingface_hub import hf_hub_download, login
9
+
10
  from src.past_data_api_calls import get_past_combined_data
11
 
12
  warnings.filterwarnings("ignore")
 
16
 
17
 
18
  def create_features(
19
+ data,
20
+ target_particle, # Added this parameter
21
+ lag_days=7,
22
+ sma_days=7,
23
+ ):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  lag_features = [
25
  "NO2",
26
  "O3",
src/helper_functions.py CHANGED
@@ -1,26 +1,9 @@
1
  import streamlit as st
2
 
3
 
4
- def custom_metric_box(label: str, value: str) -> None:
5
- """
6
- Create a styled metric box with a compact layout.
7
-
8
- This function generates a styled markdown box displaying a label and its corresponding value.
9
-
10
- Parameters:
11
- ----------
12
- label : str
13
- The text label to display in the metric box.
14
-
15
- value : str
16
- The value to be displayed in the metric box, typically representing a metric.
17
-
18
- Returns:
19
- -------
20
- None
21
- """
22
- st.markdown(
23
- f"""
24
  <div style="
25
  padding: 5px;
26
  margin-bottom: 5px;
@@ -36,42 +19,17 @@ def custom_metric_box(label: str, value: str) -> None:
36
  <p style="font-size: 18px; font-weight: bold; margin: 0;">{value}</p> <!-- Smaller metric -->
37
  </div>
38
  </div>
39
- """,
40
- unsafe_allow_html=True,
41
- )
42
-
43
-
44
- def pollution_box(label: str, value: str, delta: str, threshold: float) -> None:
45
- """
46
- Create a pollution metric box with a side-by-side layout and fixed width.
47
 
48
- Parameters:
49
- ----------
50
- label : str
51
- The text label representing the type of pollution or metric.
52
- value : str
53
- The value of the pollution metric.
54
- delta : str
55
- The change in pollution level.
56
- threshold : float
57
- The threshold value to determine pollution level status.
58
- """
59
- current_value = float(value.split()[0])
60
-
61
- # Determine status and color based on the same logic as get_simple_color_scale
62
- if current_value < threshold:
63
- status = "Good"
64
- status_color = "#77C124"
65
- elif current_value < 2 * threshold:
66
- status = "Medium"
67
- status_color = "#E68B0A"
68
- else:
69
- status = "Bad"
70
- status_color = "#E63946"
71
 
72
  # Render the pollution box
73
- st.markdown(
74
- f"""
75
  <div style="
76
  background: rgba(255, 255, 255, 0.05);
77
  border-radius: 16px;
@@ -82,10 +40,8 @@ def pollution_box(label: str, value: str, delta: str, threshold: float) -> None:
82
  padding: 15px;
83
  margin-bottom: 10px;
84
  ">
85
- <h4 style="font-size: 24px; font-weight: bold; margin: 0;">{label}</h4>
86
- <p style="font-size: 36px; font-weight: bold; color: {status_color}; margin: 0;">{status}</p>
87
- <p style="font-size: 18px; margin: 0;">{value}</p>
88
  </div>
89
- """,
90
- unsafe_allow_html=True,
91
- )
 
1
  import streamlit as st
2
 
3
 
4
+ # Custom function to create styled metric boxes with compact layout
5
+ def custom_metric_box(label, value):
6
+ st.markdown(f"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  <div style="
8
  padding: 5px;
9
  margin-bottom: 5px;
 
19
  <p style="font-size: 18px; font-weight: bold; margin: 0;">{value}</p> <!-- Smaller metric -->
20
  </div>
21
  </div>
22
+ """, unsafe_allow_html=True)
 
 
 
 
 
 
 
23
 
24
+ # Custom function to create pollution metric boxes with side-by-side layout for label and value
25
+ # Custom function to create pollution metric boxes with side-by-side layout and fixed width
26
+ def pollution_box(label, value, delta, threshold):
27
+ # Determine if the pollution level is "Good" or "Bad"
28
+ status = "Good" if float(value.split()[0]) < threshold else "Bad"
29
+ status_color = "#77C124" if status == "Good" else "#E68B0A"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  # Render the pollution box
32
+ st.markdown(f"""
 
33
  <div style="
34
  background: rgba(255, 255, 255, 0.05);
35
  border-radius: 16px;
 
40
  padding: 15px;
41
  margin-bottom: 10px;
42
  ">
43
+ <h4 style="font-size: 24px; font-weight: bold; margin: 0;">{label}</h4> <!-- Bigger label -->
44
+ <p style="font-size: 36px; font-weight: bold; color: {status_color}; margin: 0;">{status}</p> <!-- Good/Bad with color -->
45
+ <p style="font-size: 18px; margin: 0;">{value}</p> <!-- Smaller value where delta used to be -->
46
  </div>
47
+ """, unsafe_allow_html=True)
 
 
src/past_data_api_calls.py CHANGED
@@ -14,11 +14,7 @@ PAST_WEATHER_DATA_FILE = "past_weather_data.csv"
14
  PAST_POLLUTION_DATA_FILE = "past_pollution_data.csv"
15
 
16
 
17
- def update_past_weather_data() -> None:
18
- """
19
- Updates past weather data.
20
- The data is saved to a CSV file. If the file already exists, new data is appended.
21
- """
22
  last_year_date = date.today() - timedelta(days=365)
23
 
24
  if os.path.exists(PAST_WEATHER_DATA_FILE):
@@ -55,13 +51,7 @@ def update_past_weather_data() -> None:
55
  sys.exit()
56
 
57
 
58
- def update_past_pollution_data() -> tuple[list[float], list[float]]:
59
- """
60
- Updates past pollution data for NO2 and O3.
61
-
62
- Returns:
63
- tuple: A tuple containing two lists with NO2 and O3 average values.
64
- """
65
  O3 = []
66
  NO2 = []
67
  particles = ["NO2", "O3"]
@@ -75,7 +65,7 @@ def update_past_pollution_data() -> tuple[list[float], list[float]]:
75
  last_date = pd.to_datetime(existing_data["date"]).max()
76
  if last_date >= pd.to_datetime(last_year_date):
77
  print("Data is already up to date.")
78
- return [], []
79
  else:
80
  start_date = last_date.date()
81
  end_date = last_year_date + timedelta(days=3)
@@ -139,13 +129,7 @@ def update_past_pollution_data() -> tuple[list[float], list[float]]:
139
  return NO2, O3
140
 
141
 
142
- def get_past_combined_data() -> pd.DataFrame:
143
- """
144
- Retrieves and combines past weather and pollution data.
145
-
146
- Returns:
147
- pd.DataFrame: A DataFrame containing the combined past weather and pollution data.
148
- """
149
  update_past_weather_data()
150
  update_past_pollution_data()
151
 
 
14
  PAST_POLLUTION_DATA_FILE = "past_pollution_data.csv"
15
 
16
 
17
+ def update_past_weather_data():
 
 
 
 
18
  last_year_date = date.today() - timedelta(days=365)
19
 
20
  if os.path.exists(PAST_WEATHER_DATA_FILE):
 
51
  sys.exit()
52
 
53
 
54
+ def update_past_pollution_data():
 
 
 
 
 
 
55
  O3 = []
56
  NO2 = []
57
  particles = ["NO2", "O3"]
 
65
  last_date = pd.to_datetime(existing_data["date"]).max()
66
  if last_date >= pd.to_datetime(last_year_date):
67
  print("Data is already up to date.")
68
+ return
69
  else:
70
  start_date = last_date.date()
71
  end_date = last_year_date + timedelta(days=3)
 
129
  return NO2, O3
130
 
131
 
132
+ def get_past_combined_data():
 
 
 
 
 
 
133
  update_past_weather_data()
134
  update_past_pollution_data()
135
 
src/predict.py CHANGED
@@ -3,9 +3,9 @@ from datetime import date, datetime, timedelta
3
 
4
  import joblib
5
  import pandas as pd
6
- import torch
7
  from dotenv import load_dotenv
8
  from huggingface_hub import hf_hub_download, login
 
9
  from src.data_api_calls import (
10
  get_combined_data,
11
  update_pollution_data,
@@ -17,110 +17,33 @@ load_dotenv()
17
  login(token=os.getenv("HUGGINGFACE_DOWNLOAD_TOKEN"))
18
 
19
 
20
- def load_nn() -> torch.nn.Module:
21
- """
22
- Loads the neural network model for air pollution forecasting.
23
-
24
- Returns:
25
- torch.nn.Module: The loaded neural network model.
26
- """
27
- import torch.nn as nn
28
- from huggingface_hub import PyTorchModelHubMixin
29
-
30
- class AirPollutionNet(nn.Module, PyTorchModelHubMixin):
31
- def __init__(self, input_size: int, layers: list[int], dropout_rate: float):
32
- super(AirPollutionNet, self).__init__()
33
- self.layers_list = nn.ModuleList()
34
- in_features = input_size
35
-
36
- for units in layers:
37
- self.layers_list.append(nn.Linear(in_features, units))
38
- self.layers_list.append(nn.ReLU())
39
- self.layers_list.append(nn.Dropout(p=dropout_rate))
40
- in_features = units
41
-
42
- self.output = nn.Linear(in_features, 3) # Output size is 3 for next 3 days
43
-
44
- def forward(self, x: torch.Tensor) -> torch.Tensor:
45
- """
46
- Forward pass of the neural network.
47
-
48
- Args:
49
- x (torch.Tensor): Input tensor.
50
-
51
- Returns:
52
- torch.Tensor: Output tensor after passing through the network.
53
- """
54
- for layer in self.layers_list:
55
- x = layer(x)
56
- x = self.output(x)
57
- return x
58
-
59
- model = AirPollutionNet.from_pretrained(
60
- "akseljoonas/Utrecht_pollution_forecasting_NO2"
61
- )
62
- return model
63
-
64
-
65
- def load_model(particle: str) -> object:
66
- """
67
- Loads the forecasting model based on the specified particle.
68
-
69
- Args:
70
- particle (str): The type of particle ("O3" or "NO2").
71
-
72
- Returns:
73
- object: The loaded model (either a neural network or a support vector regression model).
74
- """
75
  repo_id = f"elisaklunder/Utrecht-{particle}-Forecasting-Model"
76
  if particle == "O3":
77
  file_name = "O3_svr_model.pkl"
78
- model_path = hf_hub_download(repo_id=repo_id, filename=file_name)
79
- model = joblib.load(model_path)
80
- else:
81
- model = load_nn()
82
 
 
 
83
  return model
84
 
85
 
86
- def run_model(particle: str, data: pd.DataFrame) -> list:
87
- """
88
- Runs the model for the specified particle and makes predictions based on the input data.
89
-
90
- Args:
91
- particle (str): The type of particle ("O3" or "NO2").
92
- data (pd.DataFrame): The input data for making predictions.
93
-
94
- Returns:
95
- list: The predictions for the specified particle.
96
- """
97
  input_data = create_features(data=data, target_particle=particle)
98
  model = load_model(particle)
 
99
 
100
- if particle == "NO2":
101
- with torch.no_grad():
102
- prediction = model(torch.tensor(input_data.values, dtype=torch.float32))
103
- repo_id = "akseljoonas/Utrecht_pollution_forecasting_NO2"
104
- file_name = "target_scaler_NO2.joblib"
105
- path = hf_hub_download(repo_id=repo_id, filename=file_name)
106
- else:
107
- prediction = model.predict(input_data)
108
-
109
- repo_id = f"elisaklunder/Utrecht-{particle}-Forecasting-Model"
110
- file_name = f"target_scaler_{particle}.joblib"
111
- path = hf_hub_download(repo_id=repo_id, filename=file_name)
112
-
113
  target_scaler = joblib.load(path)
114
  prediction = target_scaler.inverse_transform(prediction)
115
 
116
  return prediction
117
 
118
 
119
- def update_data_and_predictions() -> None:
120
- """
121
- Updates the weather and pollution data, makes predictions for O3 and NO2,
122
- and stores them in a CSV file.
123
- """
124
  update_weather_data()
125
  update_pollution_data()
126
 
@@ -166,16 +89,7 @@ def update_data_and_predictions() -> None:
166
  combined_data.to_csv(PREDICTIONS_FILE, index=False)
167
 
168
 
169
- def get_data_and_predictions() -> tuple[pd.DataFrame, list, list]:
170
- """
171
- Retrieves combined data and today's predictions for O3 and NO2.
172
-
173
- Returns:
174
- tuple: A tuple containing:
175
- - week_data (pd.DataFrame): The combined data for the week.
176
- - list: Predictions for O3.
177
- - list: Predictions for NO2.
178
- """
179
  week_data = get_combined_data()
180
 
181
  PREDICTIONS_FILE = "predictions_history.csv"
@@ -193,7 +107,3 @@ def get_data_and_predictions() -> tuple[pd.DataFrame, list, list]:
193
  ].values
194
 
195
  return week_data, [o3_predictions], [no2_predictions]
196
-
197
-
198
- if __name__ == "__main__":
199
- update_data_and_predictions()
 
3
 
4
  import joblib
5
  import pandas as pd
 
6
  from dotenv import load_dotenv
7
  from huggingface_hub import hf_hub_download, login
8
+
9
  from src.data_api_calls import (
10
  get_combined_data,
11
  update_pollution_data,
 
17
  login(token=os.getenv("HUGGINGFACE_DOWNLOAD_TOKEN"))
18
 
19
 
20
+ def load_model(particle):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  repo_id = f"elisaklunder/Utrecht-{particle}-Forecasting-Model"
22
  if particle == "O3":
23
  file_name = "O3_svr_model.pkl"
24
+ elif particle == "NO2":
25
+ file_name = "NO2_svr_model.pkl"
 
 
26
 
27
+ model_path = hf_hub_download(repo_id=repo_id, filename=file_name)
28
+ model = joblib.load(model_path)
29
  return model
30
 
31
 
32
+ def run_model(particle, data):
 
 
 
 
 
 
 
 
 
 
33
  input_data = create_features(data=data, target_particle=particle)
34
  model = load_model(particle)
35
+ prediction = model.predict(input_data)
36
 
37
+ repo_id = f"elisaklunder/Utrecht-{particle}-Forecasting-Model"
38
+ file_name = f"target_scaler_{particle}.joblib"
39
+ path = hf_hub_download(repo_id=repo_id, filename=file_name)
 
 
 
 
 
 
 
 
 
 
40
  target_scaler = joblib.load(path)
41
  prediction = target_scaler.inverse_transform(prediction)
42
 
43
  return prediction
44
 
45
 
46
+ def update_data_and_predictions():
 
 
 
 
47
  update_weather_data()
48
  update_pollution_data()
49
 
 
89
  combined_data.to_csv(PREDICTIONS_FILE, index=False)
90
 
91
 
92
+ def get_data_and_predictions():
 
 
 
 
 
 
 
 
 
93
  week_data = get_combined_data()
94
 
95
  PREDICTIONS_FILE = "predictions_history.csv"
 
107
  ].values
108
 
109
  return week_data, [o3_predictions], [no2_predictions]
 
 
 
 
test.ipynb ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stderr",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "c:\\Users\\elikl\\Documents\\Uni\\yr3\\ML for industry\\utrecht-pollution-prediction\\.venv\\Lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
13
+ " from .autonotebook import tqdm as notebook_tqdm\n"
14
+ ]
15
+ }
16
+ ],
17
+ "source": [
18
+ "from src.predict import get_data_and_predictions\n",
19
+ "from src.data_api_calls import get_combined_data\n",
20
+ "from src.past_data_api_calls import get_past_combined_data"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": 2,
26
+ "metadata": {},
27
+ "outputs": [
28
+ {
29
+ "name": "stdout",
30
+ "output_type": "stream",
31
+ "text": [
32
+ "Data is already up to date.\n",
33
+ "Data is already up to date.\n",
34
+ "Number of rows with missing values dropped: 7\n",
35
+ "Data is already up to date.\n",
36
+ "Number of rows with missing values dropped: 7\n"
37
+ ]
38
+ }
39
+ ],
40
+ "source": [
41
+ "week_data, predictions_O3, predictions_NO2 = get_data_and_predictions()"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": 3,
47
+ "metadata": {},
48
+ "outputs": [
49
+ {
50
+ "data": {
51
+ "text/html": [
52
+ "<div>\n",
53
+ "<style scoped>\n",
54
+ " .dataframe tbody tr th:only-of-type {\n",
55
+ " vertical-align: middle;\n",
56
+ " }\n",
57
+ "\n",
58
+ " .dataframe tbody tr th {\n",
59
+ " vertical-align: top;\n",
60
+ " }\n",
61
+ "\n",
62
+ " .dataframe thead th {\n",
63
+ " text-align: right;\n",
64
+ " }\n",
65
+ "</style>\n",
66
+ "<table border=\"1\" class=\"dataframe\">\n",
67
+ " <thead>\n",
68
+ " <tr style=\"text-align: right;\">\n",
69
+ " <th></th>\n",
70
+ " <th>date</th>\n",
71
+ " <th>NO2</th>\n",
72
+ " <th>O3</th>\n",
73
+ " <th>wind_speed</th>\n",
74
+ " <th>mean_temp</th>\n",
75
+ " <th>global_radiation</th>\n",
76
+ " <th>percipitation</th>\n",
77
+ " <th>pressure</th>\n",
78
+ " <th>minimum_visibility</th>\n",
79
+ " <th>humidity</th>\n",
80
+ " <th>weekday</th>\n",
81
+ " </tr>\n",
82
+ " </thead>\n",
83
+ " <tbody>\n",
84
+ " <tr>\n",
85
+ " <th>0</th>\n",
86
+ " <td>2024-10-17</td>\n",
87
+ " <td>22.804605</td>\n",
88
+ " <td>22.769160</td>\n",
89
+ " <td>51</td>\n",
90
+ " <td>169</td>\n",
91
+ " <td>43</td>\n",
92
+ " <td>6</td>\n",
93
+ " <td>10100</td>\n",
94
+ " <td>371</td>\n",
95
+ " <td>86</td>\n",
96
+ " <td>Thursday</td>\n",
97
+ " </tr>\n",
98
+ " <tr>\n",
99
+ " <th>1</th>\n",
100
+ " <td>2024-10-18</td>\n",
101
+ " <td>23.268500</td>\n",
102
+ " <td>23.307332</td>\n",
103
+ " <td>21</td>\n",
104
+ " <td>155</td>\n",
105
+ " <td>42</td>\n",
106
+ " <td>39</td>\n",
107
+ " <td>10140</td>\n",
108
+ " <td>45</td>\n",
109
+ " <td>97</td>\n",
110
+ " <td>Friday</td>\n",
111
+ " </tr>\n",
112
+ " <tr>\n",
113
+ " <th>2</th>\n",
114
+ " <td>2024-10-19</td>\n",
115
+ " <td>23.910064</td>\n",
116
+ " <td>23.171714</td>\n",
117
+ " <td>41</td>\n",
118
+ " <td>147</td>\n",
119
+ " <td>43</td>\n",
120
+ " <td>16</td>\n",
121
+ " <td>10141</td>\n",
122
+ " <td>228</td>\n",
123
+ " <td>89</td>\n",
124
+ " <td>Saturday</td>\n",
125
+ " </tr>\n",
126
+ " <tr>\n",
127
+ " <th>3</th>\n",
128
+ " <td>2024-10-20</td>\n",
129
+ " <td>22.573238</td>\n",
130
+ " <td>23.537845</td>\n",
131
+ " <td>81</td>\n",
132
+ " <td>155</td>\n",
133
+ " <td>0</td>\n",
134
+ " <td>5</td>\n",
135
+ " <td>10160</td>\n",
136
+ " <td>415</td>\n",
137
+ " <td>83</td>\n",
138
+ " <td>Sunday</td>\n",
139
+ " </tr>\n",
140
+ " <tr>\n",
141
+ " <th>4</th>\n",
142
+ " <td>2024-10-21</td>\n",
143
+ " <td>21.145700</td>\n",
144
+ " <td>24.020696</td>\n",
145
+ " <td>58</td>\n",
146
+ " <td>144</td>\n",
147
+ " <td>27</td>\n",
148
+ " <td>43</td>\n",
149
+ " <td>10206</td>\n",
150
+ " <td>220</td>\n",
151
+ " <td>92</td>\n",
152
+ " <td>Monday</td>\n",
153
+ " </tr>\n",
154
+ " <tr>\n",
155
+ " <th>5</th>\n",
156
+ " <td>2024-10-22</td>\n",
157
+ " <td>21.776580</td>\n",
158
+ " <td>23.335886</td>\n",
159
+ " <td>53</td>\n",
160
+ " <td>114</td>\n",
161
+ " <td>57</td>\n",
162
+ " <td>49</td>\n",
163
+ " <td>10269</td>\n",
164
+ " <td>226</td>\n",
165
+ " <td>92</td>\n",
166
+ " <td>Tuesday</td>\n",
167
+ " </tr>\n",
168
+ " <tr>\n",
169
+ " <th>6</th>\n",
170
+ " <td>2024-10-23</td>\n",
171
+ " <td>21.974794</td>\n",
172
+ " <td>22.214689</td>\n",
173
+ " <td>36</td>\n",
174
+ " <td>112</td>\n",
175
+ " <td>12</td>\n",
176
+ " <td>0</td>\n",
177
+ " <td>10328</td>\n",
178
+ " <td>65</td>\n",
179
+ " <td>97</td>\n",
180
+ " <td>Wednesday</td>\n",
181
+ " </tr>\n",
182
+ " <tr>\n",
183
+ " <th>7</th>\n",
184
+ " <td>2024-10-24</td>\n",
185
+ " <td>25.512568</td>\n",
186
+ " <td>20.913710</td>\n",
187
+ " <td>56</td>\n",
188
+ " <td>104</td>\n",
189
+ " <td>62</td>\n",
190
+ " <td>0</td>\n",
191
+ " <td>10247</td>\n",
192
+ " <td>130</td>\n",
193
+ " <td>94</td>\n",
194
+ " <td>Thursday</td>\n",
195
+ " </tr>\n",
196
+ " </tbody>\n",
197
+ "</table>\n",
198
+ "</div>"
199
+ ],
200
+ "text/plain": [
201
+ " date NO2 O3 wind_speed mean_temp global_radiation \\\n",
202
+ "0 2024-10-17 22.804605 22.769160 51 169 43 \n",
203
+ "1 2024-10-18 23.268500 23.307332 21 155 42 \n",
204
+ "2 2024-10-19 23.910064 23.171714 41 147 43 \n",
205
+ "3 2024-10-20 22.573238 23.537845 81 155 0 \n",
206
+ "4 2024-10-21 21.145700 24.020696 58 144 27 \n",
207
+ "5 2024-10-22 21.776580 23.335886 53 114 57 \n",
208
+ "6 2024-10-23 21.974794 22.214689 36 112 12 \n",
209
+ "7 2024-10-24 25.512568 20.913710 56 104 62 \n",
210
+ "\n",
211
+ " percipitation pressure minimum_visibility humidity weekday \n",
212
+ "0 6 10100 371 86 Thursday \n",
213
+ "1 39 10140 45 97 Friday \n",
214
+ "2 16 10141 228 89 Saturday \n",
215
+ "3 5 10160 415 83 Sunday \n",
216
+ "4 43 10206 220 92 Monday \n",
217
+ "5 49 10269 226 92 Tuesday \n",
218
+ "6 0 10328 65 97 Wednesday \n",
219
+ "7 0 10247 130 94 Thursday "
220
+ ]
221
+ },
222
+ "execution_count": 3,
223
+ "metadata": {},
224
+ "output_type": "execute_result"
225
+ }
226
+ ],
227
+ "source": [
228
+ "week_data"
229
+ ]
230
+ },
231
+ {
232
+ "cell_type": "code",
233
+ "execution_count": 4,
234
+ "metadata": {},
235
+ "outputs": [
236
+ {
237
+ "data": {
238
+ "text/plain": [
239
+ "array([[10.33808859, 16.00098432, 19.64377496]])"
240
+ ]
241
+ },
242
+ "execution_count": 4,
243
+ "metadata": {},
244
+ "output_type": "execute_result"
245
+ }
246
+ ],
247
+ "source": [
248
+ "predictions_O3"
249
+ ]
250
+ },
251
+ {
252
+ "cell_type": "code",
253
+ "execution_count": 5,
254
+ "metadata": {},
255
+ "outputs": [
256
+ {
257
+ "data": {
258
+ "text/plain": [
259
+ "array([[25.68519992, 25.76030745, 31.21057679]])"
260
+ ]
261
+ },
262
+ "execution_count": 5,
263
+ "metadata": {},
264
+ "output_type": "execute_result"
265
+ }
266
+ ],
267
+ "source": [
268
+ "predictions_NO2"
269
+ ]
270
+ },
271
+ {
272
+ "cell_type": "code",
273
+ "execution_count": 1,
274
+ "metadata": {},
275
+ "outputs": [],
276
+ "source": [
277
+ "from src.data_api_calls import get_combined_data"
278
+ ]
279
+ },
280
+ {
281
+ "cell_type": "code",
282
+ "execution_count": 2,
283
+ "metadata": {},
284
+ "outputs": [
285
+ {
286
+ "ename": "TypeError",
287
+ "evalue": "'<' not supported between instances of 'Timestamp' and 'str'",
288
+ "output_type": "error",
289
+ "traceback": [
290
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
291
+ "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
292
+ "Cell \u001b[1;32mIn[2], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mget_combined_data\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m2024-10-10\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
293
+ "File \u001b[1;32mc:\\Users\\elikl\\Documents\\Uni\\yr3\\ML for industry\\utrecht-pollution-prediction\\src\\data_api_calls.py:136\u001b[0m, in \u001b[0;36mget_combined_data\u001b[1;34m(input_date)\u001b[0m\n\u001b[0;32m 133\u001b[0m start_date \u001b[38;5;241m=\u001b[39m end_date \u001b[38;5;241m-\u001b[39m timedelta(\u001b[38;5;241m7\u001b[39m)\n\u001b[0;32m 135\u001b[0m update_weather_data(start_date, end_date)\n\u001b[1;32m--> 136\u001b[0m \u001b[43mupdate_pollution_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstart_date\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mend_date\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 138\u001b[0m weather_df \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mread_csv(WEATHER_DATA_FILE)\n\u001b[0;32m 140\u001b[0m weather_df\u001b[38;5;241m.\u001b[39minsert(\u001b[38;5;241m1\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNO2\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n",
294
+ "File \u001b[1;32mc:\\Users\\elikl\\Documents\\Uni\\yr3\\ML for industry\\utrecht-pollution-prediction\\src\\data_api_calls.py:123\u001b[0m, in \u001b[0;36mupdate_pollution_data\u001b[1;34m(start_date, end_date)\u001b[0m\n\u001b[0;32m 121\u001b[0m updated_data \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mconcat([existing_data, new_data], ignore_index\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m 122\u001b[0m updated_data\u001b[38;5;241m.\u001b[39mdrop_duplicates(subset\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdate\u001b[39m\u001b[38;5;124m\"\u001b[39m, keep\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlast\u001b[39m\u001b[38;5;124m\"\u001b[39m, inplace\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m--> 123\u001b[0m updated_data \u001b[38;5;241m=\u001b[39m \u001b[43mupdated_data\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msort_values\u001b[49m\u001b[43m(\u001b[49m\u001b[43mby\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdate\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 124\u001b[0m updated_data\u001b[38;5;241m.\u001b[39mto_csv(POLLUTION_DATA_FILE, index\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n",
295
+ "File \u001b[1;32mc:\\Users\\elikl\\Documents\\Uni\\yr3\\ML for industry\\utrecht-pollution-prediction\\.venv\\Lib\\site-packages\\pandas\\core\\frame.py:7200\u001b[0m, in \u001b[0;36mDataFrame.sort_values\u001b[1;34m(self, by, axis, ascending, inplace, kind, na_position, ignore_index, key)\u001b[0m\n\u001b[0;32m 7197\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(ascending, (\u001b[38;5;28mtuple\u001b[39m, \u001b[38;5;28mlist\u001b[39m)):\n\u001b[0;32m 7198\u001b[0m ascending \u001b[38;5;241m=\u001b[39m ascending[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m-> 7200\u001b[0m indexer \u001b[38;5;241m=\u001b[39m \u001b[43mnargsort\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 7201\u001b[0m \u001b[43m \u001b[49m\u001b[43mk\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkind\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkind\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mascending\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mascending\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mna_position\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mna_position\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkey\u001b[49m\n\u001b[0;32m 7202\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 7203\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 7204\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m inplace:\n",
296
+ "File \u001b[1;32mc:\\Users\\elikl\\Documents\\Uni\\yr3\\ML for industry\\utrecht-pollution-prediction\\.venv\\Lib\\site-packages\\pandas\\core\\sorting.py:439\u001b[0m, in \u001b[0;36mnargsort\u001b[1;34m(items, kind, ascending, na_position, key, mask)\u001b[0m\n\u001b[0;32m 437\u001b[0m non_nans \u001b[38;5;241m=\u001b[39m non_nans[::\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n\u001b[0;32m 438\u001b[0m non_nan_idx \u001b[38;5;241m=\u001b[39m non_nan_idx[::\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m--> 439\u001b[0m indexer \u001b[38;5;241m=\u001b[39m non_nan_idx[\u001b[43mnon_nans\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43margsort\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkind\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkind\u001b[49m\u001b[43m)\u001b[49m]\n\u001b[0;32m 440\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m ascending:\n\u001b[0;32m 441\u001b[0m indexer \u001b[38;5;241m=\u001b[39m indexer[::\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n",
297
+ "\u001b[1;31mTypeError\u001b[0m: '<' not supported between instances of 'Timestamp' and 'str'"
298
+ ]
299
+ }
300
+ ],
301
+ "source": [
302
+ "get_combined_data(\"2024-10-10\")"
303
+ ]
304
+ }
305
+ ],
306
+ "metadata": {
307
+ "kernelspec": {
308
+ "display_name": ".venv",
309
+ "language": "python",
310
+ "name": "python3"
311
+ },
312
+ "language_info": {
313
+ "codemirror_mode": {
314
+ "name": "ipython",
315
+ "version": 3
316
+ },
317
+ "file_extension": ".py",
318
+ "mimetype": "text/x-python",
319
+ "name": "python",
320
+ "nbconvert_exporter": "python",
321
+ "pygments_lexer": "ipython3",
322
+ "version": "3.11.8"
323
+ }
324
+ },
325
+ "nbformat": 4,
326
+ "nbformat_minor": 2
327
+ }
weather_data.csv CHANGED
@@ -13,165 +13,3 @@ date,temp,humidity,precip,windspeed,sealevelpressure,visibility,solarradiation
13
  2024-10-28,12.4,91.8,1.1,31.7,1021.8,12.8,27.3
14
  2024-10-29,13.8,95.9,0.2,20.5,1023.1,8.1,16.0
15
  2024-10-30,12.7,92.9,0.6,9.4,1027.5,12.5,32.8
16
- 2024-10-31,12.5,89.9,0.0,11.2,1027.1,17.1,70.6
17
- 2024-11-01,9.9,96.9,0.0,14.4,1024.3,3.2,10.0
18
- 2024-11-02,10.0,87.6,0.5,14.4,1030.9,17.9,36.1
19
- 2024-11-03,5.6,91.4,0.0,7.2,1030.3,14.0,37.7
20
- 2024-11-04,7.0,89.8,0.0,18.0,1027.6,13.9,38.4
21
- 2024-11-05,5.9,92.8,0.0,10.8,1024.0,7.3,33.1
22
- 2024-11-06,8.2,94.3,0.0,7.6,1030.2,3.5,27.1
23
- 2024-11-07,5.7,95.4,0.0,18.0,1033.1,3.7,11.6
24
- 2024-11-08,4.7,91.6,0.0,14.4,1028.5,5.0,10.8
25
- 2024-11-09,6.4,93.7,0.5,7.6,1025.4,5.0,13.0
26
- 2024-11-10,9.0,94.0,0.0,10.8,1027.4,5.4,28.1
27
- 2024-11-11,10.3,86.1,4.8,21.6,1028.7,16.0,25.6
28
- 2024-11-12,8.3,86.0,0.0,18.4,1032.5,24.1,24.8
29
- 2024-11-13,8.0,92.1,0.0,10.8,1032.5,13.2,21.5
30
- 2024-11-14,10.0,89.6,0.3,14.4,1028.6,19.7,23.5
31
- 2024-11-15,8.4,93.6,0.0,11.2,1026.9,9.1,17.8
32
- 2024-11-16,8.7,85.9,3.5,18.4,1017.6,12.3,11.7
33
- 2024-11-17,7.9,81.3,6.0,21.6,1010.4,30.1,23.4
34
- 2024-11-18,4.8,90.2,3.5,13.7,1009.4,22.9,20.9
35
- 2024-11-19,4.3,97.1,16.7,19.1,994.9,14.7,9.0
36
- 2024-11-20,1.5,94.4,4.8,24.5,1000.1,18.3,12.0
37
- 2024-11-21,0.8,91.9,0.0,24.1,998.6,20.9,34.6
38
- 2024-11-22,3.1,86.2,8.6,21.6,1001.4,35.5,23.2
39
- 2024-11-23,4.2,84.6,9.4,28.8,1011.5,34.8,13.6
40
- 2024-11-24,13.8,68.4,0.9,28.8,1003.5,43.6,34.7
41
- 2024-11-25,12.6,78.6,4.6,32.4,1002.8,30.8,7.3
42
- 2024-11-26,7.7,87.7,0.1,25.2,1015.6,24.6,30.4
43
- 2024-11-27,7.4,91.6,11.1,28.8,1012.2,15.7,5.5
44
- 2024-11-28,7.0,80.8,1.2,14.4,1024.5,42.3,41.5
45
- 2024-11-29,3.7,88.6,0.0,14.4,1031.4,26.0,44.4
46
- 2024-11-30,3.6,83.5,0.0,18.0,1027.3,32.8,39.5
47
- 2024-12-01,3.5,82.6,0.2,22.7,1019.6,23.3,41.3
48
- 2024-12-02,9.7,92.5,4.8,21.6,1011.9,19.3,18.9
49
- 2024-12-03,5.9,84.6,2.0,14.4,1018.5,30.7,31.8
50
- 2024-12-04,3.8,92.8,1.2,10.8,1024.9,25.3,11.2
51
- 2024-12-05,6.5,93.3,13.2,25.2,1012.8,8.7,3.9
52
- 2024-12-06,8.8,78.9,7.5,32.4,1007.6,16.9,16.6
53
- 2024-12-07,7.7,87.7,7.4,28.8,995.1,21.5,24.0
54
- 2024-12-08,6.7,91.8,1.0,21.6,1007.8,23.2,14.8
55
- 2024-12-09,6.3,81.2,0.0,28.8,1026.8,40.2,8.0
56
- 2024-12-10,5.2,83.7,0.0,21.6,1031.1,33.7,5.1
57
- 2024-12-11,3.7,84.7,0.0,14.4,1032.2,17.3,5.0
58
- 2024-12-12,3.4,95.6,0.5,10.8,1031.7,5.8,7.7
59
- 2024-12-13,1.9,87.8,0.0,14.4,1027.6,7.9,5.3
60
- 2024-12-14,3.9,90.7,3.0,18.0,1019.3,8.5,8.7
61
- 2024-12-15,7.5,93.5,0.2,21.6,1024.1,19.1,8.0
62
- 2024-12-16,10.0,89.0,0.6,21.6,1028.5,25.5,6.0
63
- 2024-12-17,8.3,90.7,0.0,18.0,1025.9,20.9,11.9
64
- 2024-12-18,10.0,86.0,0.6,37.8,1010.7,27.7,7.5
65
- 2024-12-19,8.4,86.9,14.3,36.0,1000.7,23.8,5.6
66
- 2024-12-20,5.9,80.5,0.3,21.6,1016.7,29.7,34.4
67
- 2024-12-21,8.1,91.9,5.8,28.8,1009.8,16.4,7.8
68
- 2024-12-22,6.1,76.5,7.5,25.2,999.3,27.3,17.9
69
- 2024-12-23,6.2,80.4,5.5,28.8,1013.9,24.2,29.5
70
- 2024-12-24,5.3,95.6,2.7,14.4,1025.1,10.3,7.3
71
- 2024-12-25,8.8,98.7,0.3,10.8,1032.9,2.6,7.8
72
- 2024-12-26,6.8,98.3,0.0,11.2,1036.2,3.0,8.0
73
- 2024-12-27,2.8,98.3,0.0,10.8,1033.9,2.0,33.4
74
- 2024-12-28,1.0,98.8,0.0,11.2,1030.0,1.0,10.3
75
- 2024-12-29,3.8,96.8,0.6,18.0,1028.5,2.8,4.9
76
- 2024-12-30,6.8,91.6,0.3,21.6,1027.5,12.3,6.1
77
- 2024-12-31,4.6,89.3,0.0,28.8,1023.3,14.3,10.2
78
- 2025-01-01,8.0,81.9,13.0,43.2,1009.5,33.0,5.3
79
- 2025-01-02,3.3,90.2,2.3,18.0,1013.0,31.0,32.7
80
- 2025-01-03,2.3,87.4,3.6,21.6,1018.2,37.4,11.8
81
- 2025-01-04,2.0,92.4,1.1,14.4,1017.7,20.0,14.9
82
- 2025-01-05,4.7,93.9,21.0,25.9,995.6,12.5,4.6
83
- 2025-01-06,9.2,82.9,3.8,46.8,984.1,35.3,9.9
84
- 2025-01-07,3.8,85.9,1.1,25.2,996.6,43.0,32.6
85
- 2025-01-08,2.7,87.0,0.2,18.0,1001.4,34.1,26.8
86
- 2025-01-09,2.0,88.1,1.6,19.4,1003.0,26.2,22.0
87
- 2025-01-10,2.6,85.2,3.7,21.6,1016.8,28.5,34.9
88
- 2025-01-11,0.3,90.7,0.1,10.8,1026.7,23.3,38.3
89
- 2025-01-12,1.9,88.9,0.1,10.8,1038.4,38.7,21.5
90
- 2025-01-13,0.7,85.8,0.0,14.8,1041.1,20.7,40.3
91
- 2025-01-14,2.3,86.3,0.1,18.0,1034.3,12.0,29.2
92
- 2025-01-15,6.6,99.9,0.0,7.2,1033.6,0.7,12.3
93
- 2025-01-16,3.8,99.6,0.0,14.8,1036.4,1.3,8.1
94
- 2025-01-17,0.4,99.3,0.0,14.8,1037.4,0.8,10.8
95
- 2025-01-18,-1.3,98.8,0.0,10.8,1032.0,1.0,13.2
96
- 2025-01-19,-0.9,97.6,0.0,10.8,1023.7,2.5,8.8
97
- 2025-01-20,-0.4,95.4,0.0,14.4,1019.6,2.8,10.8
98
- 2025-01-21,-0.4,98.0,0.0,14.8,1016.3,1.5,11.2
99
- 2025-01-22,1.7,94.5,4.8,14.4,1004.9,6.6,14.0
100
- 2025-01-23,5.4,87.9,3.9,25.2,1002.6,16.1,44.5
101
- 2025-01-24,7.7,87.7,3.0,28.8,1001.1,31.1,10.1
102
- 2025-01-25,5.4,93.6,4.2,14.4,1004.0,18.0,19.8
103
- 2025-01-26,3.5,87.9,1.8,28.8,1004.0,32.4,42.3
104
- 2025-01-27,9.0,77.4,6.0,28.8,988.5,38.8,39.7
105
- 2025-01-28,7.9,80.7,1.5,25.2,989.7,40.5,17.3
106
- 2025-01-29,7.4,86.6,5.6,25.2,1000.6,29.6,24.5
107
- 2025-01-30,5.5,89.0,1.6,10.8,1015.3,22.7,19.2
108
- 2025-01-31,2.2,90.6,0.0,10.8,1027.0,20.7,43.5
109
- 2025-02-01,0.0,89.2,0.0,10.8,1031.7,16.8,54.5
110
- 2025-02-02,-1.2,88.8,0.0,10.8,1025.8,12.3,65.0
111
- 2025-02-03,0.2,88.4,0.0,10.8,1026.7,8.0,66.4
112
- 2025-02-04,2.5,88.7,0.0,18.0,1026.6,12.4,19.7
113
- 2025-02-05,4.8,94.2,0.0,18.0,1036.1,4.8,21.6
114
- 2025-02-06,4.2,90.4,0.0,21.6,1041.8,17.5,39.1
115
- 2025-02-07,3.3,75.4,0.0,32.4,1029.6,33.4,26.1
116
- 2025-02-08,4.1,74.4,0.0,21.6,1021.7,15.0,24.2
117
- 2025-02-09,3.5,79.4,0.0,18.0,1028.1,9.8,38.2
118
- 2025-02-10,1.9,82.3,2.2,25.2,1025.2,7.8,29.2
119
- 2025-02-11,3.0,93.1,10.5,25.2,1017.3,8.8,18.5
120
- 2025-02-12,4.0,94.0,6.3,7.2,1017.8,4.4,29.0
121
- 2025-02-13,0.9,86.9,1.0,18.0,1021.6,5.6,40.7
122
- 2025-02-14,-0.2,84.3,0.0,10.8,1027.7,13.2,66.5
123
- 2025-02-15,1.6,76.6,0.0,10.8,1024.5,13.5,39.0
124
- 2025-02-16,0.6,72.9,0.0,29.5,1023.0,25.4,98.6
125
- 2025-02-17,-1.3,73.9,0.0,14.4,1025.0,34.5,103.5
126
- 2025-02-18,-1.0,64.1,0.0,21.6,1025.7,38.3,105.8
127
- 2025-02-19,1.3,54.2,0.0,25.2,1022.0,41.7,71.3
128
- 2025-02-20,6.3,83.1,0.8,19.1,1019.7,14.6,37.7
129
- 2025-02-21,12.9,77.0,0.0,21.6,1016.8,30.2,68.8
130
- 2025-02-22,10.5,88.1,3.1,18.0,1014.2,20.0,20.5
131
- 2025-02-23,10.2,83.4,0.0,21.6,1024.8,20.4,93.5
132
- 2025-02-24,11.0,78.3,2.5,25.9,1015.7,34.1,22.8
133
- 2025-02-25,9.1,88.1,0.0,14.4,1013.4,10.5,58.0
134
- 2025-02-26,7.6,78.2,2.0,21.6,1014.7,27.9,111.8
135
- 2025-02-27,6.0,88.3,2.9,18.0,1014.2,31.4,68.4
136
- 2025-02-28,5.2,83.6,0.1,18.0,1025.6,21.7,98.3
137
- 2025-03-01,3.7,85.7,0.0,14.4,1033.3,27.1,47.3
138
- 2025-03-02,2.0,86.8,0.0,7.2,1034.9,13.5,99.9
139
- 2025-03-03,2.3,81.7,0.0,7.6,1029.9,10.8,131.4
140
- 2025-03-04,3.1,80.8,0.0,10.8,1026.7,6.6,131.6
141
- 2025-03-05,5.4,74.6,0.0,18.0,1023.1,9.6,157.3
142
- 2025-03-06,7.2,72.3,0.0,14.4,1017.7,21.5,128.1
143
- 2025-03-07,9.5,68.1,0.0,14.4,1016.1,38.3,134.3
144
- 2025-03-08,9.9,63.3,0.0,21.6,1012.9,32.3,143.2
145
- 2025-03-09,9.5,64.5,0.0,14.4,1006.0,17.6,131.5
146
- 2025-03-10,8.4,71.3,0.0,11.2,1002.4,10.2,140.8
147
- 2025-03-11,5.9,78.7,0.0,18.0,1003.7,19.3,90.3
148
- 2025-03-12,4.6,79.3,0.3,14.8,1000.7,34.6,118.4
149
- 2025-03-13,3.0,82.5,0.0,14.4,1000.6,30.1,62.0
150
- 2025-03-14,2.2,74.6,0.0,18.0,1009.5,33.8,95.8
151
- 2025-03-15,3.7,67.3,0.0,21.6,1019.9,42.5,129.6
152
- 2025-03-16,4.3,71.3,0.0,14.8,1023.3,35.9,168.3
153
- 2025-03-17,6.3,60.0,0.0,25.9,1028.6,36.0,128.6
154
- 2025-03-18,5.0,41.8,0.0,25.2,1028.3,43.5,175.3
155
- 2025-03-19,6.8,56.2,0.0,14.4,1024.0,39.3,200.8
156
- 2025-03-20,10.2,64.0,0.0,10.8,1021.4,24.6,141.9
157
- 2025-03-21,14.3,54.9,0.0,32.4,1013.5,23.8,158.8
158
- 2025-03-22,15.3,51.4,0.0,22.3,1004.1,34.3,118.0
159
- 2025-03-23,13.4,70.9,0.3,14.4,1003.7,37.0,110.6
160
- 2025-03-24,9.9,83.3,0.0,14.8,1014.5,7.5,155.5
161
- 2025-03-25,8.3,79.7,0.0,14.8,1020.5,9.3,100.2
162
- 2025-03-26,8.5,80.9,0.0,18.0,1024.2,27.3,60.8
163
- 2025-03-27,7.0,77.7,0.0,11.2,1021.3,13.9,208.4
164
- 2025-03-28,6.7,88.5,0.5,18.0,1012.7,13.3,73.3
165
- 2025-03-29,7.9,77.5,0.0,14.4,1018.7,25.1,182.0
166
- 2025-03-30,10.1,71.2,0.4,28.8,1016.6,21.1,112.8
167
- 2025-03-31,9.0,68.7,0.0,21.6,1026.6,28.0,212.8
168
- 2025-04-01,8.0,70.8,0.0,25.2,1028.2,27.4,223.3
169
- 2025-04-02,11.7,53.8,0.0,32.4,1024.4,41.0,220.0
170
- 2025-04-03,14.2,51.6,0.0,28.8,1022.9,38.4,221.0
171
- 2025-04-04,14.1,54.8,0.0,18.4,1020.5,33.9,230.8
172
- 2025-04-05,10.8,57.4,0.0,21.6,1019.7,37.5,236.0
173
- 2025-04-06,8.2,41.9,0.0,20.5,1024.5,24.1,241.4
174
- 2025-04-07,7.9,49.1,0.0,13.3,1026.2,24.1,239.5
175
- 2025-04-08,9.9,53.7,0.0,14.8,1026.9,24.1,221.1
176
- 2025-04-09,8.1,73.4,0.0,25.9,1026.9,11.2,229.1
177
- 2025-04-10,9.5,73.4,0.0,22.3,1028.3,12.9,203.9
 
13
  2024-10-28,12.4,91.8,1.1,31.7,1021.8,12.8,27.3
14
  2024-10-29,13.8,95.9,0.2,20.5,1023.1,8.1,16.0
15
  2024-10-30,12.7,92.9,0.6,9.4,1027.5,12.5,32.8