Table Of Contents
Table Of Contents

[Download]

Quick Start Tutorial

The GluonTS toolkit contains components and tools for building time series models using MXNet. The models that are currently included are forecasting models but the components also support other time series use cases, such as classification or anomaly detection.

The toolkit is not intended as a forecasting solution for businesses or end users but it rather targets scientists and engineers who want to tweak algorithms or build and experiment with their own models.

GluonTS contains:

  • Components for building new models (likelihoods, feature processing pipelines, calendar features etc.)
  • Data loading and processing
  • A number of pre-built models
  • Plotting and evaluation facilities
  • Artificial and real datasets (only external datasets with blessed license)
In [1]:
# Third-party imports
%matplotlib inline
import mxnet as mx
from mxnet import gluon
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import json

Datasets

GluonTS datasets

GluonTS comes with a number of publicly available datasets.

In [2]:
from gluonts.dataset.repository.datasets import get_dataset, dataset_recipes
from gluonts.dataset.util import to_pandas
In [3]:
print(f"Available datasets: {list(dataset_recipes.keys())}")
Available datasets: ['constant', 'exchange_rate', 'solar-energy', 'electricity', 'traffic', 'm4_hourly', 'm4_daily', 'm4_weekly', 'm4_monthly', 'm4_quarterly', 'm4_yearly']

To download one of the built-in datasets, simply call get_dataset with one of the above names. GluonTS can re-use the saved dataset so that it does not need to be downloaded again: simply set regenerate=False.

In [4]:
dataset = get_dataset("m4_hourly", regenerate=True)
INFO:root:downloading and processing m4_hourly
saving time-series into /var/lib/jenkins/.mxnet/gluon-ts/datasets/m4_hourly/train/data.json
saving time-series into /var/lib/jenkins/.mxnet/gluon-ts/datasets/m4_hourly/test/data.json

In general, the datasets provided by GluonTS are objects that consists of three main members:

  • dataset.train is an iterable collection of data entries used for training. Each entry corresponds to one time series
  • dataset.test is an iterable collection of data entries used for inference. The test dataset is an extended version of the train dataset that contains a window in the end of each time series that was not seen during training. This window has length equal to the recommended prediction length.
  • dataset.metadata contains metadata of the dataset such as the frequency of the time series, a recommended prediction horizon, associated features, etc.
In [5]:
entry = next(iter(dataset.train))
train_series = to_pandas(entry)
train_series.plot()
plt.grid(which="both")
plt.legend(["train series"], loc="upper left")
plt.show()
../../_images/examples_basic_forecasting_tutorial_tutorial_8_0.png
In [6]:
entry = next(iter(dataset.test))
test_series = to_pandas(entry)
test_series.plot()
plt.axvline(train_series.index[-1], color='r') # end of train dataset
plt.grid(which="both")
plt.legend(["test series", "end of train series"], loc="upper left")
plt.show()
../../_images/examples_basic_forecasting_tutorial_tutorial_9_0.png
In [7]:
print(f"Length of forecasting window in test dataset: {len(test_series) - len(train_series)}")
print(f"Recommended prediction horizon: {dataset.metadata.prediction_length}")
print(f"Frequency of the time series: {dataset.metadata.freq}")
Length of forecasting window in test dataset: 48
Recommended prediction horizon: 48
Frequency of the time series: H

Custom datasets

At this point, it is important to emphasize that GluonTS does not require this specific format for a custom dataset that a user may have. The only requirements for a custom dataset are to be iterable and have a “target” and a “start” field. To make this more clear, assume the common case where a dataset is in the form of a numpy.array and the index of the time series in a pandas.Timestamp (possibly different for each time series):

In [8]:
N = 10  # number of time series
T = 100  # number of timesteps
prediction_length = 24
freq = "1H"
custom_dataset = np.random.normal(size=(N, T))
start = pd.Timestamp("01-01-2019", freq=freq)  # can be different for each time series

Now, you can split your dataset and bring it in a GluonTS appropriate format with just two lines of code:

