]> AND Private Git Repository - predictops.git/blobdiff - predictops/source/ephemeris.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Reducing the computation time and adding holidays features
[predictops.git] / predictops / source / ephemeris.py
index e46b296ad09efd78afdff11163e43f3606ce67fc..e1c07ecfe604de8012715c25a773c2a66fed7bb7 100644 (file)
@@ -1,12 +1,14 @@
 from configparser import ConfigParser
 from configparser import ConfigParser
-from csv import DictReader
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
+from logging import getLogger
+from logging.config import fileConfig
 from pathlib import Path
 
 import time
 import calendar
 
 from pathlib import Path
 
 import time
 import calendar
 
-CSV_FILE = Path.cwd() / 'config' / 'features' / 'ephemeris_features.csv'
+fileConfig((Path.cwd() / 'config') / 'logging.cfg')
+logger = getLogger()
 
 class Ephemeris:
 
 
 class Ephemeris:
 
@@ -19,10 +21,9 @@ class Ephemeris:
         self._config.read(config_file)
 
         # Collecting ephemeris features
         self._config.read(config_file)
 
         # Collecting ephemeris features
-        with open(CSV_FILE, "r") as f:
-            reader = DictReader(f, delimiter=',')
-            self._features = [row['name'] for row in reader
-                              if self._config['FEATURES'].getboolean(row['name'])]
+        self._features = [section for section in self._config
+                              if self._config[section].getboolean('numerical')
+                              or self._config[section].getboolean('categorical')]
 
         self._dated_features = {}
 
 
         self._dated_features = {}
 
@@ -45,10 +46,10 @@ class Ephemeris:
         self._end = x
 
 
         self._end = x
 
 
-
     @property
     def dated_features(self):
         if self._dated_features == {}:
     @property
     def dated_features(self):
         if self._dated_features == {}:
+            logger.info("Adding ephemeris features")
             date = self._start
             while date <= self._end:
                 dict_hour = {}
             date = self._start
             while date <= self._end:
                 dict_hour = {}