Package: pmdarima
pmdarimaPmdarima (originallypyramid-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'sauto.arimafunctionalityA collection of statistical tests of stationarity and seasonalityTime series utilities, such as differencing and inverse differencingNumerous endogenous and exogenous transformers and featurizers, including Box-Cox and Fourier transformationsSeasonal time series decompositionsCross-validation utilitiesA rich collection of built-in time series datasets for prototyping and examplesScikit-learn-esque pipelines to consolidate your estimators and promote productionizationPmdarima wrapsstatsmodelsunder the hood, but is designed with an interface that's familiar to users coming
from a scikit-learn background.InstallationpipPmdarima has binary and source distributions for Windows, Mac and Linux (manylinux) on pypi
under the package namepmdarimaand can be downloaded viapip:pipinstallpmdarimacondaPmdarima also has Mac and Linux builds available viacondaand can be installed like so:condaconfig--addchannelsconda-forge
condaconfig--setchannel_prioritystrict
condainstallpmdarimaNote:We do not maintain our own Conda binaries, they are maintained athttps://github.com/conda-forge/pmdarima-feedstock.
See that repo for further documentation on working with Pmdarima on Conda.Quickstart ExamplesFitting a simple auto-ARIMA on thewineinddataset:importpmdarimaaspmfrompmdarima.model_selectionimporttrain_test_splitimportnumpyasnpimportmatplotlib.pyplotasplt# Load/split your datay=pm.datasets.load_wineind()train,test=train_test_split(y,train_size=150)# Fit your modelmodel=pm.auto_arima(train,seasonal=True,m=12)# make your forecastsforecasts=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()Fitting a more complex pipeline on thesunspotsdataset,
serializing it, and then loading it from disk to make predictions:importpmdarimaaspmfrompmdarima.model_selectionimporttrain_test_splitfrompmdarima.pipelineimportPipelinefrompmdarima.preprocessingimportBoxCoxEndogTransformerimportpickle# Load/split your datay=pm.datasets.load_sunspots()train,test=train_test_split(y,train_size=2700)# Define and fit your pipelinepipeline=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:withopen('model.pkl','wb')aspkl:pickle.dump(pipeline,pkl)# Load it and make predictions seamlessly:withopen('model.pkl','rb')aspkl: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]Availabilitypmdarimais 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.10If a wheel doesn't exist for your platform, you can stillpip installand it
will build from the source distribution tarball, however you'll needcython>=0.29andgcc(Mac/Linux) orMinGW(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:$pipinstallpyramid-arima# python -c 'import pyramid;'However, this is not recommended.DocumentationAll of your questions and more (including examples and guides) can be answered by
thepmdarimadocumentation. If not, always
feel free to file an issue.