TCMFForecaster


Introduction

Analytics Zoo Zouwu TCMFForecaster provides an efficient way to forecast high dimensional time series.

TCMFForecaster is based on DeepGLO algorithm, which is a deep forecasting model which thinks globally and acts locally. You can refer to the deepglo paper for more details.

TCMFForecaster supports distributed training and inference. It is based on Orca PyTorch Estimator, which is an estimator to do PyTorch training/evaluation/prediction on Spark in a distributed fashion. Also you can choose to enable distributed training and inference or not.

Remarks:


TCMFForecaster

Create TCMFForecaster

from zoo.zouwu.model.forecast.tcmf_forecaster import TCMFForecaster
model = TCMFForecaster(
         vbsize=128,
         hbsize=256,
         num_channels_X=[32, 32, 32, 32, 32, 1],
         num_channels_Y=[16, 16, 16, 16, 16, 1],
         kernel_size=7,
         dropout=0.1,
         rank=64,
         kernel_size_Y=7,
         learning_rate=0.0005,
         normalize=False,
         use_time=True,
         svd=True,)

Use TCMFForecaster

Train model

After an TCMFForecaster is created, you can call forecaster API to train a tcmf model:

model.fit(x,
          val_len=24,
          start_date="2020-4-1",
          freq="1H",
          covariates=None,
          dti=None,
          period=24,
          y_iters=10,
          init_FX_epoch=100,
          max_FX_epoch=300,
          max_TCN_epoch=300,
          alt_iters=10,
          num_workers=None)

Get prediction results of model

After Training, you can call forecaster API to get the prediction result of tcmf model. model.predict will output the prediction results of future horizon steps after x in fit.

model.predict(horizon=24,
              future_covariates=None,
              future_dti=None,
              num_workers=None,
              )

Evaluate model

After Training, you can call forecaster API to evaluate the tcmf model. model.evaluate will output the evaluation results for future horizon steps after x in fit.

model.evaluate(target_value,
               metric=['mae'],
               target_covariates=None,
               target_dti=None,
               num_workers=None,
               )

Incrementally fit the model with additional data

Incrementally fit the model. Note that we only incrementally fit X_seq (TCN in global model). We haven't enable fit_incremental for input SparkXshards yet.

model.fit_incremental(x_incr,
                      covariates_incr=None,
                      dti_incr=None
                     )

Save model

You can save model after fit for future deployment.

model.save(path)

Load model

You can load saved model with

TCMFForecaster.load(path, 
                    distributed=False, 
                    minPartitions=None)

Check whether model is distributed with input xshards

You can check whether model is distributed by input xshards with model.is_xshards_distributed().