Split an array into train and test sets
This procedure splits an array into two sets along one dimension. The array can be of any rank, but the dimension along which to split must be specified. An optional index array can also be split. The size of the left and right splits can also be specified. The data can be shuffled before splitting.
Split a 2D array along one dimension
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(in), | dimension(:,:) | :: | data |
2D array to be split |
|
| real(kind=real32), | intent(in), | dimension(:) | :: | label |
1D array to be split |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:,:) | :: | left_data |
2D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:,:) | :: | right_data |
2D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:) | :: | left_label |
1D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:) | :: | right_label |
1D arrays to store the left and right splits |
|
| integer, | intent(in) | :: | dim |
Dimension along which to split |
||
| real(kind=real32), | intent(in), | optional | :: | left_size |
Size of the left and right splits |
|
| real(kind=real32), | intent(in), | optional | :: | right_size |
Size of the left and right splits |
|
| logical, | intent(in), | optional | :: | shuffle |
Shuffle the data before splitting |
|
| integer, | intent(in), | optional | :: | seed |
Random seed |
|
| integer, | intent(out), | optional, | dimension(size(data,dim)) | :: | split_list |
Index array |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in), | dimension(:,:,:) | :: | data |
3D array to be split |
|
| integer, | intent(in), | dimension(:) | :: | label |
1D array to be split |
|
| integer, | intent(out), | allocatable, dimension(:,:,:) | :: | left_data |
3D arrays to store the left and right splits |
|
| integer, | intent(out), | allocatable, dimension(:,:,:) | :: | right_data |
3D arrays to store the left and right splits |
|
| integer, | intent(out), | allocatable, dimension(:) | :: | left_label |
1D arrays to store the left and right splits |
|
| integer, | intent(out), | allocatable, dimension(:) | :: | right_label |
1D arrays to store the left and right splits |
|
| integer, | intent(in) | :: | dim |
Dimension along which to split |
||
| real(kind=real32), | intent(in), | optional | :: | left_size |
Size of the left and right splits |
|
| real(kind=real32), | intent(in), | optional | :: | right_size |
Size of the left and right splits |
|
| logical, | intent(in), | optional | :: | shuffle |
Shuffle the data before splitting |
|
| integer, | intent(in), | optional | :: | seed |
Random seed |
|
| integer, | intent(out), | optional, | dimension(size(data,dim)) | :: | split_list |
Index array |
Split a 3D array along one dimension
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in), | dimension(:,:,:) | :: | data |
3D array to be split |
|
| real(kind=real32), | intent(in), | dimension(:) | :: | label |
1D array to be split |
|
| integer, | intent(out), | allocatable, dimension(:,:,:) | :: | left_data |
3D arrays to store the left and right splits |
|
| integer, | intent(out), | allocatable, dimension(:,:,:) | :: | right_data |
3D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:) | :: | left_label |
1D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:) | :: | right_label |
1D arrays to store the left and right splits |
|
| integer, | intent(in) | :: | dim |
Dimension along which to split |
||
| real(kind=real32), | intent(in), | optional | :: | left_size |
Size of the left and right splits |
|
| real(kind=real32), | intent(in), | optional | :: | right_size |
Size of the left and right splits |
|
| logical, | intent(in), | optional | :: | shuffle |
Shuffle the data before splitting |
|
| integer, | intent(in), | optional | :: | seed |
Random seed |
|
| integer, | intent(out), | optional, | dimension(size(data,dim)) | :: | split_list |
Index array |
Split a 5D array along one dimension
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(in), | dimension(:,:,:,:,:) | :: | data |
5D array to be split |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:,:,:,:,:) | :: | left |
5D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:,:,:,:,:) | :: | right |
5D arrays to store the left and right splits |
|
| integer, | intent(in) | :: | dim |
Dimension along which to split |
||
| real(kind=real32), | intent(in), | optional | :: | left_size |
Size of the left and right splits |
|
| real(kind=real32), | intent(in), | optional | :: | right_size |
Size of the left and right splits |
|
| logical, | intent(in), | optional | :: | shuffle |
Shuffle the data before splitting |
|
| integer, | intent(in), | optional | :: | seed |
Random seed |
Split a 5D array along one dimension
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real32), | intent(in), | dimension(:,:,:,:,:) | :: | data |
5D array to be split |
|
| real(kind=real32), | intent(in), | dimension(:) | :: | label |
1D array to be split |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:,:,:,:,:) | :: | left_data |
5D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:,:,:,:,:) | :: | right_data |
5D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:) | :: | left_label |
1D arrays to store the left and right splits |
|
| real(kind=real32), | intent(out), | allocatable, dimension(:) | :: | right_label |
1D arrays to store the left and right splits |
|
| integer, | intent(in) | :: | dim |
Dimension along which to split |
||
| real(kind=real32), | intent(in), | optional | :: | left_size |
Size of the left and right splits |
|
| real(kind=real32), | intent(in), | optional | :: | right_size |
Size of the left and right splits |
|
| logical, | intent(in), | optional | :: | shuffle |
Shuffle the data before splitting |
|
| integer, | intent(in), | optional | :: | seed |
Random seed |
|
| integer, | intent(out), | optional, | dimension(size(data,dim)) | :: | split_list |
Index array |