Skip to content

skfolio/skfolio-shuffled-returns-split

Rule skfolio-shuffled-returns-split
Pack skfolio
Severity warning
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions skfolio 1.14.4 and later

A shuffled split can train a skfolio model on returns from after the dates used for testing.

train_test_split(returns)
train_test_split(returns, shuffle=False)

The rule follows data from prices_to_returns. For cross-validation, use WalkForward to keep training before testing. KFold can train on future data even when its shuffle option is off.

Use xpd check --fix --unsafe-fixes to set shuffle=False on train_test_split calls over asset returns. Replace shuffled cross-validation splitters with WalkForward by hand.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

Shuffling skfolio asset returns can train on future observations. In a 20-row split, training included row 19 and testing included row 0. Split in observation order.

Browse the other rules of the skfolio pack.