paddlets.models.base
- class Trainable[source]
Bases:
objectBase class for all trainable classes.
Any classes need to be fitted (e.g.
BaseModel,Pipeline, etc.) may inherit from this base class and optionally implementfit()method.
- class BaseModel(in_chunk_len: int, out_chunk_len: int, skip_chunk_len: int)[source]
Bases:
TrainableBase class for all machine learning and deep learning models.
- Parameters
in_chunk_len (int) – The size of the loopback window, i.e., the number of time steps feed to the model.
out_chunk_len (int) – The size of the forecasting horizon, i.e., the number of time steps output by the model.
skip_chunk_len (int) – Optional, the number of time steps between in_chunk and out_chunk for a single sample. The skip chunk is neither used as a feature (i.e. X) nor a label (i.e. Y) for a single sample. By default, it will NOT skip any time steps.
- _in_chunk_len
The size of the loopback window, i.e., the number of time steps feed to the model.
- Type
int
- _out_chunk_len
The size of the forecasting horizon, i.e., the number of time steps output by the model.
- Type
int
- _skip_chunk_len
The length of time series chunk between past target and future target for a single sample. The skip chunk are neither used as feature (i.e. X) nor label (i.e. Y) for a single sample.
- Type
int
- abstract fit(train_data: TSDataset, valid_data: Optional[TSDataset] = None)[source]
Fit a BaseModel instance.
Any non-abstract classes inherited from this class should implement this method.
- abstract predict(data: TSDataset) TSDataset[source]
Make prediction.
Any non-abstract classes inherited from this class should implement this method.
- abstract save(path: str) None[source]
Saves a BaseModel instance to a disk file.
Any non-abstract classes inherited from this class should implement this method.
- Parameters
path (str) – A path string containing a model file name.
- abstract static load(path: str) BaseModel[source]
Loads a
BaseModelinstance from a file.Any non-abstract classes inherited from this class should implement this method.
- Parameters
path (str) – A path string containing a model file name.
- Returns
A loaded model.
- Return type
- recursive_predict(tsdataset: TSDataset, predict_length: int) TSDataset[source]
Apply self.predict method iteratively for multi-step time series forecasting, the predicted results from the current call will be appended to the TSDataset object and will appear in the loopback window for next call. Note that each call of self.predict will return a result of length out_chunk_len, so it will be called ceiling(predict_length/out_chunk_len) times to meet the required length.