In [9]:
from gluonts.dataset.common import ListDataset
In [10]:
# train dataset: cut the last window of length "prediction_length", add "target" and "start" fields
train_ds = ListDataset([{'target': x, 'start': start}
                        for x in custom_dataset[:, :-prediction_length]],
                       freq=freq)
# test dataset: use the whole dataset, add "target" and "start" fields
test_ds = ListDataset([{'target': x, 'start': start}
                       for x in custom_dataset],
                      freq=freq)

Training an existing model (Estimator)

GluonTS comes with a number of pre-built models. All the user needs to do is configure some hyperparameters. The existing models focus on (but are not limited to) probabilistic forecasting. Probabilistic forecasts are predictions in the form of a probability distribution, rather than simply a single point estimate.

We will begin with GulonTS’s pre-built feedforward neural network estimator, a simple but powerful forecasting model. We will use this model to demonstrate the process of training a model, producing forecasts, and evaluating the results.

GluonTS’s built-in feedforward neural network (SimpleFeedForwardEstimator) accepts an input window of length context_length and predicts the distribution of the values of the subsequent prediction_length values. In GluonTS parlance, the feedforward neural network model is an example of Estimator. In GluonTS, Estimator objects represent a forecasting model as well as details such as its coefficients, weights, etc.

In general, each estimator (pre-built or custom) is configured by a number of hyperparameters that can be either common (but not binding) among all estimators (e.g., the prediction_length) or specific for the particular estimator (e.g., number of layers for a neural network or the stride in a CNN).

Finally, each estimator is configured by a Trainer, which defines how the model will be trained i.e., the number of epochs, the learning rate, etc.

In [11]:
from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.trainer import Trainer
INFO:root:Using GPU
In [12]:
estimator = SimpleFeedForwardEstimator(
    num_hidden_dimensions=[10],
    prediction_length=dataset.metadata.prediction_length,
    context_length=100,
    freq=dataset.metadata.freq,
    trainer=Trainer(ctx="cpu",
                    epochs=5,
                    learning_rate=1e-3,
                    num_batches_per_epoch=100
                   )
)

After specifying our estimator with all the necessary hyperparameters we can train it using our training dataset dataset.train by invoking the train method of the estimator. The training algorithm returns a fitted model (or a Predictor in GluonTS parlance) that can be used to construct forecasts.

In [13]:
predictor = estimator.train(dataset.train)
INFO:root:Start model training
INFO:root:Epoch[0] Learning rate is 0.001
  0%|          | 0/100 [00:00<?, ?it/s]INFO:root:Number of parameters in SimpleFeedForwardTrainingNetwork: 48513
100%|██████████| 100/100 [00:00<00:00, 154.87it/s, avg_epoch_loss=5.46]
INFO:root:Epoch[0] Elapsed time 0.648 seconds
INFO:root:Epoch[0] Evaluation metric 'epoch_loss'=5.463297
INFO:root:Epoch[1] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 177.35it/s, avg_epoch_loss=4.86]
INFO:root:Epoch[1] Elapsed time 0.565 seconds
INFO:root:Epoch[1] Evaluation metric 'epoch_loss'=4.858970
INFO:root:Epoch[2] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 172.81it/s, avg_epoch_loss=4.61]
INFO:root:Epoch[2] Elapsed time 0.580 seconds
INFO:root:Epoch[2] Evaluation metric 'epoch_loss'=4.613332
INFO:root:Epoch[3] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 173.02it/s, avg_epoch_loss=4.67]
INFO:root:Epoch[3] Elapsed time 0.579 seconds
INFO:root:Epoch[3] Evaluation metric 'epoch_loss'=4.671197
INFO:root:Epoch[4] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 169.20it/s, avg_epoch_loss=4.66]
INFO:root:Epoch[4] Elapsed time 0.592 seconds
INFO:root:Epoch[4] Evaluation metric 'epoch_loss'=4.663506
INFO:root:Loading parameters from best epoch (2)
INFO:root:Final loss: 4.613331880569458 (occurred at epoch 2)
INFO:root:End model training

