[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', 'exchange_rate_nips', 'electricity_nips', 'traffic_nips', 'solar_nips', 'wiki-rolling_nips', 'taxi_30min', 'm4_hourly', 'm4_daily', 'm4_weekly', 'm4_monthly', 'm4_quarterly', 'm4_yearly', 'm5']

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)
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
/var/lib/jenkins/workspace/workspace/gluon-ts-gpu-py3/conda/gpu/py3/lib/python3.6/site-packages/ipykernel_launcher.py:2: DeprecationWarning: gluonts.trainer is deprecated. Use gluonts.mx.trainer instead.

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)
  0%|          | 0/100 [00:00<?, ?it/s]
learning rate from ``lr_scheduler`` has been overwritten by ``learning_rate`` in optimizer.
100%|██████████| 100/100 [00:00<00:00, 140.01it/s, epoch=1/5, avg_epoch_loss=5.63]
100%|██████████| 100/100 [00:00<00:00, 139.12it/s, epoch=2/5, avg_epoch_loss=4.8]
100%|██████████| 100/100 [00:00<00:00, 149.71it/s, epoch=3/5, avg_epoch_loss=4.91]
100%|██████████| 100/100 [00:00<00:00, 132.82it/s, epoch=4/5, avg_epoch_loss=4.74]
100%|██████████| 100/100 [00:00<00:00, 137.89it/s, epoch=5/5, avg_epoch_loss=4.72]

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:
 [618.63324 560.5373  573.6191  534.7239  474.3449  424.95184 400.43402
 484.0339  483.159   635.0678  569.7637  605.52295 726.9146  718.8593
 781.2949  871.37866 832.8507  811.7904  915.394   802.6954  737.5463
 826.1116  734.1622  621.4608  592.012   523.38367 475.57782 481.23074
 430.90518 555.0655  473.369   555.29315 602.9777  603.49304 685.15405
 640.7822  808.0232  830.7382  801.4352  865.8962  903.82385 901.4687
 818.0764  844.6998  839.7346  826.147   817.7683  720.9179 ]
0.5-quantile (median) of the future window:
 [627.5742  561.48846 594.2106  537.6911  466.9397  430.20023 412.6508
 484.70312 489.66757 616.0707  568.27423 596.4292  744.9617  733.847
 781.6702  887.11774 826.04016 803.44525 901.9264  800.2061  759.90265
 821.4279  727.413   610.03516 592.88354 522.57477 482.89688 481.66312
 427.50916 580.70306 455.3549  549.54926 599.9553  607.1343  676.6377
 634.97235 775.5665  836.89575 802.03766 880.30695 880.91376 912.67084
 826.2038  849.02905 813.04834 823.94586 816.97534 727.71564]

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:00<00:00, 3932.39it/s]

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

In [28]:
print(json.dumps(agg_metrics, indent=4))
{
    "MSE": 13185684.45690436,
    "abs_error": 11164704.534996033,
    "abs_target_sum": 145558863.59960938,
    "abs_target_mean": 7324.822041043146,
    "seasonal_error": 336.9046924038305,
    "MASE": 5.132159278821622,
    "MAPE": 0.2678863913368016,
    "sMAPE": 0.2122571888667198,
    "OWA": NaN,
    "MSIS": 64.42364291480138,
    "QuantileLoss[0.1]": 5563845.873083878,
    "Coverage[0.1]": 0.09601449275362318,
    "QuantileLoss[0.5]": 11164704.519984245,
    "Coverage[0.5]": 0.42190016103059585,
    "QuantileLoss[0.9]": 6627129.545302676,
    "Coverage[0.9]": 0.8480273752012883,
    "RMSE": 3631.2097786969507,
    "NRMSE": 0.49574034131480704,
    "ND": 0.07670233374249835,
    "wQuantileLoss[0.1]": 0.03822402659303813,
    "wQuantileLoss[0.5]": 0.07670233363936628,
    "wQuantileLoss[0.9]": 0.04552886290409635,
    "mean_wQuantileLoss": 0.05348507437883359,
    "MAE_Coverage": 0.04468599033816421
}

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 MAPE sMAPE OWA MSIS QuantileLoss[0.1] Coverage[0.1] QuantileLoss[0.5] Coverage[0.5] QuantileLoss[0.9] Coverage[0.9]
0 0.0 3745.974609 2411.371094 31644.0 659.250000 42.371302 1.185635 0.079721 0.077463 NaN 13.591842 1062.205426 0.000000 2411.371216 0.520833 1365.088635 0.979167
1 1.0 157444.197917 15466.601562 124149.0 2586.437500 165.107988 1.951576 0.134682 0.121989 NaN 13.993761 3365.445312 0.291667 15466.600952 0.937500 8288.198877 1.000000
2 2.0 44347.151042 8305.946289 65030.0 1354.791667 78.889053 2.193467 0.120161 0.128611 NaN 13.518049 3716.880188 0.000000 8305.946167 0.166667 3309.509241 0.708333
3 3.0 316375.458333 23730.753906 235783.0 4912.145833 258.982249 1.908975 0.101099 0.101830 NaN 14.737117 11080.922461 0.041667 23730.754639 0.333333 7710.334863 0.895833
4 4.0 100450.125000 11716.642578 131088.0 2731.000000 200.494083 1.217476 0.093023 0.088670 NaN 13.187473 5348.718823 0.041667 11716.642822 0.541667 6862.393555 1.000000
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,
        )

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)
  0%|          | 0/100 [00:00<?, ?it/s]
