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 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)
MAINTAINER = 'Taylor G. Smith'
MAINTAINER_GIT = 'tgsmith61591'
MAINTAINER_EMAIL = 'taylor.smith@alkaline-ml.com'
LICENSE = 'MIT'
URL = 'http://alkaline-ml.com/pmdarima'
DOWNLOAD_URL = 'https://pypi.org/project/pmdarima/#files'
PROJECT_URLS = {
'Bug Tracker': 'https://github.com/alkaline-ml/pmdarima/issues',
'Documentation': URL,
'Source Code': 'https://github.com/alkaline-ml/pmdarima'
}
# import restricted version of pmdarima that does not need the compiled code
import pmdarima
VERSION = pmdarima.__version__ # will be 0.0.0 unless tagging
# get the installation requirements:
with open('requirements.txt') as req:
REQUIREMENTS = [l for l in req.read().split(os.linesep) if l]
print("Requirements: %r" % REQUIREMENTS)
# Optional setuptools features
SETUPTOOLS_COMMANDS = { # this is a set literal, not a dict
'develop', 'release', 'bdist_egg', 'bdist_rpm',
'bdist_wininst', 'install_egg_info', 'build_sphinx',
'egg_info', 'easy_install', 'upload', 'bdist_wheel',
'--single-version-externally-managed',
# scikit does NOT do this:
'sdist,'
}
as similarly as possible to that of scikit to make its usage as simple as
possible.
.. 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)
which greatly simplifies your life.
.. raw:: html
<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))
])
def _warn_for_older_version(self):
# Added in v0.8.1 - check for the version pickled under and warn
# if it's different from the current version
do_warn = False
modl_version = None
this_version = pmdarima.__version__
try:
modl_version = getattr(self, 'pkg_version_')
# Either < or > or '-dev' vs. release version
if modl_version != this_version:
do_warn = True
except AttributeError:
# Either wasn't fit when pickled or didn't have the attr due to
# it being an older version. If it wasn't fit, it will be missing
# the arima_res_ attr.
if hasattr(self, 'arima_res_'): # it was fit, but is older
do_warn = True
modl_version = '<0.8.1'
# else: it may not have the model (not fit) and still be older,
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'pmdarima'
year = datetime.datetime.now().year
copyright = '2017-{0}, Taylor G Smith'.format(year)
author = 'Taylor G Smith'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = str(parse_version(pmdarima.__version__))
# The full version, including alpha/beta/rc tags.
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
else:
fit, self.arima_res_ = _fit_wrapper()
# Set df_model attribute for SARIMAXResults object
sm_compat.bind_df_model(fit, self.arima_res_)
# if the model is fit with an exogenous array, it must
# be predicted with one as well.
self.fit_with_exog_ = exogenous is not None
# Save nobs since we might change it later if using OOB
self.nobs_ = y.shape[0]
# As of version 0.7.2, start saving the version with the model so
# we can track changes over time.
self.pkg_version_ = pmdarima.__version__
return self