Last active
July 3, 2021 18:30
-
-
Save tomonori-masui/1d99b4487343e3386fe12a03c9053718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sktime.forecasting.trend import PolynomialTrendForecaster | |
from sktime.transformations.series.detrend import Detrender | |
# linear detrending | |
forecaster = PolynomialTrendForecaster(degree=1) | |
transformer = Detrender(forecaster=forecaster) | |
yt = transformer.fit_transform(wpi_train) | |
forecaster = PolynomialTrendForecaster(degree=1) | |
fh_ins = -np.arange(len(wpi_train)) # in-sample forecasting horizon | |
y_pred = forecaster.fit(wpi_train).predict(fh=fh_ins) | |
plot_series( | |
wpi_train, y_pred, yt, labels=["y_train", "fitted linear trend", "residuals"] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment