import warnings
warnings.filterwarnings('ignore')
from sktime.datasets import load_airline
from sktime.forecasting.model_selection import temporal_train_test_split
y = load_airline() # 144 for 12 years
y_train, y_test = temporal_train_test_split(y, test_size=36) # hold out last 3 years
from sktime.forecasting.compose import EnsembleForecaster
from sktime.forecasting.ets import AutoETS
from sktime.forecasting.naive import NaiveForecaster
from sktime.forecasting.arima import AutoARIMA
forecaster = EnsembleForecaster([
('Naive', NaiveForecaster(strategy="last", sp=12)),
('AutoETS', AutoETS(auto=True, sp=12, n_jobs=-1)),
('AutoARIMA', AutoARIMA(sp=12, suppress_warnings=True))
])
import numpy as np
fh = np.arange(1, 37)
forecaster.fit(y=y_train, fh=fh)
y_pred = forecaster.predict(fh)
from sktime.utils.plotting import plot_series
from sktime.performance_metrics.forecasting import mean_absolute_percentage_error
plot_series(y_train, y_test, y_pred, labels=["y_train", "y_test", "y_pred"])
mean_absolute_percentage_error(y_test, y_pred, symmetric=False)
0.06465290009631279