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.
Note: 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
a pandas
dataframe data
with date-time index and constant time spacing
(i.e., its data.index.freq
attribute must not be None
).
Only numerical data is supported at this time.
You build a model by
from tsar import tsar
model = tsar(data=data, P=P, F=F)
where P
and 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,
the rank R
and the quadratic regularization parameter quadratic_regularization
.
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 (np.nan
).
Inference is performed with
prediction = model.predict(data=new_data, prediction_time=t)
where 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 t
minus P
steps in the past, to the time t
plus 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.