In [8]:
import pmdarima
from pmdarima.datasets import load_wineind
wineind = load_wineind()
print("Pyramid version: %s" % pmdarima.__version__)
In [9]:
import numpy as np
import gc
from datetime import datetime
import matplotlib.pyplot as plt
%matplotlib inline
# to store the results
stepwise_results = []
grid_results = []
mu_second = 0.0 + 10 ** 6 # number of microseconds in a second
In [10]:
def benchmark(x, results, **kwargs):
from pmdarima.arima import auto_arima
gc.collect()
# start
tstart = datetime.now()
auto_arima(x, **kwargs)
delta = datetime.now() - tstart
# stop
results.append(delta.seconds + delta.microseconds / mu_second)
In [11]:
def fit_benchmark(**kwargs):
# pop these, since we'll manually assign
kwargs.pop('stepwise', None)
kwargs.pop('n_jobs', None)
for stepwise, results in ((True, stepwise_results), (False, grid_results)):
benchmark(wineind, results, **kwargs)
def plot_benchmarks():
plt.figure('auto_arima benchmark results')
xx = len(stepwise_results)
plt.scatter(x=xx, y=stepwise_results, label='stepwise')
plt.scatter(x=xx, y=grid_results, label='grid')
plt.legend(loc='upper left')
plt.ylabel('Time (s)')
plt.show()
# fit with all default args
fit_benchmark(suppress_warnings=True)
plot_benchmarks()
In [ ]: