Skip to main content

Python's forecast::auto.arima equivalent

Project description

pmdarima

PyPI version CircleCI Github Actions Status codecov Supported versions Downloads Downloads/Week

Pmdarima (originally pyramid-arima, for the anagram of 'py' + 'arima') is a statistical library designed to fill the void in Python's time series analysis capabilities. This includes:

  • The equivalent of R's auto.arima functionality
  • A collection of statistical tests of stationarity and seasonality
  • Time series utilities, such as differencing and inverse differencing
  • Numerous endogenous and exogenous transformers and featurizers, including Box-Cox and Fourier transformations
  • Seasonal time series decompositions
  • Cross-validation utilities
  • A rich collection of built-in time series datasets for prototyping and examples
  • Scikit-learn-esque pipelines to consolidate your estimators and promote productionization

Pmdarima wraps statsmodels under the hood, but is designed with an interface that's familiar to users coming from a scikit-learn background.

Installation

pip

Pmdarima has binary and source distributions for Windows, Mac and Linux (manylinux) on pypi under the package name pmdarima and can be downloaded via pip:

pip install pmdarima

conda

Pmdarima also has Mac and Linux builds available via conda and can be installed like so:

conda config --add channels conda-forge
conda config --set channel_priority strict
conda install pmdarima

Note: We do not maintain our own Conda binaries, they are maintained at https://github.com/conda-forge/pmdarima-feedstock. See that repo for further documentation on working with Pmdarima on Conda.

Quickstart Examples

Fitting a simple auto-ARIMA on the wineind dataset:

import pmdarima as pm
from pmdarima.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt

# Load/split your data
y = pm.datasets.load_wineind()
train, test = train_test_split(y, train_size=150)

# Fit your model
model = pm.auto_arima(train, seasonal=True, m=12)

# make your forecasts
forecasts = model.predict(test.shape[0])  # predict N steps into the future

# Visualize the forecasts (blue=train, green=forecasts)
x = np.arange(y.shape[0])
plt.plot(x[:150], train, c='blue')
plt.plot(x[150:], forecasts, c='green')
plt.show()
Wineind example

Fitting a more complex pipeline on the sunspots dataset, serializing it, and then loading it from disk to make predictions:

import pmdarima as pm
from pmdarima.model_selection import train_test_split
from pmdarima.pipeline import Pipeline
from pmdarima.preprocessing import BoxCoxEndogTransformer
import pickle

# Load/split your data
y = pm.datasets.load_sunspots()
train, test = train_test_split(y, train_size=2700)

# Define and fit your pipeline
pipeline = Pipeline([
    ('boxcox', BoxCoxEndogTransformer(lmbda2=1e-6)),  # lmbda2 avoids negative values
    ('arima', pm.AutoARIMA(seasonal=True, m=12,
                           suppress_warnings=True,
                           trace=True))
])

pipeline.fit(train)

# Serialize your model just like you would in scikit:
with open('model.pkl', 'wb') as pkl:
    pickle.dump(pipeline, pkl)
    
# Load it and make predictions seamlessly:
with open('model.pkl', 'rb') as pkl:
    mod = pickle.load(pkl)
    print(mod.predict(15))
# [25.20580375 25.05573898 24.4263037  23.56766793 22.67463049 21.82231043
# 21.04061069 20.33693017 19.70906027 19.1509862  18.6555793  18.21577243
# 17.8250318  17.47750614 17.16803394]

Availability

pmdarima is available on PyPi in pre-built Wheel files for Python 3.7+ for the following platforms:

  • Mac (64-bit)
  • Linux (64-bit manylinux)
  • Windows (64-bit)
    • 32-bit wheels are available for pmdarima versions below 2.0.0 and Python versions below 3.10

If a wheel doesn't exist for your platform, you can still pip install and it will build from the source distribution tarball, however you'll need cython>=0.29 and gcc (Mac/Linux) or MinGW (Windows) in order to build the package from source.

Note that legacy versions (<1.0.0) are available under the name "pyramid-arima" and can be pip installed via:

# Legacy warning:
$ pip install pyramid-arima
# python -c 'import pyramid;'

However, this is not recommended.

Documentation

