mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-28 11:17:47 +00:00
3eb3ea94e3
* refactor(Training): added InferenceResult & TrainedModel types * refactor(Pipeline): introduced TrainingOutcome, BetSizingWithMetaOutcome, etc. * fix(Pipeline): getting it to compile * refactor(WalkForward): separate preprocessing step * feat(Pipeline): separate out transformations processing step * refactor(Pipeline): use the Directional model terminology, put bet_sizing into pipeline instead of hiding it in a step * refactor(WalkForward): moved functions to separate folder * fix(WalkForward): use sparse array to store models, process transformations in parallel (lot faster) * fix(Tests): and evaluation * fix(Tests): for realz * fix(Inference): preloading everything now, renamed primary models to directional models * fix(BetSizing): was running transformations on the wrong data, oops * fix(BetSizing): concatenated on the wrong axis accidentally * fix(Reporting): able to use the new Stats type * fix(BetSizing): renamed int column names * fix(Portfolio): name the column properly * fix(Reporting): rename the correct Series, lol * fix(Inference): walk_forwad_inference() can deal with models not being aligned with the starting index * fix(WalkForward): accidentally using the wrong index * fix(WalkForward): use the correct indicies to fetch last model/transformations * fix(CI): changed the name of the results
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
import pandas as pd
|
|
from dataclasses import dataclass
|
|
from typing import Optional, Dict
|
|
|
|
PredictionsSeries = pd.Series
|
|
WeightsSeries = pd.Series
|
|
ProbabilitiesDataFrame = pd.DataFrame
|
|
Stats = Dict[str, float]
|
|
|
|
ModelOverTime = pd.Series
|
|
TransformationsOverTime = list[pd.Series]
|
|
|
|
|
|
@dataclass
|
|
class TrainingOutcome:
|
|
model_id: str
|
|
predictions: PredictionsSeries
|
|
probabilities: ProbabilitiesDataFrame
|
|
stats: Stats
|
|
model_over_time: ModelOverTime
|
|
|
|
@dataclass
|
|
class EnsembleOutcome:
|
|
weights: WeightsSeries
|
|
stats: Stats
|
|
|
|
@dataclass
|
|
class BetSizingWithMetaOutcome:
|
|
model_id: str
|
|
meta_training: list[TrainingOutcome]
|
|
meta_transformations: TransformationsOverTime
|
|
weights: WeightsSeries
|
|
stats: Stats
|
|
|
|
@dataclass
|
|
class DirectionalTrainingOutcome:
|
|
training: list[TrainingOutcome]
|
|
transformations: TransformationsOverTime
|
|
|
|
@dataclass
|
|
class PipelineOutcome:
|
|
directional_training: DirectionalTrainingOutcome
|
|
bet_sizing: list[BetSizingWithMetaOutcome]
|
|
ensemble: EnsembleOutcome
|
|
secondary_bet_sizing: Optional[BetSizingWithMetaOutcome]
|
|
|
|
def get_output_weights(self) -> WeightsSeries:
|
|
return self.secondary_bet_sizing.weights if self.secondary_bet_sizing else self.ensemble.weights
|
|
|
|
def get_output_stats(self) -> Stats:
|
|
return self.secondary_bet_sizing.stats if self.secondary_bet_sizing else self.ensemble.stats |