Exemple #1
0
 def __init__(self, global_hyperparams, hp_grid=None, n=1):
     BaseAlgo.__init__(self, global_hyperparams, hp_grid)
     self.name = 'Momentum'
     self.algo_type = 'TA'
     self.n = n
     if global_hyperparams['output_type'] == 'R':
         raise AlgoError('You cannot call MOM as a regressor')
Exemple #2
0
 def __init__(self, global_hyperparams, hp_grid=None, **hyperparams):
     BaseAlgo.__init__(self, global_hyperparams, hp_grid)
     if global_hyperparams['output_type'] == 'C':
         self.model = RandomForestClassifier()
         self.name = 'Random Forest Classifier'
     else:
         self.model = RandomForestRegressor()
         self.name = 'Random Forest Regressor'
     self.algo_type = 'ML'
     self.set_hyperparams(**hyperparams)
 def __init__(self, env, iterations, lamb, monte_carlo, save_mse_vals=False):
     BaseAlgo.__init__(self, env, iterations)
     self.gamma = 0.8
     self.lamb = lamb
     self.mc = monte_carlo
     if save_mse_vals: 
         self.save_mse_vals = True
         self.mse_vals = []
     else:
         self.save_mse_vals = False
 def __init__(self, global_hyperparams, hp_grid=None, **hyperparams):
     BaseAlgo.__init__(self, global_hyperparams, hp_grid)
     if global_hyperparams['output_type'] == 'C':
         self.model = MLPClassifier()
         self.name = 'Multi Layer Perceptron Classifier'
     else:
         self.model = MLPRegressor()
         self.name = 'Multi Layer Perception Regressor'
     self.algo_type = 'ML'
     self.set_hyperparams(**hyperparams)
 def __init__(self, global_hyperparams, hp_grid=None, ob=80, os=20, w=None):
     BaseAlgo.__init__(self, global_hyperparams, hp_grid)
     self.name = 'Relative Strength Index'
     self.algo_type = 'TA'
     self.ob = ob  # The overbought level for the RSI
     self.os = os  # The oversold level for the RSI
     self.w = w if w is not None else global_hyperparams[
         'rolling_window_size']  # The window size of the RS
     if global_hyperparams['output_type'] == 'R':
         raise AlgoError('You cannot call RSI as a regressor')
Exemple #6
0
 def __init__(self,
              global_hyperparams,
              hp_grid=None,
              mean_type='arithmetic',
              window_size=None):
     BaseAlgo.__init__(
         self, global_hyperparams, hp_grid
     )  # allow to run the init of the BaseAlgo class, and define all default arguments
     self.name = 'Historical Mean'
     self.algo_type = 'ML'  # By convention
     self.mean_type = mean_type
     if window_size is not None:  # It is possible to define a window size different from the global rolling window size, but it has to be less or equal
         self.window_size = window_size
     else:
         self.window_size = self.global_hyperparams['rolling_window_size']
Exemple #7
0
 def __init__(self,
              global_hyperparams,
              hp_grid=None,
              stw=50,
              ltw=200,
              a=None,
              b=None,
              c=None):
     BaseAlgo.__init__(self, global_hyperparams, hp_grid)
     self.algo_type = 'TA'
     self.name = 'Golden Dead Cross'
     self.a = a  # a>=0, it controls the min ratio of mz/z, a=0: always accept
     self.b = b  # b>=0, it controls the impact of the criteria on mz, b=0: always accept
     self.c = c  # c>=0, it controls the max values of z and the min value of mz
     self.stw = stw
     self.ltw = ltw
     self.mz = None  # absolute value of the last peak
     if global_hyperparams['output_type'] == 'R':
         raise AlgoError('You cannot call GDC as a regressor')
Exemple #8
0
class TestEasy21(unittest.TestCase):
    def setUp(self):
        self.algo1 = BaseAlgo(None, 5, (2, 3))
        self.algo2 = BaseAlgo(None, (5, 2), (3, ))
        self.algo3 = BaseAlgo(None, (5, 2), (3, 2, 3))

    def test_get_action(self):

        state = tuple([0] * len(self.algo1.state_space_shape))
        self.assertEqual(len(self.algo1.get_action(state)),
                         len(self.algo1.action_space_shape))

        state = tuple([0] * len(self.algo2.state_space_shape))
        self.assertEqual(len(self.algo2.get_action(state)),
                         len(self.algo2.action_space_shape))

        state = tuple([0] * len(self.algo3.state_space_shape))
        self.assertEqual(len(self.algo3.get_action(state)),
                         len(self.algo3.action_space_shape))

    def test_get_V(self):
        pass
Exemple #9
0
 def __init__(self,
              global_hyperparams,
              hp_grid=None,
              regularization=None,
              **hyperparams):
     BaseAlgo.__init__(
         self, global_hyperparams, hp_grid, **hyperparams
     )  # allow to run the init of the BaseAlgo class, and define all default arguments
     if regularization is None:
         self.model = LinearRegression()
         self.name = 'Linear Regression'
     elif regularization == 'Lasso':
         self.model = Lasso(normalize=True)
         self.name = 'Lasso'
     elif regularization == 'Ridge':
         self.model = Ridge(normalize=True)
         self.name = 'Ridge'
     elif regularization == 'ElasticNet':
         self.model = ElasticNet(normalize=True)
         self.name = 'Elastic Net'
     self.algo_type = 'ML'
     self.set_hyperparams(
         **hyperparams
     )  # Do not forget to fix hyperparams after defining the model
Exemple #10
0
 def __init__(self, global_hyperparams, weights):
     BaseAlgo.__init__(self, global_hyperparams)
     self.algo_type = 'BA'
     self.weights = weights
     self.name = 'Core Manual Weighting'
Exemple #11
0
 def __init__(self, global_hyperparams, scoring):
     BaseAlgo.__init__(self, global_hyperparams)
     self.algo_type = 'BA'
     self.scoring = scoring
     self.index_best = None
     self.name = 'Best In Sample'
Exemple #12
0
 def setUp(self):
     self.algo1 = BaseAlgo(None, 5, (2, 3))
     self.algo2 = BaseAlgo(None, (5, 2), (3, ))
     self.algo3 = BaseAlgo(None, (5, 2), (3, 2, 3))