With a predictor in hand, we can now predict the last window of the dataset.test and evaluate our model’s performance.

GluonTS comes with the make_evaluation_predictions function that automates the process of prediction and model evaluation. Roughly, this function performs the following steps:

  • Removes the final window of length prediction_length of the dataset.test that we want to predict
  • The estimator uses the remaining data to predict (in the form of sample paths) the “future” window that was just removed
  • The module outputs the forecast sample paths and the dataset.test (as python generator objects)
In [14]:
from gluonts.evaluation.backtest import make_evaluation_predictions
In [15]:
forecast_it, ts_it = make_evaluation_predictions(
    dataset=dataset.test,  # test dataset
    predictor=predictor,  # predictor
    num_samples=100,  # number of sample paths we want for evaluation
)

First, we can convert these generators to lists to ease the subsequent computations.

In [16]:
forecasts = list(forecast_it)
tss = list(ts_it)

We can examine the first element of these lists (that corresponds to the first time series of the dataset). Let’s start with the list containing the time series, i.e., tss. We expect the first entry of tss to contain the (target of the) first time series of dataset.test.

In [17]:
# first entry of the time series list
ts_entry = tss[0]
In [18]:
# first 5 values of the time series (convert from pandas to numpy)
np.array(ts_entry[:5]).reshape(-1,)
Out[18]:
array([605., 586., 586., 559., 511.], dtype=float32)
In [19]:
# first entry of dataset.test
dataset_test_entry = next(iter(dataset.test))
In [20]:
# first 5 values
dataset_test_entry['target'][:5]
Out[20]:
array([605., 586., 586., 559., 511.], dtype=float32)

The entries in the forecast list are a bit more complex. They are objects that contain all the sample paths in the form of numpy.ndarray with dimension (num_samples, prediction_length), the start date of the forecast, the frequency of the time series, etc. We can access all these information by simply invoking the corresponding attribute of the forecast object.

In [21]:
# first entry of the forecast list
forecast_entry = forecasts[0]
In [22]:
print(f"Number of sample paths: {forecast_entry.num_samples}")
print(f"Dimension of samples: {forecast_entry.samples.shape}")
print(f"Start date of the forecast window: {forecast_entry.start_date}")
print(f"Frequency of the time series: {forecast_entry.freq}")
Number of sample paths: 100
Dimension of samples: (100, 48)
Start date of the forecast window: 1750-01-30 04:00:00
Frequency of the time series: H

We can also do calculations to summarize the sample paths, such computing the mean or a quantile for each of the 48 time steps in the forecast window.

In [23]:
print(f"Mean of the future window:\n {forecast_entry.mean}")
print(f"0.5-quantile (median) of the future window:\n {forecast_entry.quantile(0.5)}")
Mean of the future window:
 [647.20386 582.2614  510.9434  489.15054 503.30368 455.37906 471.7423
 492.86914 497.1763  547.5439  615.975   604.37964 754.25476 790.59106
 841.4908  887.181   851.8546  814.7787  840.62024 825.0949  790.5732
 822.56305 762.7234  680.1077  681.34424 551.4373  524.6219  505.07013
 478.725   472.67578 500.87167 483.30276 562.15643 581.1776  583.90704
 607.20557 749.0424  833.4041  898.1994  867.8575  886.46716 896.48016
 884.12714 868.132   893.50726 841.6726  800.5941  745.99097]
0.5-quantile (median) of the future window:
 [653.2535  577.2916  531.8633  493.9621  496.69083 454.48898 484.97568
 499.91995 512.7409  527.7276  613.26807 594.4528  784.11505 804.5232
 843.9167  901.80035 862.8625  824.5678  835.8673  828.4219  801.69434
 814.95526 753.5655  653.70496 678.038   554.0029  527.26935 505.42145
 489.98508 455.08206 477.33917 478.04794 556.63824 586.34265 588.07886
 597.58844 724.43585 826.5106  883.08466 882.9329  870.3865  899.2444
 875.2176  849.0925  866.5467  850.58136 814.26556 752.473  ]

