Example: Univariate forecast¶
This example shows how to use ATOM to work with a univariate time series dataset.
Import the airline dataset from sktime.datasets. This is a small and easy to train dataset that measures monthly totals of international airline passengers from 1949 to 1960.
Load the data¶
In [1]:
Copied!
# Import packages
import numpy as np
from sktime.datasets import load_airline
from atom import ATOMForecaster
# Import packages
import numpy as np
from sktime.datasets import load_airline
from atom import ATOMForecaster
In [2]:
Copied!
# Load the data
y = load_airline()
print(y)
# Load the data
y = load_airline()
print(y)
Analyze the data¶
In [3]:
Copied!
atom = ATOMForecaster(y, verbose=2, random_state=1)
atom = ATOMForecaster(y, verbose=2, random_state=1)
In [4]:
Copied!
# Since the dataset contains only the target column, atom.X is empty
atom.X
# Since the dataset contains only the target column, atom.X is empty
atom.X
In [5]:
Copied!
# Examine the dataset
atom.plot_series()
# Examine the dataset
atom.plot_series()
In [6]:
Copied!
atom.plot_qq()
atom.plot_qq()
Seasonality¶
In [7]:
Copied!
# ATOM has a number of plots to understand the seasonality of the data
with atom.canvas(rows=2, cols=1, sharex=True, vspace=0.01, legend=None):
atom.plot_acf()
atom.plot_pacf()
# ATOM has a number of plots to understand the seasonality of the data
with atom.canvas(rows=2, cols=1, sharex=True, vspace=0.01, legend=None):
atom.plot_acf()
atom.plot_pacf()
In [8]:
Copied!
with atom.canvas(rows=2, cols=1, sharex=True, vspace=0.01, legend=None):
atom.plot_periodogram()
atom.plot_fft()
with atom.canvas(rows=2, cols=1, sharex=True, vspace=0.01, legend=None):
atom.plot_periodogram()
atom.plot_fft()
In [9]:
Copied!
# It's also possible to compute the seasonality
sp = atom.get_seasonal_period()
sp
# It's also possible to compute the seasonality
sp = atom.get_seasonal_period()
sp
In [10]:
Copied!
# And use that seasonality
atom.sp = sp
# And use that seasonality
atom.sp = sp
Run the pipeline¶
In [11]:
Copied!
# Use the regular data cleaning methods to transform the target column
atom.scale(columns=-1)
# Use the regular data cleaning methods to transform the target column
atom.scale(columns=-1)
In [12]:
Copied!
atom.y
atom.y
In [13]:
Copied!
atom.run(["AutoARIMA", "TBATS", "Prophet"])
atom.run(["AutoARIMA", "TBATS", "Prophet"])
In [14]:
Copied!
# It's also possible to use regression models for forecast tasks
atom.run("RF")
# It's also possible to use regression models for forecast tasks
atom.run("RF")
In [15]:
Copied!
atom.rf.estimator
atom.rf.estimator
Analyze the results¶
In [16]:
Copied!
atom.evaluate()
atom.evaluate()
In [17]:
Copied!
atom.winner.plot_forecast()
atom.winner.plot_forecast()
In [18]:
Copied!
atom.plot_errors()
atom.plot_errors()