Spaces:
Sleeping
Sleeping
Update feature_handler.py
Browse files- feature_handler.py +6 -4
feature_handler.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
-
|
| 4 |
def apply_feature_engineering(df_input):
|
| 5 |
df = df_input.copy()
|
| 6 |
df['time'] = pd.to_datetime(df['time'])
|
|
@@ -35,10 +35,12 @@ def apply_feature_engineering(df_input):
|
|
| 35 |
df['is_hot_day'] = (df['temperature_2m_max'] >= 35).astype(int)
|
| 36 |
df['is_heavy_rain'] = (df['precipitation_sum'] >= 20).astype(int)
|
| 37 |
|
| 38 |
-
# 4. Gestion de la Région (Le preprocessor attend une colonne 'region')
|
| 39 |
-
# On va chercher la région dans ton dictionnaire CITIES_COORDS
|
| 40 |
def get_region(city):
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
df['region'] = df['city'].apply(get_region)
|
| 43 |
|
| 44 |
# 5. Séries temporelles (Lags)
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
+
from config import CITIES_COORDS
|
| 4 |
def apply_feature_engineering(df_input):
|
| 5 |
df = df_input.copy()
|
| 6 |
df['time'] = pd.to_datetime(df['time'])
|
|
|
|
| 35 |
df['is_hot_day'] = (df['temperature_2m_max'] >= 35).astype(int)
|
| 36 |
df['is_heavy_rain'] = (df['precipitation_sum'] >= 20).astype(int)
|
| 37 |
|
|
|
|
|
|
|
| 38 |
def get_region(city):
|
| 39 |
+
city_info = CITIES_COORDS.get(city)
|
| 40 |
+
if city_info:
|
| 41 |
+
return city_info.get('region', 'Littoral')
|
| 42 |
+
return 'Littoral'
|
| 43 |
+
|
| 44 |
df['region'] = df['city'].apply(get_region)
|
| 45 |
|
| 46 |
# 5. Séries temporelles (Lags)
|