Forecast objects have a plot method that can summarize the forecast paths as the mean, prediction intervals, etc. The prediction intervals are shaded in different colors as a “fan chart”.

In [24]:
def plot_prob_forecasts(ts_entry, forecast_entry):
    plot_length = 150
    prediction_intervals = (50.0, 90.0)
    legend = ["observations", "median prediction"] + [f"{k}% prediction interval" for k in prediction_intervals][::-1]

    fig, ax = plt.subplots(1, 1, figsize=(10, 7))
    ts_entry[-plot_length:].plot(ax=ax)  # plot the time series
    forecast_entry.plot(prediction_intervals=prediction_intervals, color='g')
    plt.grid(which="both")
    plt.legend(legend, loc="upper left")
    plt.show()
In [25]:
plot_prob_forecasts(ts_entry, forecast_entry)
../../_images/examples_basic_forecasting_tutorial_tutorial_38_0.png

We can also evaluate the quality of our forecasts numerically. In GluonTS, the Evaluator class can compute aggregate performance metrics, as well as metrics per time series (which can be useful for analyzing performance across heterogeneous time series).

In [26]:
from gluonts.evaluation import Evaluator
In [27]:
evaluator = Evaluator(quantiles=[0.1, 0.5, 0.9])
agg_metrics, item_metrics = evaluator(iter(tss), iter(forecasts), num_series=len(dataset.test))
Running evaluation: 100%|██████████| 414/414 [00:01<00:00, 229.42it/s]

Aggregate metrics aggregate both across time-steps and across time series.

In [28]:
print(json.dumps(agg_metrics, indent=4))
{
    "MSE": 8443908.678894352,
    "abs_error": 8877123.154870987,
    "abs_target_sum": 145558863.59960938,
    "abs_target_mean": 7324.822041043146,
    "seasonal_error": 336.9046924038305,
    "MASE": 3.246015285156499,
    "sMAPE": 0.18506043295168975,
    "MSIS": 38.217292786814824,
    "QuantileLoss[0.1]": 5679215.008755971,
    "Coverage[0.1]": 0.09983896940418678,
    "QuantileLoss[0.5]": 8877123.216818333,
    "Coverage[0.5]": 0.5041767310789049,
    "QuantileLoss[0.9]": 7424048.535117529,
    "Coverage[0.9]": 0.892109500805153,
    "RMSE": 2905.8404427797395,
    "NRMSE": 0.39671140493208645,
    "ND": 0.0609864829618992,
    "wQuantileLoss[0.1]": 0.0390166209622099,
    "wQuantileLoss[0.5]": 0.06098648338748198,
    "wQuantileLoss[0.9]": 0.051003754436685866,
    "mean_wQuantileLoss": 0.05033561959545924,
    "MAE_Coverage": 0.004076086956521706
}

Individual metrics are aggregated only across time-steps.

In [29]:
item_metrics.head()
Out[29]:
item_id MSE abs_error abs_target_sum abs_target_mean seasonal_error MASE sMAPE MSIS QuantileLoss[0.1] Coverage[0.1] QuantileLoss[0.5] Coverage[0.5] QuantileLoss[0.9] Coverage[0.9]
0 NaN 2575.603190 1810.123291 31644.0 659.250000 42.371302 0.890010 0.052957 6.590440 1124.217487 0.000000 1810.123322 0.687500 1556.539575 1.000
1 NaN 155960.083333 16736.312500 124149.0 2586.437500 165.107988 2.111789 0.128283 9.495756 3136.557202 0.083333 16736.311035 1.000000 8878.533398 1.000
2 NaN 33333.468750 6730.528320 65030.0 1354.791667 78.889053 1.777425 0.099408 9.843424 3813.144781 0.000000 6730.527954 0.125000 1800.347559 0.875
3 NaN 205193.458333 17788.773438 235783.0 4912.145833 258.982249 1.430984 0.074392 9.752359 11702.585449 0.041667 17788.773682 0.333333 8140.801953 1.000
4 NaN 97967.750000 10185.052734 131088.0 2731.000000 200.494083 1.058328 0.072182 8.256144 6101.760876 0.020833 10185.052490 0.645833 7459.407422 1.000
In [30]:
item_metrics.plot(x='MSIS', y='MASE', kind='scatter')
plt.grid(which="both")
plt.show()
../../_images/examples_basic_forecasting_tutorial_tutorial_46_0.png

