3 changed files with 34 additions and 16 deletions
@ -0,0 +1,19 @@ |
|||
import pandas as pd |
|||
|
|||
|
|||
from ..interfaces import Predictor |
|||
|
|||
|
|||
class Derivate(Predictor): |
|||
"""Derivate.""" |
|||
|
|||
def __init__(self, coef: float = 1) -> None: |
|||
self.coef = coef |
|||
|
|||
def predict(self, data: pd.DataFrame) -> dict: |
|||
"""Predict from others predictors.""" |
|||
derivates = data.diff().iloc[-10:] |
|||
maxs = derivates.abs().max() |
|||
last = self.coef*derivates.iloc[-1] |
|||
res = (last/maxs).fillna(0).to_dict() |
|||
return res |
Loading…
Reference in new issue