mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-07 08:07:49 +00:00
cc70d3f907
* feat(Selection): added prototype feature selection python script * feat(Utils): added some helpers for the future from Advances in Financial ML book * feat(Selection): added RFECV * feat(Selection): added configurable feature selection step into pipeline * feat(Config): added level_1 & level_2 default config, PCA before feature selection process starts * feat(Selection): added backup feature selector models if current one can't output feature importance, removed unnecessary array for level-2 models * fix(Training): deal with zero first value coming out of static models * feat(Sweep): added feature selection sweep * fix(Sweep): config problem * fix(Sweep): config * chore(Utils): removed unnecessary purged k-fold crossval class * feat(Config): added dimensionality_reduction as a separate flag * fix(Sweep): config updated * fix(Sweep): sweep name * chore(Config): updated level_2 config to the best performing configuation
28 lines
789 B
Python
28 lines
789 B
Python
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.
|
|
'''
|
|
|
|
data_scaling = 'unscaled'
|
|
only_column = 'mom'
|
|
feature_selection = 'off'
|
|
model_type = 'static'
|
|
|
|
def __init__(self, allow_short: bool) -> None:
|
|
super().__init__()
|
|
self.allow_short = allow_short
|
|
|
|
def fit(self, X, y, prev_model):
|
|
# This is a static model, it can' learn anything
|
|
pass
|
|
|
|
def predict(self, X):
|
|
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 clone(self):
|
|
return self |