Create your own forecast model

For creating your own forecast model you need to:

  • Define the training and prediction network
  • Define a new estimator that specifies any data processing and uses the networks

The training and prediction networks can be arbitrarily complex but they should follow some basic rules:

  • Both should have a hybrid_forward method that defines what should happen when the network is called
  • The training network’s hybrid_forward should return a loss based on the prediction and the true values
  • The prediction network’s hybrid_forward should return the predictions

For example, we can create a simple training network that defines a neural network which takes as an input the past values of the time series and outputs a future predicted window of length prediction_length. It uses the L1 loss in the hybrid_forward method to evaluate the error among the predictions and the true values of the time series. The corresponding prediction network should be identical to the training network in terms of architecture (we achieve this by inheriting the training network class), and its hybrid_forward method outputs directly the predictions.

Note that this simple model does only point forecasts by construction, i.e., we train it to outputs directly the future values of the time series and not any probabilistic view of the future (to achieve this we should train a network to learn a probability distribution and then sample from it to create sample paths).

In [31]:
class MyTrainNetwork(gluon.HybridBlock):
    def __init__(self, prediction_length, **kwargs):
        super().__init__(**kwargs)
        self.prediction_length = prediction_length

        with self.name_scope():
            # Set up a 3 layer neural network that directly predicts the target values
            self.nn = mx.gluon.nn.HybridSequential()
            self.nn.add(mx.gluon.nn.Dense(units=40, activation='relu'))
            self.nn.add(mx.gluon.nn.Dense(units=40, activation='relu'))
            self.nn.add(mx.gluon.nn.Dense(units=self.prediction_length, activation='softrelu'))

    def hybrid_forward(self, F, past_target, future_target):
        prediction = self.nn(past_target)
        # calculate L1 loss with the future_target to learn the median
        return (prediction - future_target).abs().mean(axis=-1)


class MyPredNetwork(MyTrainNetwork):
    # The prediction network only receives past_target and returns predictions
    def hybrid_forward(self, F, past_target):
        prediction = self.nn(past_target)
        return prediction.expand_dims(axis=1)

Now, we need to construct the estimator which should also follow some rules:

  • It should include a create_transformation method that defines all the possible feature transformations and how the data is split during training
  • It should include a create_training_network method that returns the training network configured with any necessary hyperparameters
  • It should include a create_predictor method that creates the prediction network, and returns a Predictor object

A Predictor defines the predict method of a given predictor. Roughly, this method takes the test dataset, it passes it through the prediction network and yields the predictions. You can think of the Predictor object as a wrapper of the prediction network that defines its predict method.

Earlier, we used the make_evaluation_predictions to evaluate our predictor. Internally, the make_evaluation_predictions function invokes the predict method of the predictor to get the forecasts.

In [32]:
from gluonts.model.estimator import GluonEstimator
from gluonts.model.predictor import Predictor, RepresentableBlockPredictor
from gluonts.core.component import validated
from gluonts.support.util import copy_parameters
from gluonts.transform import ExpectedNumInstanceSampler, Transformation, InstanceSplitter
from gluonts.dataset.field_names import FieldName
from mxnet.gluon import HybridBlock
In [33]:
class MyEstimator(GluonEstimator):
    @validated()
    def __init__(
        self,
        freq: str,
        context_length: int,
        prediction_length: int,
        trainer: Trainer = Trainer()
    ) -> None:
        super().__init__(trainer=trainer)
        self.context_length = context_length
        self.prediction_length = prediction_length
        self.freq = freq


    def create_transformation(self):
        # Feature transformation that the model uses for input.
        # Here we use a transformation that randomly select training samples from all time series.
        return InstanceSplitter(
                    target_field=FieldName.TARGET,
                    is_pad_field=FieldName.IS_PAD,
                    start_field=FieldName.START,
                    forecast_start_field=FieldName.FORECAST_START,
                    train_sampler=ExpectedNumInstanceSampler(num_instances=1),
                    past_length=self.context_length,
                    future_length=self.prediction_length,
                )

    def create_training_network(self) -> MyTrainNetwork:
        return MyTrainNetwork(
            prediction_length=self.prediction_length
        )

    def create_predictor(
        self, transformation: Transformation, trained_network: HybridBlock
    ) -> Predictor:
        prediction_network = MyPredNetwork(
            prediction_length=self.prediction_length
        )

        copy_parameters(trained_network, prediction_network)

        return RepresentableBlockPredictor(
            input_transform=transformation,
            prediction_net=prediction_network,
            batch_size=self.trainer.batch_size,
            freq=self.freq,
            prediction_length=self.prediction_length,
            ctx=self.trainer.ctx,
        )
