Files
drift/training/ensemble.py
T
Mark Aron Szulyovszky f85ee6bb9c fix(MetaLabeling): previously misinterpreted meta-labeling, now also multiplying base model's prediction with the meta model's prediction (#193)
* fix(MetaLabeling): previously misinterpreted meta-labeling, now also multiplying base model's prediction with the meta model's prediction

* fix(Evaluate): print results

* fix(Evaluate): make sure we have numerical stability in returns

* fix(Inference): only output and print stats in training mode

* fix(Evaluate): don't add miniscule amount to result
2022-02-01 13:09:00 +01:00

27 lines
938 B
Python

from .types import WeightsSeries, EnsembleOutcome
import pandas as pd
from utils.evaluate import evaluate_predictions
from data_loader.types import ForwardReturnSeries, ySeries
from typing import Literal
def ensemble_weights(
input_weights: list[WeightsSeries],
forward_returns: ForwardReturnSeries,
y: ySeries,
no_of_classes: Literal['two', 'three-balanced', 'three-imbalanced'],
output_stats: bool
) -> EnsembleOutcome:
weights = pd.concat(input_weights, axis=1).mean(axis=1)
if output_stats:
stats = evaluate_predictions(
forward_returns = forward_returns,
y_pred = weights,
y_true = y,
no_of_classes = no_of_classes,
discretize = True,
)
print(stats)
else:
stats = None
return EnsembleOutcome(weights, stats)