train_test_split¶
Defined in fynance.data
- train_test_split(n, test_size, gap=0)[source]
Time-ordered train/test index split.
- Parameters:
- nint
Number of observations.
- test_sizefloat or int
Trailing test set size. A value strictly inside
(0, 1)is read as a fraction ofn(e.g.0.2->round(0.2 * n)); any other value – including the bounds0.0and1.0– is read as an absolute count (int(test_size)). In particular1.0means a single observation (count1), not the whole series, and0.0means an empty test set; pass a fraction strictly between the bounds to get a proportional split.- gapint
Embargo: observations dropped between train end and test start.
- Returns:
- (train_idx, test_idx)tuple of numpy.ndarray
test_idxis strictly aftertrain_idx(no leakage).