INFO:root:Using GPU

Now, we can repeat the same pipeline as in the case we had a pre-built model: train the predictor, create the forecasts and evaluate the results.

In [34]:
estimator = MyEstimator(
    prediction_length=dataset.metadata.prediction_length,
    context_length=100,
    freq=dataset.metadata.freq,
    trainer=Trainer(ctx="cpu",
                    epochs=5,
                    learning_rate=1e-3,
                    num_batches_per_epoch=100
                   )
)
In [35]:
predictor = estimator.train(dataset.train)
INFO:root:Start model training
INFO:root:Epoch[0] Learning rate is 0.001
  0%|          | 0/100 [00:00<?, ?it/s]INFO:root:Number of parameters in MyTrainNetwork: 7648
100%|██████████| 100/100 [00:00<00:00, 208.39it/s, avg_epoch_loss=2.79e+3]
INFO:root:Epoch[0] Elapsed time 0.481 seconds
INFO:root:Epoch[0] Evaluation metric 'epoch_loss'=2791.850966
INFO:root:Epoch[1] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 203.11it/s, avg_epoch_loss=1.24e+3]
INFO:root:Epoch[1] Elapsed time 0.494 seconds
INFO:root:Epoch[1] Evaluation metric 'epoch_loss'=1244.906549
INFO:root:Epoch[2] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 209.26it/s, avg_epoch_loss=744]
INFO:root:Epoch[2] Elapsed time 0.479 seconds
INFO:root:Epoch[2] Evaluation metric 'epoch_loss'=744.116191
INFO:root:Epoch[3] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 185.17it/s, avg_epoch_loss=801]
INFO:root:Epoch[3] Elapsed time 0.541 seconds
INFO:root:Epoch[3] Evaluation metric 'epoch_loss'=801.397754
INFO:root:Epoch[4] Learning rate is 0.001
100%|██████████| 100/100 [00:00<00:00, 185.20it/s, avg_epoch_loss=632]
INFO:root:Epoch[4] Elapsed time 0.542 seconds
INFO:root:Epoch[4] Evaluation metric 'epoch_loss'=632.006380
INFO:root:Loading parameters from best epoch (4)
INFO:root:Final loss: 632.0063797760009 (occurred at epoch 4)
INFO:root:End model training
In [36]:
forecast_it, ts_it = make_evaluation_predictions(
    dataset=dataset.test,
    predictor=predictor,
    num_samples=100
)
In [37]:
forecasts = list(forecast_it)
tss = list(ts_it)
In [38]:
plot_prob_forecasts(tss[0], forecasts[0])
../../_images/examples_basic_forecasting_tutorial_tutorial_57_0.png

Observe that we cannot actually see any prediction intervals in the predictions. This is expected since the model that we defined does not do probabilistic forecasting but it just gives point estimates. By requiring 100 sample paths (defined in make_evaluation_predictions) in such a network, we get 100 times the same output.

