feat(Project): use SKLearn models directly, removed custom ensembling, use 5 minute data, batch inference, numba cusum filter (#192)

* feat(Project): use 5 minute data, running training in parallel, sped up cusum filter by 10x with numba

* fix(WalkForward): inference mini-batch parallelization

* fix(WalkForward): don't use the parallel version of any of the functions

* feat(CI): download the data required

* fix(Project): 5min_crypto folder added

* fix(Evaluate): make sure we have numerical stability in returns

* feat(Models): use SKLearn models directly to enable composability

* feat(Inference): batched inference now working, added forecasting_horizon

* fix(Inference): works again

* fix(Inference)

* chore(Models): remove unused Ensemble model

* fix(Labeller): don't just forward shift returns, also take the sum of the data happened until then

* Update test.yml
This commit is contained in:
Mark Aron Szulyovszky
2022-02-17 16:36:35 +01:00
committed by GitHub
parent 5c94af8b01
commit 9d47ee942d
52 changed files with 470 additions and 628 deletions
+8 -12
View File
@@ -1,16 +1,15 @@
from __future__ import annotations
from models.base import Model
import numpy as np
from .base import Model
from sklearn.base import BaseEstimator, ClassifierMixin
class StaticMomentumModel(Model):
class StaticMomentumModel(BaseEstimator, ClassifierMixin, Model):
'''
Model that uses only one feature: momentum. It's positive if momentum is greater than 0, otherwise it's negative.
'''
method = 'classification'
data_transformation = 'original'
only_column = 'mom'
model_type = 'static'
predict_window_size = 'single_timestamp'
def __init__(self, allow_short: bool) -> None:
@@ -21,13 +20,10 @@ class StaticMomentumModel(Model):
# This is a static model, it can' learn anything
pass
def predict(self, X) -> tuple[float, np.ndarray]:
def predict(self, X) -> np.ndarray:
negative_class = -1.0 if self.allow_short == True else 0.0
prediction = 1.0 if X[-1][0] > 0 else negative_class
return (prediction, np.array([]))
def clone(self) -> StaticMomentumModel:
return self
def initialize_network(self, input_dim:int, output_dim:int):
pass
return np.array(prediction)
def predict_proba(self, X) -> np.ndarray:
return np.array([])