sktime 中不一致的预测范围设置
Inconsistant prediction range settings in sktime
我注意到在为不同类型的算法指定预测区间时存在不一致 - AutoETS
和 AutoARIMA
。我不确定这是错误还是功能。
from matplotlib import pyplot as plt
from sktime.datasets import load_airline
from sktime.forecasting.model_selection import temporal_train_test_split
from sktime.forecasting.base import ForecastingHorizon
y = load_airline()
y_train,y_test = temporal_train_test_split(y)
fh = ForecastingHorizon(y_test.index, is_relative=False)
from sktime.forecasting.ets import AutoETS
model = AutoETS(trend='add',seasonal='mul',sp=12)
model.fit(y_train,fh=y_test.index)
preds_ets_05 = model.predict(fh,return_pred_int=True,alpha=0.05)
preds_ets_95 = model.predict(fh,return_pred_int=True,alpha=0.95)
from sktime.forecasting.arima import AutoARIMA
model = AutoARIMA(tsp=12)
model.fit(y_train,fh=y_test.index)
preds_arima_05 = model.predict(fh,return_pred_int=True,alpha=0.05)
preds_arima_95 = model.predict(fh,return_pred_int=True,alpha=0.95)
如果我们绘制预测图,我们会得到:
figs, (ax1,ax2) = plt.subplots(2,sharey=True)
ax1.fill_between(preds_ets_05[0].index.to_timestamp('M'),
preds_ets_05[1]['lower'],
preds_ets_05[1]['upper'],
alpha=0.25,
color='green',
label = 'ets')
ax1.fill_between(preds_arima_05[0].index.to_timestamp('M'),
preds_arima_05[1]['lower'],
preds_arima_05[1]['upper'],
alpha=0.25,
color='red',
label ='arima')
ax1.tick_params(rotation=45)
ax1.set_title('alpha=0.05')
ax1.legend()
ax2.fill_between(preds_ets_95[0].index.to_timestamp('M'),
preds_ets_95[1]['lower'],
preds_ets_95[1]['upper'],
alpha=0.25,
color='green',
label = 'ets')
ax2.fill_between(preds_arima_95[0].index.to_timestamp('M'),
preds_arima_95[1]['lower'],
preds_arima_95[1]['upper'],
alpha=0.25,
color='red',
label = 'arima')
ax2.tick_params(rotation=45)
ax2.set_title('alpha=0.95')
ax2.legend()
plt.tight_layout()
plt.show()
其中一个算法的 alpha 定义似乎颠倒了。
版本 0 中的已知错误。10.X(随着 覆盖率 变大,间隔应该变宽),应该在 0.11.0 中修复,请参阅
https://github.com/alan-turing-institute/sktime/discussions/2334
我注意到在为不同类型的算法指定预测区间时存在不一致 - AutoETS
和 AutoARIMA
。我不确定这是错误还是功能。
from matplotlib import pyplot as plt
from sktime.datasets import load_airline
from sktime.forecasting.model_selection import temporal_train_test_split
from sktime.forecasting.base import ForecastingHorizon
y = load_airline()
y_train,y_test = temporal_train_test_split(y)
fh = ForecastingHorizon(y_test.index, is_relative=False)
from sktime.forecasting.ets import AutoETS
model = AutoETS(trend='add',seasonal='mul',sp=12)
model.fit(y_train,fh=y_test.index)
preds_ets_05 = model.predict(fh,return_pred_int=True,alpha=0.05)
preds_ets_95 = model.predict(fh,return_pred_int=True,alpha=0.95)
from sktime.forecasting.arima import AutoARIMA
model = AutoARIMA(tsp=12)
model.fit(y_train,fh=y_test.index)
preds_arima_05 = model.predict(fh,return_pred_int=True,alpha=0.05)
preds_arima_95 = model.predict(fh,return_pred_int=True,alpha=0.95)
如果我们绘制预测图,我们会得到:
figs, (ax1,ax2) = plt.subplots(2,sharey=True)
ax1.fill_between(preds_ets_05[0].index.to_timestamp('M'),
preds_ets_05[1]['lower'],
preds_ets_05[1]['upper'],
alpha=0.25,
color='green',
label = 'ets')
ax1.fill_between(preds_arima_05[0].index.to_timestamp('M'),
preds_arima_05[1]['lower'],
preds_arima_05[1]['upper'],
alpha=0.25,
color='red',
label ='arima')
ax1.tick_params(rotation=45)
ax1.set_title('alpha=0.05')
ax1.legend()
ax2.fill_between(preds_ets_95[0].index.to_timestamp('M'),
preds_ets_95[1]['lower'],
preds_ets_95[1]['upper'],
alpha=0.25,
color='green',
label = 'ets')
ax2.fill_between(preds_arima_95[0].index.to_timestamp('M'),
preds_arima_95[1]['lower'],
preds_arima_95[1]['upper'],
alpha=0.25,
color='red',
label = 'arima')
ax2.tick_params(rotation=45)
ax2.set_title('alpha=0.95')
ax2.legend()
plt.tight_layout()
plt.show()
其中一个算法的 alpha 定义似乎颠倒了。
版本 0 中的已知错误。10.X(随着 覆盖率 变大,间隔应该变宽),应该在 0.11.0 中修复,请参阅 https://github.com/alan-turing-institute/sktime/discussions/2334