true_test_indices
timecave.utils.true_test_indices(test_ind, model_order)
Modify an array of validation indices for modelling purposes.
This function modifies the array of validation indices yielded by a splitter so that it includes the previous time steps that should be passed as inputs to the model in order for it to predict the series' next value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_ind |
ndarray
|
Array of test (validation, really) indices yielded by a splitter. |
required |
model_order |
int
|
The number of previous time steps the model needs to take as input in order to predict the series' value at the next time step. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of validation indices including the time steps required by the model to predict the series' value at the first validation index. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
ValueError
|
If |
Examples:
>>> from timecave.utils import true_test_indices
>>> test_indices = np.array([8, 9, 10]);
>>> model_order = 2;
>>> true_test_indices(test_indices, model_order)
array([ 6, 7, 8, 9, 10])
The order of a model must be an integer value:
>>> true_test_indices(test_indices, 0.5)
Traceback (most recent call last):
...
TypeError: 'model_order' should be an integer.
The order of a model must not be a negative value:
>>> true_test_indices(test_indices, -1)
Traceback (most recent call last):
...
ValueError: 'model_order' should be positive.
This function assumes training and validation are done sequentially. Therefore, an exception will be thrown if the amount of samples preceding the validation set is smaller than the order of the model:
>>> true_test_indices(test_indices, 10)
Traceback (most recent call last):
...
ValueError: 'model_order' should be smaller than the amount of samples in the training set.