learning rate from ``lr_scheduler`` has been overwritten by ``learning_rate`` in optimizer.
100%|██████████| 100/100 [00:00<00:00, 143.43it/s, epoch=1/5, avg_epoch_loss=2.97e+3]
100%|██████████| 100/100 [00:00<00:00, 155.57it/s, epoch=2/5, avg_epoch_loss=1.61e+3]
100%|██████████| 100/100 [00:00<00:00, 161.20it/s, epoch=3/5, avg_epoch_loss=1.18e+3]
100%|██████████| 100/100 [00:00<00:00, 156.72it/s, epoch=4/5, avg_epoch_loss=1.18e+3]
100%|██████████| 100/100 [00:00<00:00, 158.87it/s, epoch=5/5, avg_epoch_loss=1.02e+3]
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:00<00:00, 5036.20it/s]
In [40]:
print(json.dumps(agg_metrics, indent=4))
{
    "MSE": 86233619.69905807,
    "abs_error": 25505798.342391968,
    "abs_target_sum": 145558863.59960938,
    "abs_target_mean": 7324.822041043146,
    "seasonal_error": 336.9046924038305,
    "MASE": 12.1980331451371,
    "MAPE": 0.5330938709259624,
    "sMAPE": 0.3184877097268396,
    "OWA": NaN,
    "MSIS": 487.92133149358364,
    "QuantileLoss[0.1]": 12043808.987167837,
    "Coverage[0.1]": 0.3714271336553945,
    "QuantileLoss[0.5]": 25505798.609896183,
    "Coverage[0.5]": 0.3714271336553945,
    "QuantileLoss[0.9]": 38967788.23262454,
    "Coverage[0.9]": 0.3714271336553945,
    "RMSE": 9286.205882870467,
    "NRMSE": 1.2677722176507642,
    "ND": 0.17522669325415383,
    "wQuantileLoss[0.1]": 0.08274184539044559,
    "wQuantileLoss[0.5]": 0.17522669509192726,
    "wQuantileLoss[0.9]": 0.26771154479340903,
    "mean_wQuantileLoss": 0.17522669509192731,
    "MAE_Coverage": 0.3095242887815352
}
In [41]:
item_metrics.head(10)
Out[41]:
item_id MSE abs_error abs_target_sum abs_target_mean seasonal_error MASE MAPE sMAPE OWA MSIS QuantileLoss[0.1] Coverage[0.1] QuantileLoss[0.5] Coverage[0.5] QuantileLoss[0.9] Coverage[0.9]
0 0.0 2.028022e+04 5203.663574 31644.0 659.250000 42.371302 2.558563 0.169554 0.194155 NaN 102.342526 2374.629608 0.354167 5203.663666 0.354167 8032.697723 0.354167
1 1.0 2.944715e+05 21092.886719 124149.0 2586.437500 165.107988 2.661501 0.172540 0.177778 NaN 106.460060 20014.562305 0.520833 21092.887695 0.520833 22171.213086 0.520833
2 2.0 1.880157e+05 16359.754883 65030.0 1354.791667 78.889053 4.320349 0.228432 0.273805 NaN 172.813967 4506.942383 0.208333 16359.755859 0.208333 28212.569336 0.208333
3 3.0 1.170196e+06 41249.894531 235783.0 4912.145833 258.982249 3.318269 0.167480 0.188992 NaN 132.730763 13652.090674 0.187500 41249.894775 0.187500 68847.698877 0.187500
4 4.0 4.758771e+05 24829.246094 131088.0 2731.000000 200.494083 2.580006 0.176630 0.192678 NaN 103.200241 12609.317725 0.333333 24829.245850 0.333333 37049.173975 0.333333
5 5.0 1.561011e+06 47966.656250 303379.0 6320.395833 212.875740 4.694313 0.168289 0.194309 NaN 187.772517 18620.512842 0.250000 47966.654053 0.250000 77312.795264 0.250000
6 6.0 1.049356e+08 384873.812500 1985325.0 41360.937500 1947.687870 4.116781 0.180524 0.206553 NaN 164.671235 119851.733203 0.166667 384873.806641 0.166667 649895.880078 0.166667
7 7.0 5.976108e+07 285593.000000 1540706.0 32098.041667 1624.044379 3.663603 0.188205 0.221991 NaN 146.544128 100954.036328 0.208333 285592.994141 0.208333 470231.951953 0.208333
8 8.0 4.639233e+07 254431.609375 1640860.0 34184.583333 1850.988166 2.863691 0.155938 0.173978 NaN 114.547644 134665.332422 0.354167 254431.599609 0.354167 374197.866797 0.354167
9 9.0 1.131647e+04 3959.520264 21408.0 446.000000 10.526627 7.836319 0.178165 0.207493 NaN 313.452751 1240.564172 0.270833 3959.520325 0.270833 6678.476477 0.270833
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