Files
drift/models/momentum.py
T
Mark Aron SzulyovszkyandGitHub 6b26643ece feat(Transformations): replaced feature selection pre-processing step with online version (with cache) (#170)
* feat(Transformations): removed feature-selection pre-processing step completely

* fix(Core): removed unnecessary `original_X`

* fix(Transformations): use the X_expanding_window to transform subsequent data

* fix(RFE): should check for model correctly

* fix(Config): only re-train the model every 40 timestamp

* fix(MetaLabeling): pass in the correct X to meta-labeling step

* fix(Transformation): PCA should at least keep as many features as sliding_window_size

* feat(Transformations): cache transformations across the same asset

* fix(Tests): missing preloaded_transformations arg

* chore(Config): got rid of unnecessary 'classification_models' and 'regression_models' dictionary keys
2022-01-17 11:43:51 +01:00

36 lines
1.1 KiB
Python

from __future__ import annotations
from models.base import Model
import numpy as np
class StaticMomentumModel(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:
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) -> tuple[float, 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 get_name(self) -> str:
return 'static_mom'
def initialize_network(self, input_dim:int, output_dim:int):
pass