Data¶
SONNDataset pairs features with targets for a PyTorch DataLoader; the
preprocessing module holds the helpers for splitting data by row position.
See Data.
SONNDataset
¶
Bases: Dataset
Map-style dataset of (x, target) rows, optionally one half of them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
(N, d) array or tensor
|
Input rows. |
required |
target
|
(N, ...) array or tensor, or None
|
Targets. None yields |
required |
split
|
(None, 0, 1)
|
None uses every row; 0 the even rows (0, 2, 4, ...); 1 the odd rows. The trainer uses the two halves as subsets A and B of one loader. |
None
|
preprocessing
¶
DataSetType
¶
Bases: IntEnum
Tag attached to each row of a dataset by set_split_types.
SequenceTypeSet
¶
Bases: IntEnum
How rows are assigned to train vs. validate.
sqRandom — random Bernoulli per row. sqMode1 — every 2nd row is validate. sqMode3_1 — every 3rd row is validate. sqMode4_1 — every 4th row is validate. sqMode2 — every 2nd row is train (inverse of sqMode1). sqMode3_2 — every 3rd row is train (inverse of sqMode3_1). sqMode4_2 — every 4th row is train (inverse of sqMode4_1).
train_preprocessing
¶
train_preprocessing(data_x: ndarray | DataFrame, data_y: ndarray | DataFrame | Series, feature_names: Sequence[str] | None) -> tuple[np.ndarray, np.ndarray]
process of train input data: transform to numpy matrix, transpose etc
predict_preprocessing
¶
process of predict input data: transform to numpy matrix, transpose etc
set_split_types
¶
Set seq_types array that will be used to divide data set to train and validate ones
split_dataset
¶
split_dataset(data_x: ndarray, data_y: ndarray, seq_type: SequenceTypeSet) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
Split train and validate data sets from input data set and target