예제 #1
0
    def __init__(self,
                 feature_exprs,
                 model,
                 encoder=None,
                 window_sizes={
                     '5s': 50,
                     '50s': 500
                 },
                 raw_features={
                     'bid': online_features.best_bid,
                     'offer': online_features.best_offer
                 },
                 min_frames_before_prediction=2):

        self.raw_features = raw_features
        self.window_sizes = window_sizes
        self.agg = mk_agg(raw_features, window_sizes)

        self.feature_exprs = feature_exprs
        # a list of expr_lang functions which map a symbol environment to the
        # evaluated feature expression
        self.compiled_features = [
            expr_lang.compile_expr(expr) for expr in feature_exprs
        ]

        # the set of symbols that need to be present in an environment so that
        # all the feature expressions can be evaluated
        self.feature_symbols = expr_lang.symbol_set(feature_exprs)
        self.encoder = encoder
        self.model = model
        self.min_frames_before_prediction = min_frames_before_prediction
        self.longest_window = np.max(window_sizes.values())
 def __init__(self, 
         feature_exprs, 
         model,
         encoder=None,
         window_sizes={'5s': 50, '50s': 500}, 
         raw_features={'bid': online_features.best_bid, 'offer': online_features.best_offer}, 
         min_frames_before_prediction=2):
     
     self.raw_features = raw_features
     self.window_sizes = window_sizes 
     self.agg = mk_agg(raw_features, window_sizes) 
     
     self.feature_exprs = feature_exprs 
     # a list of expr_lang functions which map a symbol environment to the
     # evaluated feature expression 
     self.compiled_features = [expr_lang.compile_expr(expr) for expr in feature_exprs]
     
     # the set of symbols that need to be present in an environment so that 
     # all the feature expressions can be evaluated 
     self.feature_symbols = expr_lang.symbol_set(feature_exprs)
     self.encoder = encoder 
     self.model = model 
     self.min_frames_before_prediction = min_frames_before_prediction
     self.longest_window = np.max(window_sizes.values())
예제 #3
0
def test_symbol_set():
    s = '(log2 x) + (log2 y) + 0.5 * 3 - x/y/z'
    symbols = expr_lang.symbol_set(s)
    expected = set(['x', 'y', 'x/y/z'])
    print "Expected:", expected, "Result:", symbols 
    assert symbols == expected