pmdarima.arima.StepwiseContext

class pmdarima.arima.StepwiseContext(max_steps=None, max_dur=None)[source][source]

Context manager to capture runtime context for stepwise mode.

StepwiseContext allows one to call auto_arima() in the context of a runtime configuration that offers additional level of control required in certain scenarios. Use cases that are either sensitive to duration and/or the number of attempts to find the best fit can use StepwiseContext to control them.

Parameters:

max_steps : int, optional (default=100)

The maximum number of steps to try to find a best fit. When the number of tries exceed this number, the stepwise process will stop and the best fit model at that time will be returned.

max_dur : int, optional (default=None)

The maximum duration in seconds to try to find a best fit. When the cumulative fit duration exceeds this number, the stepwise process will stop and the best fit model at that time will be returned. Please note that this is a soft limit.

Notes

Although the max_steps parameter is set to a default value of None here, the stepwise search is limited to 100 tries to find a best fit model. Defaulting the parameter to None here preserves the intention of the caller and properly handles the nested contexts, like:

>>> with StepwiseContext(max_steps=10):
...     with StepwiseContext(max_dur=30):
...         auto_arima(sample, stepwise=True, ...)

In the above example, the stepwise search will be limited to either a maximum of 10 steps or a maximum duration of 30 seconds, whichever occurs first and the best fit model at that time will be returned

Methods

get_type() Get the ContextType
items()
keys()
update(other)
values()
__init__(max_steps=None, max_dur=None)[source][source]

Initialize self. See help(type(self)) for accurate signature.

get_type()[source][source]

Get the ContextType