Module Reference

functions.r2(true, pred)

Coefficient of determination (R²)

functions.rmse(true, pred)

Root mean squared error

functions.mape(true, pred)

Mean absolute percentage error

functions.mae(true, pred)

Median absolute error

functions.pocid(true, pred)

Prediction on change of direction

functions.periodogram(x, *args, detrend='diff', **kwargs)

Return periodogram of signal x.

Parameters:
  • x (array_like) – A 1D signal.
  • detrend ('diff' or False or int) – Remove trend from x. If int, fit and subtract a polynomial of this order. See also: statsmodels.tsa.detrend.
  • kwargs (args,) – As accepted by scipy.signal.periodogram.
Returns:

  • periods (array_like) – The periods at which the spectral density is calculated.
  • pgram (array_like) – Power spectral density of x.

functions.periodogram_nonequispaced(times, x, *, freqs=None, period_low=None, period_high=None, n_periods=1000, detrend='linear')

Compute the Lomb-Scargle periodogram for non-equispaced timeseries.

Parameters:
  • times (array_like) – Sample times.
  • x (array_like) – A 1D signal.
  • freqs (array_like, optional) – Angular frequencies for output periodogram.
  • period_low (float) – If freqs not provided, the lowest period for which to look for periodicity. Defaults to 5th percentile of time difference between observations.
  • period_high (float) – If freqs not provided, the highest period for which to look for periodicity. Defaults to 80th percentile of time difference of observations, or 200*period_low, whichever is larger.
  • n_periods (int) – Number of periods between period_low and period_high to try.
  • detrend ('diff' or False or int) – Remove trend from x. If int, fit and subtract a polynomial of this order. See also: statsmodels.tsa.detrend.
Returns:

  • periods (array_like) – The periods at which the spectral density is calculated.
  • pgram (array_like) – Lomb-Scargle periodogram.

Notes

Read also: https://jakevdp.github.io/blog/2015/06/13/lomb-scargle-in-python/#lomb-scargle-algorithms-in-python

functions.autocorrelation(x, *args, unbiased=True, nlags=None, fft=True, **kwargs)

Return autocorrelation function of signal x.

Parameters:
  • x (array_like) – A 1D signal.
  • nlags (int) – The number of lags to calculate the correlation for (default .9*len(x))
  • fft (bool) – Compute the ACF via FFT.
  • kwargs (args,) – As accepted by statsmodels.tsa.stattools.acf.
Returns:

  • acf (array) – Autocorrelation function.
  • confint (array, optional) – Confidence intervals if alpha kwarg provided.

functions.partial_autocorrelation(x, *args, nlags=None, method='ldb', **kwargs)

Return partial autocorrelation function (PACF) of signal x.

Parameters:
  • x (array_like) – A 1D signal.
  • nlags (int) – The number of lags to calculate the correlation for (default: min(600, len(x)))
  • kwargs (args,) – As accepted by statsmodels.tsa.stattools.pacf.
Returns:

  • acf (array) – Partioal autocorrelation function.
  • confint (optional) – As returned by statsmodels.tsa.stattools.pacf.

functions.interpolate_timeseries(data, method='linear', multivariate=False)

Return a new Timeseries (Table) with nan values interpolated.

Parameters:
  • data (Orange.data.Table) – A table to interpolate.
  • method (str {'linear', 'cubic', 'nearest', 'mean'}) – The interpolation method to use.
  • multivariate (bool) – Whether to perform multivariate (2d) interpolation first. Univariate interpolation of same method is always performed as a final step.
Returns:

series – A table with nans in original replaced with interpolated values.

Return type:

Timeseries

functions.seasonal_decompose(data, model='multiplicative', period=12, *, callback=None)

Return table of decomposition components of original features and original features seasonally adjusted.

Parameters:
  • data (Timeseries) – A table of featres to decompose/adjust.
  • model (str {'additive', 'multiplicative'}) – A decompostition model. See: https://en.wikipedia.org/wiki/Decomposition_of_time_series
  • period (int) – The period length of season.
  • callback (callable) – Optional callback to call (with no parameters) after each iteration.
Returns:

table – Table with columns: original series seasonally adjusted, original series’ seasonal components, trend components, and residual components.

Return type:

Timeseries

functions.granger_causality(data, max_lag=10, alpha=0.05, *, callback=None)

Return results of Granger-causality tests.

Parameters:
  • data (Timeseries) – A table of features to compute Granger causality between.
  • max_lag (int) – The maximum lag to compute Granger-causality for.
  • alpha (float in (0, 1)) – Confidence of test is 1 - alpha.
  • callback (callable) – A callback to call in each iteration with ratio of completion.
Returns:

res – Each internal list is [lag, antecedent, consequent] where lag is the minimum lag at which antecedent feature in data is Granger-causal for the consequent feature in data.

Return type:

list of lists

functions.moving_transform(data, spec, fixed_wlen=0)

Return data transformed according to spec.

Parameters:
  • data (Timeseries) – A table with features to transform.
  • spec (list of lists) – A list of lists [feature:Variable, window_length:int, function:callable].
  • fixed_wlen (int) – If not 0, then window_length in spec is disregarded and this length is used. Also the windows don’t shift by one but instead align themselves side by side.
Returns:

transformed – A table of original data its transformations.

Return type:

Timeseries

functions.model_evaluation(data, models, n_folds, forecast_steps, *, callback=None)

Evaluate models on data.

Parameters:
  • data (Timeseries) – The timeseries to model. Must have a class variable that is used for prediction and scoring.
  • models (list) – List of models (objects with fit() and predict() methods) to try.
  • n_folds (int) – Number of iterations.
  • forecast_steps (int) – Number of forecast steps at each iteraction.
  • callback (callable, optional) – Optional argument-less callback to call after each iteration.
Returns:

results – A table with horizontal and vertical headers and results. Print it to see it.

Return type:

list of lists