tsar: time series auto-regressor
tsar is a Python library to model and forecast time series data. It operates on
pandas dataframes and uses
numba just-in-time compilation
to speed up some operations.
The core algorithm used is described in the draft paper Seasonally-Adjusted Auto-Regression of Vector Time Series, E. Busseti, November 2019.
tsar is currently in beta release, its interface might change.
To install, execute in a terminal
pip install tsar
To use it, you need some time series data as
data with date-time index and constant time spacing
data.index.freq attribute must not be
Only numerical data is supported at this time.
Build a model
You build a model by
from tsar import tsar model = tsar(data=data, P=P, F=F)
F are positive integers representing
how many points in the past will be used for inference,
and how many steps in the future will be predicted, respectively.
If you wish, you can pass to the constructor any hyper-parameter of the model, for example,
R and the quadratic regularization parameter
If not specified, these will be optimized by greedy grid search (see the paper)
on an internally split test set.
The data can have any amount of missing values (
Inference is performed with
prediction = model.predict(data=new_data, prediction_time=t)
new_data is a dataframe with the same column names and time spacing than the one
used to build the model, and prediction_time is the timestamp at which to infer.
The resulting prediction dataframe has time index spanning
from the time
P steps in the past, to the time
F steps in the future.
Any data that was present (and not equal to
np.nan) in the
new_data dataframe will be copied to the
appropriate position in the
prediction dataframe. All other points will be inferred.
The provided data can have any amount of missing values, the prediction has none.