Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
<br>
"""
print(__doc__)
# Author: Taylor Smith
import pmdarima as pm
from pmdarima import model_selection
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt
import numpy as np
# #############################################################################
# Load the data and split it into separate pieces
data = pm.datasets.load_lynx()
train, test = model_selection.train_test_split(data, train_size=90)
# Fit a simple auto_arima model
modl = pm.auto_arima(train, start_p=1, start_q=1, start_P=1, start_Q=1,
max_p=5, max_q=5, max_P=5, max_Q=5, seasonal=True,
stepwise=True, suppress_warnings=True, D=10, max_D=10,
error_action='ignore')
# Create predictions for the future, evaluate on test
preds, conf_int = modl.predict(n_periods=test.shape[0], return_conf_int=True)
# Print the error:
print("Test RMSE: %.3f" % np.sqrt(mean_squared_error(test, preds)))
# #############################################################################
# Plot the points and the forecasts
<br>
"""
print(__doc__)
# Author: Taylor Smith
import numpy as np
import pmdarima as pm
from pmdarima import pipeline, preprocessing as ppc, 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 = data[:150], data[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
transparams=False,
suppress_warnings=True))
])
pipe.fit(train)
print("Model fit:")
print(pipe)
#Topic: TS - Arima lynx
#-----------------------------
#libraries
#https://www.alkaline-ml.com/pmdarima/user_guide.html
import pmdarima as pm
#pip install pmdarima
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt
import numpy as np
#https://www.alkaline-ml.com/pmdarima/auto_examples/arima/example_auto_arima.html#sphx-glr-auto-examples-arima-example-auto-arima-py
##########################################################
# Load the data and split it into separate pieces
data = pm.datasets.load_lynx()
data
data.shape
train, test = data[:90], data[90:]
train.shape, test.shape
# Fit a simple auto_arima model
tsmodel = pm.auto_arima(train, start_p=1, start_q=1, start_P=1, start_Q=1, max_p=5, max_q=5, max_P=5, max_Q=5, seasonal=True, stepwise= True, suppress_warnings=True, D=10, max_D=10, error_action='ignore')
tsmodel
# Create predictions for the future, evaluate on test
preds, conf_int = tsmodel.predict(n_periods=test.shape[0], return_conf_int=True)
preds
conf_int
# Print the error:
test
preds
print("Test RMSE: %.3f" % np.sqrt(mean_squared_error(test, preds)))
used for benchmarking or experimentation. Pyramid has several built-in datasets
that exhibit seasonality, non-stationarity, and other time series nuances.
.. raw:: html
<br>
"""
print(__doc__)
# Author: Taylor Smith
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:
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()
# `decomposed_plot`
figure_kwargs = {'figsize': (6, 6)} # set figure size for both examples
#
# ADDITIVE EXAMPLE : ausbeer
#
# Decompose the ausbeer dataset into trend, seasonal and random parts.
# We subset to a small window of the time series.
head_index = 17*4+2
tail_index = 17*4-4
first_index = head_index - tail_index
last_index = head_index
ausbeer = datasets.load_ausbeer()
timeserie_beer = ausbeer[first_index:last_index]
decomposed = arima.decompose(timeserie_beer, 'additive', m=4)
# Plot the decomposed signal of ausbeer as a subplot
axes = utils.decomposed_plot(decomposed, figure_kwargs=figure_kwargs,
show=False)
axes[0].set_title("Ausbeer Seasonal Decomposition")
#
# MULTIPLICATIVE EXAMPLE: airpassengers
#
# Decompose the airpassengers dataset into trend, seasonal and random parts.
decomposed = arima.decompose(datasets.load_airpassengers(),