hypertools.predict

hypertools.predict(data, model='Kalman', t=10, return_model=False, **kwargs)[source]

Forecast t new rows continuing each input dataset.

Parameters:
dataDataFrame/array or list/tuple of these

Dataset(s) to forecast from, each shaped (n_observations, n_features) with at least 2 observations (rows). A 1-D array, a flat list of numbers, or a pandas Series is treated as a UNIVARIATE timeseries – n observations of 1 feature, i.e. an (n, 1) column – matching hyp.plot/format_data’s convention; a tuple of datasets is treated exactly like a list. Degenerate inputs (None, a scalar, empty data, fewer than 2 rows) raise a clear error instead of returning meaningless forecasts.

modelstr, dict, class, or Forecaster instance

Which forecaster to use (default: ‘Kalman’). A string is one of FORECASTERS’ names (Kalman, GaussianProcess, AutoRegressor, ARIMA, Laplace, Chronos); the short alias ‘GP’ also resolves to GaussianProcess, and names are matched case-insensitively (‘kalman’ works too). A dict may be {'model': ..., 'params': {...}} (deprecated) or {'model': ..., 'args': [...], 'kwargs': {...}}. A class or an already-constructed (unfitted) instance is used directly. An ALREADY-FITTED Forecaster instance (returned from a previous return_model=True call) is applied to data via predict_new (its learned parameters are reused – not re-estimated).

Note that the models’ default configurations suit different signals: Kalman/AutoRegressor/GaussianProcess track oscillatory and trending data out of the box, while ARIMA(1, 1, 1) and Laplace defaults only suit drift/random-walk-like signals (see hypertools.predict.arima / hypertools.predict.laplace).

NaN policy: Kalman, ARIMA, and Chronos tolerate missing (NaN) entries; GaussianProcess, AutoRegressor, and Laplace raise a clear ValueError (fill missing values first, e.g. with hyp.impute).

tint or datetime-like

Forecast horizon (see hypertools.predict.common.resolve_t). A datetime-like t at or before the data’s last timestamp truncates the history up to t instead of forecasting; a t BEFORE the data’s first timestamp raises a ValueError (there is no data to truncate to and nothing to forecast – it used to silently return an empty frame).

return_modelbool

If True, also return the fitted (or reused) Forecaster instance, so it can be passed back as model= on future calls with new data (default: False).

**kwargs

Passed through to the forecaster’s constructor when model resolves to a name, class, or dict spec (merged into a dict spec’s own kwargs, with these outer values winning). When model is already a constructed instance they cannot be applied, and a warning is raised. Unknown parameter names raise TypeError (typos used to be swallowed silently for some models).

Returns:
forecasts (and the fitted Forecaster if return_model=True). Lists in,
lists out: a single input dataset returns a single forecast DataFrame.

Examples

>>> import numpy as np
>>> import hypertools as hyp
>>> x = np.cumsum(np.random.default_rng(0).standard_normal((40, 3)),
...               axis=0)
>>> forecast = hyp.predict(x, model='Kalman', t=5)
>>> forecast.shape
(5, 3)