Skip to content

skfolio/skfolio-shuffled-returns-split

Pack Severity Fix Versions
skfolio warning unsafe, with xpd check --fix --unsafe-fixes skfolio 1.14.4+

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.

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.

See all rules in the skfolio pack.