All of your questions and more (including examples and guides) can be answered by the pmdarima documentation. If not, always feel free to file an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pmdarima-2.0.0.tar.gz (630.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pmdarima-2.0.0-cp310-cp310-win_amd64.whl (568.8 kB view details)

Uploaded CPython 3.10Windows x86-64

pmdarima-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pmdarima-2.0.0-cp310-cp310-macosx_11_0_x86_64.whl (607.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

pmdarima-2.0.0-cp39-cp39-win_amd64.whl (608.1 kB view details)

Uploaded CPython 3.9Windows x86-64

pmdarima-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pmdarima-2.0.0-cp39-cp39-macosx_11_0_x86_64.whl (608.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

pmdarima-2.0.0-cp38-cp38-win_amd64.whl (606.7 kB view details)

Uploaded CPython 3.8Windows x86-64

pmdarima-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pmdarima-2.0.0-cp38-cp38-macosx_11_0_x86_64.whl (601.1 kB view details)

Uploaded CPython 3.8macOS 11.0+ x86-64

pmdarima-2.0.0-cp37-cp37m-win_amd64.whl (601.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

pmdarima-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pmdarima-2.0.0-cp37-cp37m-macosx_11_0_x86_64.whl (601.1 kB view details)

Uploaded CPython 3.7mmacOS 11.0+ x86-64

File details

Details for the file pmdarima-2.0.0.tar.gz.

File metadata

  • Download URL: pmdarima-2.0.0.tar.gz
  • Upload date:
  • Size: 630.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.9

File hashes

Hashes for pmdarima-2.0.0.tar.gz
Algorithm Hash digest
SHA256 e0127b5ad1578d87cb300b250e84f9c4035009b774a08976b3808e4b57bad457
MD5 0d958a086c1cb81b11179db1e78a3215
BLAKE2b-256 ae50a531afd52b2541b26f92a9c614b504460ad49a4bde1ece928f95287fa1ec

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pmdarima-2.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 568.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for pmdarima-2.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 29325bd4946283a92fcfa557f790808267784f57e1554e309e7ff47df2a2c72c
MD5 9adbecffd381575762df7cd86ad502b9
BLAKE2b-256 5a7ac41cf14dfaa05a02582a182c77047f66ebe24eb323224ed86bb561675992

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 133fa5a4ed7d36c26c37afdcbc48d1292783fd5c57a1ebb61328f33fef643521
MD5 4118211b8efead598f12a0d191aafc1f
BLAKE2b-256 dd42f4f783cafc70395098450f24e5d4128adffdd4a7ba0e4d9578a7e5c0ebc5

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 bdd61717b3150386c728f7f5020306b09dbd8201c66a3645a5960e8b5a2e7567
MD5 21ecc6c667f8eb7c2036083c6f6cb459
BLAKE2b-256 a3171f498e7e22e7c3641d6c69f5f762bf03f883898b93191652b0530b64b054

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pmdarima-2.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 608.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pmdarima-2.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 866aa14c80ecfc3d4ddc13b7464ca166cd01d0ba4fb5458c93097ab33feb343c
MD5 88113a005d115d28b9911148a24b1286
BLAKE2b-256 5d04b66f8bd1efd1fe5ef4805a2cc10aea0c704ab63532e0defbce4201a92efa

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a96dfaca678838defb85b5e4e4691f9d3dc75f345cbea132337a02dd5d61f2a6
MD5 f0b969c0169afdf93223f8a57e183c57
BLAKE2b-256 26938c66b5cf1a3a1f105b4c828392ce848037e39c21ede60d5fd25bfc1ad421

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 d55b00b51da1b458047f61e45118d64455826a257d5928040508b9d367b68d3d
MD5 4893f7186cddb76f946bf0a0e93da49d
BLAKE2b-256 c901de1304c9470c376cdb5116ce54e599bfde8ffda554336254eaa10ebce5f8

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pmdarima-2.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 606.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for pmdarima-2.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 992b077976cf0e6166e5dc638123755b3de59363328ff74d81709110409f9e8a
MD5 4f3147f280b7638e1b885a86c3c17086
BLAKE2b-256 58dd1cf20d4b9c6c1c7a561fc54f42cdd0bab4ae081330b0312f390477e88a1f

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a7bf56bf0030d8c77ca0804d56a37c5b48d04292738d7e5663513cfeedf5fdec
MD5 6d58c5a168621b608488c2d34537695e
BLAKE2b-256 382323a21842a8aa85e5f6f0ce54f6c74c824ca5e31aa0e7f19b3437f177d854

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f2cb3e53fe43b972f79909f6f58788e3083a44906eff6232acf122c5440b85ef
MD5 f1be403b2ed60f2e17dd7e5ed44557cb
BLAKE2b-256 c769167adc583c928650ff3136d85af2a1236c77257e500b65cccaaa87d554be

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pmdarima-2.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 601.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.9

File hashes

Hashes for pmdarima-2.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 66382a688c713c49538767bb0e7fc389ae81f5e2437dc2d8264f8678acd5e0f4
MD5 3fdee5d0fcd0b76205e5b7e72618cd8f
BLAKE2b-256 7d0b95949f9b951a2845c0a9ba6cf4cb29a80c0d07227c21a13050d0065c088f

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1b2e5d2f73e93ea818eb146b3fc708cee9d6c729aa8d7f597072607f147fc563
MD5 6d5e01a3645b614453ae3f2c394f793b
BLAKE2b-256 7f17559cce0a7662dab5633b4c099b33c085293e1700780b1473ab7c400d0a5e

See more details on using hashes here.

File details

Details for the file pmdarima-2.0.0-cp37-cp37m-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for pmdarima-2.0.0-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 62cbfb37878713996447935fc03d1ee06fd7e443cee68a9fbbcda61c8691fb9d
MD5 8ba666dd4f5d42d917efe628b3ef3f57
BLAKE2b-256 60a9c110bc40c82a17e015055f5b502692ef1044a960ea326e60f63fd911f2c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page