Definition
Bailey, Borwein, López de Prado and Zhu compute it by combinatorially symmetric cross-validation (CSCV). The performance of N configurations over T periods is cut into S blocks of time. For every way of choosing half of the blocks as in-sample, the best configuration in sample is found and its rank among the N is read on the other half.
PBO = share of splits where the in-sample winner ranks below the median out of sample
A PBO near 0 means the winner in sample stays near the top out of sample. A PBO of one half or more means being best in sample says nothing about the rest: the search is overfitted.
Worked example
The procedure is run on 50 configurations of pure noise, then on the same set where one configuration has a real edge, then on only 5 noise configurations with several random draws.
import numpy as np
from itertools import combinations
def pbo(returns, S=8):
T, N = returns.shape
blocks = np.array_split(np.arange(T), S)
below = []
for chosen in combinations(range(S), S // 2):
ins = np.concatenate([blocks[i] for i in chosen])
oos = np.concatenate([blocks[i] for i in range(S) if i not in chosen])
sharpe = lambda idx: returns[idx].mean(0) / returns[idx].std(0)
winner = int(np.argmax(sharpe(ins)))
rank = (sharpe(oos) < sharpe(oos)[winner]).mean() # 1 = best out of sample
below.append(rank < 0.5)
return float(np.mean(below))
rng = np.random.default_rng(6)
noise = rng.normal(0, 0.01, (1000, 50))
print(f"50 configurations, all noise: PBO = {pbo(noise):.2f}")
edge = noise.copy(); edge[:, 0] += 0.002
print(f"50 configurations, one with an edge: PBO = {pbo(edge):.2f}")
few = [pbo(rng.normal(0, 0.01, (1000, 5))) for _ in range(8)]
print("5 configurations, all noise, 8 draws:", np.round(few, 2))Output, produced by running the code above when this page was built:
50 configurations, all noise: PBO = 0.66 50 configurations, one with an edge: PBO = 0.14 5 configurations, all noise, 8 draws: [0.74 0.91 0.03 0.49 0.01 0.81 0.06 0.71]
With a real edge among the candidates the PBO is low. With noise only it is high, here above one half. With five configurations, the same situation gives values scattered from near 0 to near 1 from one draw to the next.
Where it misleads
- The out-of-sample rank of a winner among 5 candidates takes few possible values. The PBO of a small set is mostly noise, as the last line shows.
- PBO describes the selection process, not the winner. A low PBO does not say the winning configuration is profitable, only that the ranking persists.
- All configurations tried must be in the matrix. Leaving out the abandoned ones lowers the PBO artificially.
- Blocks of time are treated as exchangeable. With strong trends or regimes they are not, and the splits where training follows testing mix past and future.
In our work
We use PBO on large populations of candidates only. On one of our own searches a PBO of 0.467 computed on 5 configurations turned out to be mostly noise, and we now state the number of candidates next to the figure.
Service: machine learning and model validation Research note: detecting overfitting
References
- Bailey, D. H., Borwein, J., López de Prado, M., Zhu, Q. J. (2017). The probability of backtest overfitting. Journal of Computational Finance, 20(4), 39-69. doi:10.21314/JCF.2016.322
- Bailey, D. H., López de Prado, M. (2014). The deflated Sharpe ratio: correcting for selection bias, backtest overfitting, and non-normality. Journal of Portfolio Management, 40(5), 94-107. doi:10.3905/jpm.2014.40.5.094
- López de Prado, M. (2018). Advances in financial machine learning. Wiley, Hoboken.