pub fn time_ordered(periods: &[i64], n_test: usize) -> Result<Vec<Split>>Expand description
Time-ordered splits for forecasting: for each of the last n_test
distinct periods t, train on rows with period before t and test on
rows with period t. For a reserving triangle, the period is the
calendar diagonal (origin + development), and this is the diagonal
backtest of docs/design/models.md.
use prospicio_models::resample::time_ordered;
// Diagonals of a 3 × 3 triangle's cells.
let diag = [0, 1, 2, 1, 2, 2];
let splits = time_ordered(&diag, 1).unwrap();
assert_eq!(splits[0].test, [2, 4, 5]);
assert_eq!(splits[0].train, [0, 1, 3]);