Sample Weights


MlFinLab supports two methods of applying sample weights. The first is weighting an observation based on its given return as well as average uniqueness. The second is weighting an observation based on a time decay.


Implementations

By Returns and Average Uniqueness

The following function utilizes a samples average uniqueness and its return to compute sample weights:

Code implementation demo

Example

This function can be utilized as shown below assuming we have already found our barrier events

Code example demo

By Time Decay

The following function assigns sample weights using a time decay factor

Code implementation demo

Example

This function can be utilized as shown below assuming we have already found our barrier events

Code example demo

Research Notebook

The following research notebooks can be used to better understand the previously discussed sampling methods

Note

This is the same notebook as seen in the Sample Uniqueness docs.

Notebook demo