mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-28 03:08:01 +00:00
567cd5e9f0
* refactor(Evaluate): print out accuracy, f1, etc. for the final & meta predictions, separated out evaluation step * fix(Linter): ran * fix(Tests): syntax change * fix(Inference): runs now again * fix(Linter): ran
37 lines
929 B
Python
37 lines
929 B
Python
from data_loader.types import ReturnSeries, ForwardReturnSeries
|
|
from abc import ABC, abstractmethod
|
|
import pandas as pd
|
|
import pandera as pa
|
|
from pandera.typing import DataFrame, Series
|
|
from typing import Callable
|
|
|
|
|
|
class EventFilter(ABC):
|
|
@abstractmethod
|
|
def get_event_start_times(self, returns: ReturnSeries) -> pd.DatetimeIndex:
|
|
raise NotImplementedError
|
|
|
|
|
|
class EventSchema(pa.SchemaModel):
|
|
start: Series[pd.Timestamp]
|
|
end: Series[pd.Timestamp]
|
|
label: Series[int]
|
|
returns: Series[float]
|
|
|
|
|
|
EventsDataFrame = DataFrame[EventSchema]
|
|
|
|
|
|
class EventLabeller(ABC):
|
|
@abstractmethod
|
|
def label_events(
|
|
self, event_start_times: pd.DatetimeIndex, returns: ReturnSeries
|
|
) -> EventsDataFrame:
|
|
raise NotImplementedError
|
|
|
|
def get_labels(self) -> list[int]:
|
|
raise NotImplementedError
|
|
|
|
def get_discretize_function(self) -> Callable:
|
|
raise NotImplementedError
|