Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.. raw:: html
<br>
"""
print(__doc__)
# Author: Taylor Smith
import pmdarima as pm
from pmdarima import model_selection
import numpy as np
from matplotlib import pyplot as plt
# #############################################################################
# Load the data and split it into separate pieces
data = pm.datasets.load_wineind()
train, test = model_selection.train_test_split(data, train_size=150)
# Fit a simple auto_arima model
arima = pm.auto_arima(train, error_action='ignore', trace=True,
suppress_warnings=True, maxiter=10,
seasonal=True, m=12)
# #############################################################################
# Plot actual test vs. forecasts:
x = np.arange(test.shape[0])
plt.scatter(x, test, marker='x')
plt.plot(x, arima.predict(n_periods=test.shape[0]))
plt.title('Actual test samples vs. forecasts')
plt.show()
.. raw:: html
<br>
"""
print(__doc__)
# Author: Taylor Smith
import pmdarima as pm
from pmdarima import model_selection
import joblib # for persistence
import os
# #############################################################################
# Load the data and split it into separate pieces
y = pm.datasets.load_wineind()
train, test = model_selection.train_test_split(y, train_size=125)
# Fit an ARIMA
arima = pm.ARIMA(order=(1, 1, 2), seasonal_order=(0, 1, 1, 12))
arima.fit(y)
# #############################################################################
# Persist a model and create predictions after re-loading it
pickle_tgt = "arima.pkl"
try:
# Pickle it
joblib.dump(arima, pickle_tgt, compress=3)
# Load the model up, create predictions
arima_loaded = joblib.load(pickle_tgt)
preds = arima_loaded.predict(n_periods=test.shape[0])
print(__doc__)
# Author: Taylor Smith
import numpy as np
import pmdarima as pm
from pmdarima import pipeline
from pmdarima import model_selection
from pmdarima import preprocessing as ppc
from pmdarima import arima
from matplotlib import pyplot as plt
print("pmdarima version: %s" % pm.__version__)
# Load the data and split it into separate pieces
data = pm.datasets.load_wineind()
train, test = model_selection.train_test_split(data, train_size=150)
# Let's create a pipeline with multiple stages... the Wineind dataset is
# seasonal, so we'll include a FourierFeaturizer so we can fit it without
# seasonality
pipe = pipeline.Pipeline([
("fourier", ppc.FourierFeaturizer(m=12, k=4)),
("arima", arima.AutoARIMA(stepwise=True, trace=1, error_action="ignore",
seasonal=False, # because we use Fourier
suppress_warnings=True))
])
pipe.fit(train)
print("Model fit:")
print(pipe)
.. raw:: html
<br>
"""
print(__doc__)
# Author: Taylor Smith
import numpy as np
import pmdarima as pm
from pmdarima import model_selection
print("pmdarima version: %s" % pm.__version__)
# Load the data and split it into separate pieces
data = pm.datasets.load_wineind()
train, test = model_selection.train_test_split(data, train_size=165)
# Even though we have a dedicated train/test split, we can (and should) still
# use cross-validation on our training set to get a good estimate of the model
# performance. We can choose which model is better based on how it performs
# over various folds.
model1 = pm.ARIMA(order=(2, 1, 1), seasonal_order=(0, 0, 0, 1))
model2 = pm.ARIMA(order=(1, 1, 2), seasonal_order=(0, 1, 1, 12))
cv = model_selection.SlidingWindowForecastCV(window_size=100, step=24, h=1)
model1_cv_scores = model_selection.cross_val_score(
model1, train, scoring='smape', cv=cv, verbose=2)
model2_cv_scores = model_selection.cross_val_score(
model2, train, scoring='smape', cv=cv, verbose=2)
# #############################################################################
# You can load the datasets via load_
lynx = pm.datasets.load_lynx()
print("Lynx array:")
print(lynx)
# You can also get a series, if you rather
print("\nLynx series head:")
print(pm.datasets.load_lynx(as_series=True).head())
# Several other datasets:
air_passengers = pm.datasets.load_airpassengers()
austres = pm.datasets.load_austres()
heart_rate = pm.datasets.load_heartrate()
wineind = pm.datasets.load_wineind()
woolyrnq = pm.datasets.load_woolyrnq()
import pmdarima as pm
# #############################################################################
# You can load the datasets via load_
lynx = pm.datasets.load_lynx()
print("Lynx array:")
print(lynx)
# You can also get a series, if you rather
print("\nLynx series head:")
print(pm.datasets.load_lynx(as_series=True).head())
# Several other datasets:
heart_rate = pm.datasets.load_heartrate()
wineind = pm.datasets.load_wineind()
woolyrnq = pm.datasets.load_woolyrnq()