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

Private GIT Repository
Reducing the computation time and adding holidays features
[predictops.git] / predictops / engine.py
index 2ec62df816001a0877883ffae6470df8c67ba936..e7bbf1c5aa58221da7a8aaa71788cf0339258cbc 100644 (file)
@@ -5,8 +5,12 @@ from logging.config import fileConfig
 from pathlib import Path
 from shutil import rmtree
 
-from predictops.source.ephemeris import Ephemeris
-from predictops.source.meteofrance import MeteoFrance
+from .source.ephemeris import Ephemeris
+from .source.holidays import Holidays
+from .source.meteofrance import MeteoFrance
+from .learn.learning import Learning
+from .learn.preprocessing import Preprocessing
+from .target.target import Target
 
 fileConfig((Path.cwd() / 'config') / 'logging.cfg')
 logger = getLogger()
@@ -26,7 +30,6 @@ class Engine:
                                    self._config['DATETIME'].getfloat('hourStep'))
 
         self._X = {}
-        self._Y = {}
 
 
 
@@ -64,6 +67,35 @@ class Engine:
             for date in dated_features:
                 self._X.setdefault(date,{}).update(dated_features[date])
 
+        if self._config['FEATURES'].getboolean('holidays'):
+            holidays = Holidays(config_file =
+                                eval(self._config['FEATURE_CONFIG']['holidays']))
+
+            holidays.start = self._start
+            holidays.end = self._end
+
+            dated_features = holidays.dated_features
+            for date in dated_features:
+                self._X.setdefault(date,{}).update(dated_features[date])
+
+
+    def add_target(self):
+        self._target = Target(config_file = eval(self._config['TARGET']['config']),
+                              start = self._start, end = self._end,
+                              timestep = self._timestep)
+
+
+    def add_preprocessing(self):
+        self._preproc = Preprocessing(config_file = self._config,
+                                      dict_features = self.X,
+                                      dict_target = self.y)
+
+
+    def learn(self):
+        history = self._config['HISTORY_KNOWLEDGE'].getint('nb_lines')
+        self._learner = Learning(config_file = eval(self._config['LEARNER']['config']),
+                                 X = self._preproc.dataframe, y = list(self.y.values())[history:])
+
 
     @property
     def X(self):
@@ -71,4 +103,13 @@ class Engine:
 
     @X.setter
     def X(self, x):
-        self._X = x
\ No newline at end of file
+        self._X = x
+
+
+    @property
+    def y(self):
+        return self._target.y
+
+    @y.setter
+    def end(self, y):
+        self._target.y = y