Skip to content

CINNForecaster

CINNForecaster

class CINNForecaster(n_coupling_layers=10, hidden_dim_size=32, sample_dim=24, batch_size=64, encoded_cond_size=64, lr=0.0005, weight_decay=1e-05, sp_list=None, fourier_terms_list=None, window_size=720, num_epochs=50, verbose=False, f_statistic=None, init_param_f_statistic=None, deterministic=False, lag_feature='mean', patience=5, delta=0.0001, val_split=0.2)[source]

Conditional Invertible Neural Network (cINN) Forecaster.

This forecaster uses a cINN to forecast the time series. The cINN learns a bijective mapping between the time series and a normal distributed latent space. The latent space is then sampled and transformed back to the time series space. The cINN is conditioned on statistical and fourier term based features of the time series and the provided exogenous features. This forecaster was applied in the BigDEAL challenge by the KIT-IAI team and is described in [1]_.

Parameters:
n_coupling_layersint, optional (default=15)

Number of coupling layers in the cINN.

hidden_dim_sizeint, optional (default=64)

Number of hidden units in the subnet.

sample_dimint, optional (default=24)

Dimension of the samples that the cINN is creating

batch_sizeint, optional (default=64)

Batch size for the training.

encoded_cond_sizeint, optional (default=64)

Dimension of the encoded condition.

lrfloat, optional (default=5e-4)

Learning rate for the Adam optimizer.

weight_decayfloat, optional (default=1e-5)

Weight decay for the Adam optimizer.

sp_listlist of int, optional (default=[24])

List of seasonal periods to use for the Fourier features.

fourier_terms_listlist of int, optional (default=[1, 1])

List of number of Fourier terms to use for the Fourier features.

window_sizeint, optional (default=24*30)

Window size for calculating the rolling statistics using the WindowSummarizer.

lag_feature: str, optional (default=”mean”)

The rolling statistic that the WindowSummarizer should calculate.

num_epochsint, optional (default=50)

Number of epochs to train the cINN.

verbosebool, optional (default=False)

Whether to print the training progress.

f_statisticfunction, optional (default=default_sine)

Function to use for forecasting the rolling statistic.

init_param_f_statisticlist of float, optional (default=[1, 0, 0, 10, 1, 1])

Initial parameters for the f_statistic function.

deterministicbool, optional (default=False)

Whether to use a deterministic or stochastic cINN. Note, deterministic should only used for testing.

patienceint, optional (default=5)

Number of epochs to wait before stopping the training.

deltafloat, optional (default=0.0001)

Minimum change in the validation loss to consider as an improvement.

val_splitfloat, optional (default=0.2)

Fraction of the data to use for validation.

Attributes:
cutoff

Cut-off = “present time” state of forecaster.

fh

Forecasting horizon that was passed.

is_fitted

Whether fit has been called.

state

State of the estimator.

References

..[1] Heidrich, B., Hertel, M., Neumann, O., Hagenmeyer, V., & Mikut, R.

(2023). Using conditional Invertible Neural Networks to Perform Mid- Term Peak Load Forecasting. IET Smart Grid, Under Review

Examples

>>> from sktime.forecasting.cinn import CINNForecaster
>>> from sktime.datasets import load_airline
>>> y = load_airline()
>>> model = CINNForecaster(window_size=100)
>>> model.fit(y)
CINNForecaster(...)
>>> y_pred = model.predict(fh=[1,2,3])

Methods

build_pytorch_pred_dataloader(y, fh)

Build PyTorch DataLoader for prediction.

build_pytorch_train_dataloader(y)

Build PyTorch DataLoader for training.

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(y[, X, fh])

Fit forecaster to training data.

fit_predict(y[, X, fh, X_pred])

Fit and forecast time series at future horizon.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_pretrained_params([deep])

Get pretrained parameters of this estimator.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator.

get_y_true(y)

Get y_true values for validation.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(path)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

predict([fh, X])

Forecast time series at future horizon.

predict_interval([fh, X, coverage])

Compute/return prediction interval forecasts.

predict_proba([fh, X, marginal])

Compute/return fully probabilistic forecasts.

predict_quantiles([fh, X, alpha])

Compute/return quantile forecasts.

predict_residuals([y, X])

Return residuals of time series forecasts.

predict_var([fh, X, cov])

Compute/return variance forecasts.

pretrain(y[, X, fh])

Pre-train forecaster on panel (global) data.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

score(y[, X, fh])

Scores forecast against ground truth, using MAPE (non-symmetric).

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

update(y[, X, update_params])

Update cutoff value and, optionally, fitted parameters.

update_predict(y[, cv, X, update_params, ...])

Make predictions and update model iteratively over the test set.

update_predict_single([y, fh, X, update_params])

Update model with new data and make forecasts.