label_concurrency¶
Defined in fynance.features.labels
- label_concurrency(t_in, t_out, T)[source]
Number of labels alive at each bar (inclusive
[t_in, t_out]spans).Warning
This describes labels, not a feature — see the module warning.
Used by
uniqueness_weights, and useful on its own to diagnose how muchtriple_barrierlabels overlap.- Parameters:
- t_in, t_outnp.ndarray[int, ndim=1]
Label start / end indices (the
t_in/t_outfields of atriple_barrieroutput), same length, with0 <= t_in <= t_out <= T - 1element-wise.- Tint
Number of bars in the underlying series.
- Returns:
- np.ndarray[np.int64, ndim=1]
Shape
(T,), the count of labels whose[t_in, t_out]span includes each bar.
- Raises:
- ValueError
If
t_inandt_outhave different lengths, or any span falls outside[0, T - 1]or hast_in > t_out.
See also
uniqueness_weights,triple_barrier
References
[1]Lopez de Prado, M. (2018). Advances in Financial Machine Learning. Wiley. Chapter 4, “Sample Weights”.
Examples
>>> import numpy as np >>> label_concurrency(np.array([0, 0, 2]), np.array([1, 1, 3]), T=4) array([2, 2, 1, 1])