mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-05 23:27:49 +00:00
ee35332f58
* feat: Added base functions for Neural Net. * feat: Added function to handle Neural Nets. * fix: Fixed fit loop * feat: Neural Net trains now, need to test it. * feat: Prediction now works on the neural net. * fix: Put back config and run_pipeline.py * fix: Took out import from run_pipeline. * fix(Models): added get_name(), adjusted pytorch model output size * fix(Tests): fixed tests Co-authored-by: Mark Aron Szulyovszky <mark.szulyovszky@gmail.com>
36 lines
1.1 KiB
Python
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.
|
|
'''
|
|
|
|
data_scaling = 'unscaled'
|
|
only_column = 'mom'
|
|
feature_selection = 'off'
|
|
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 |