mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-04 14:47:49 +00:00
9d47ee942d
* 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
30 lines
972 B
Python
30 lines
972 B
Python
from __future__ import annotations
|
|
import numpy as np
|
|
from .base import Model
|
|
from sklearn.base import BaseEstimator, ClassifierMixin
|
|
|
|
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.
|
|
'''
|
|
|
|
data_transformation = 'original'
|
|
only_column = 'mom'
|
|
predict_window_size = 'single_timestamp'
|
|
|
|
def __init__(self, allow_short: bool) -> None:
|
|
super().__init__()
|
|
self.allow_short = allow_short
|
|
|
|
def fit(self, X: np.ndarray, y: np.ndarray) -> None:
|
|
# This is a static model, it can' learn anything
|
|
pass
|
|
|
|
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 np.array(prediction)
|
|
|
|
def predict_proba(self, X) -> np.ndarray:
|
|
return np.array([])
|