Пример #1
0
def model(all_x, all_x_dates, all_y, all_y_dates):
    values = all_x[-(look_back_years + 1):-1]
    dates = all_x_dates[-(look_back_years + 1):-1]
    ind1 = Preprocessor(dates, values).slope()
    values = all_y[-(look_back_years + 1):-1]
    dates = all_y_dates[-(look_back_years + 1):-1]
    ind2 = Preprocessor(dates, values).slope()
    return (ind1 < 0.20 and ind2 < 0.11)
Пример #2
0
 def __init__(self,
              look_back_years,
              cache_enabled=False,
              cache_host="localhost",
              cache_port=27017):
     '''
     Constructor
     '''
     self.t_loc = conf.sample_selection_file
     self.extractor = Extractor()
     self.cache_enabled = cache_enabled
     if self.cache_enabled:
         self.extractor.enable_cache(cache_host, cache_port)
     self.look_back_years = look_back_years
     self.preprocessor = Preprocessor()
     # sample set placeholders
     self.crisis_samples = []
     self.normal_samples = []
     self.metadata = Metadata(conf, look_back_years)
Пример #3
0
 def apply_slope(self, *args):
     """
     @param *args:
     look_back_year - integer stating how many
     values back to look in the slope
     """
     #TODO: move this method to preprocessor & get rid of the foc dependency
     look_back_years = args[0]
     new_values = []
     past_values = []
     past_dates = []
     for i in range(len(self.dates)):
         past_dates.append(self.dates[i])
         past_values.append(self.values[i])
         if i >= look_back_years - 1:
             new_values.append(
                 Preprocessor(past_dates, past_values).slope())
             past_dates.pop(0)
             past_values.pop(0)
     try:
         [self.dates.pop(0) for i in range(look_back_years - 1)]
     except:
         pass
     self.values = new_values