mizarlabs.transformers.sample_weights package

Module contents

class mizarlabs.transformers.sample_weights.SampleWeightsByReturns(event_end_time_column_name: str = 'event_end_time', close_column_name: str = 'close')[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin

Calculate the sample weights by absolute returns.

See page 69 of Advances in Financial Machine Learning by Marcos Lopez de Prado for additional information.

Parameters
  • event_end_time_column_name (str, optional) – The column name of the event end time

  • close_column_name (str, optional) – The column name of the close price

transform(X: pandas.core.frame.DataFrame)pandas.core.series.Series[source]
class mizarlabs.transformers.sample_weights.SampleWeightsByTimeDecay(minimum_decay_weight: float, event_end_time_column_name: str = 'event_end_time')[source]

Bases: mizarlabs.transformers.sampling.average_uniqueness.AverageUniqueness

Calculate the sample weights by time decay.

See page 70 of Advances in Financial Machine Learning by Marcos Lopez de Prado for additional information.

Parameters
  • event_end_time_column_name (str, optional) – The column name of the event end time

  • minimum_decay_weight (float) –

    Is the minimum desired value in the decay weights - minimum_decay_weight = 1 means there is no time decay - 0 < minimum_decay_weight < 1 means that weights decay linearly over

    time, but every observation still receives a strictly positive weight, regadless of how old

    • minimum_decay_weight = 0 means that weights converge linearly to zero, as they become older

    • minimum_decay_weight < 0 means that the oldest portion of the observations receive zero weight (i.e they are erased from memory)

transform(X: pandas.core.frame.DataFrame)pandas.core.series.Series[source]