In [39]:
evaluator = Evaluator(quantiles=[0.1, 0.5, 0.9])
agg_metrics, item_metrics = evaluator(iter(tss), iter(forecasts), num_series=len(dataset.test))
Running evaluation: 100%|██████████| 414/414 [00:01<00:00, 245.75it/s]
In [40]:
print(json.dumps(agg_metrics, indent=4))
{
    "MSE": 5853364.606121205,
    "abs_error": 8915522.82320404,
    "abs_target_sum": 145558863.59960938,
    "abs_target_mean": 7324.822041043146,
    "seasonal_error": 336.9046924038305,
    "MASE": 5.623555808453385,
    "sMAPE": 0.23897049948657853,
    "MSIS": 224.9422332728974,
    "QuantileLoss[0.1]": 8795887.99092722,
    "Coverage[0.1]": 0.40750805152979064,
    "QuantileLoss[0.5]": 8915522.804756641,
    "Coverage[0.5]": 0.40750805152979064,
    "QuantileLoss[0.9]": 9035157.618586063,
    "Coverage[0.9]": 0.40750805152979064,
    "RMSE": 2419.3727712200957,
    "NRMSE": 0.33029782261789215,
    "ND": 0.0612502914815829,
    "wQuantileLoss[0.1]": 0.060428391465889575,
    "wQuantileLoss[0.5]": 0.06125029135484792,
    "wQuantileLoss[0.9]": 0.062072191243806266,
    "mean_wQuantileLoss": 0.06125029135484792,
    "MAE_Coverage": 0.29749731615673647
}
In [41]:
item_metrics.head(10)
Out[41]:
item_id MSE abs_error abs_target_sum abs_target_mean seasonal_error MASE sMAPE MSIS QuantileLoss[0.1] Coverage[0.1] QuantileLoss[0.5] Coverage[0.5] QuantileLoss[0.9] Coverage[0.9]
0 NaN 3.360324e+03 2110.315430 31644.0 659.250000 42.371302 1.037610 0.069895 41.504413 2214.549841 0.437500 2110.315369 0.437500 2006.080896 0.437500
1 NaN 1.351201e+05 14836.974609 124149.0 2586.437500 165.107988 1.872130 0.115252 74.885207 25520.270874 0.875000 14836.974487 0.875000 4153.678101 0.875000
2 NaN 6.388074e+04 9895.433594 65030.0 1354.791667 78.889053 2.613225 0.149865 104.529027 3342.424353 0.270833 9895.434753 0.270833 16448.445154 0.270833
3 NaN 2.783296e+05 19391.820312 235783.0 4912.145833 258.982249 1.559938 0.085016 62.397526 15240.185791 0.416667 19391.821533 0.416667 23543.457275 0.416667
4 NaN 7.997118e+04 11028.311523 131088.0 2731.000000 200.494083 1.145951 0.083636 45.838060 12282.007129 0.645833 11028.311035 0.645833 9774.614941 0.645833
5 NaN 2.672339e+05 19521.517578 303379.0 6320.395833 212.875740 1.910496 0.065652 76.419839 12099.338477 0.229167 19521.516602 0.229167 26943.694727 0.229167
6 NaN 1.076784e+07 129877.453125 1985325.0 41360.937500 1947.687870 1.389227 0.065421 55.569072 61269.861328 0.291667 129877.447266 0.291667 198485.033203 0.291667
7 NaN 7.907451e+06 117301.203125 1540706.0 32098.041667 1624.044379 1.504746 0.080767 60.189858 49112.301953 0.166667 117301.197266 0.166667 185490.092578 0.166667
8 NaN 7.048744e+06 103050.171875 1640860.0 34184.583333 1850.988166 1.159855 0.062404 46.394217 136085.590234 0.645833 103050.169922 0.645833 70014.749609 0.645833
9 NaN 1.216817e+03 1343.103149 21408.0 446.000000 10.526627 2.658146 0.062820 106.325852 477.116528 0.229167 1343.103149 0.229167 2209.089771 0.229167
In [42]:
item_metrics.plot(x='MSIS', y='MASE', kind='scatter')
plt.grid(which="both")
plt.show()
../../_images/examples_basic_forecasting_tutorial_tutorial_62_0.png