Orange3-Timeseries Documentation: Release

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Orange3-Timeseries Documentation

Release

February 12, 2017


Contents

1 Widgets 1

2 Python Scripting 29

3 Indices and tables 37

Python Module Index 39

i
ii
CHAPTER 1

Widgets

1.1 Yahoo Finance

Generate time series from Yahoo Finance stock market data.

1.1.1 Signals

Outputs

• Time series
Time series table of open, high, low, close (OHLC) prices, volume and adjusted close price.

1.1.2 Description

This widget fetches historical stock market data from Yahoo Finance and outputs it as a time series data table.

1
Orange3-Timeseries Documentation, Release

1. Stock (e.g. GOOG) or index (e.g. ^DJI) symbol you are interested in.
2. Date range you are interested in.
3. Desired resolution of the time series. Can be one of: daily, weekly, monthly, or dividends. The last option
outputs a table of dates when dividends were issued, along with their respective dividend amounts.

1.1.3 Example

Since the output data type is inherently a Table, you can connect it to wherever data table is expected.

1.2 As Timeseries

Reinterpret Table object as a Timeseries object.

2 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.2.1 Signals

Inputs

• Data
Any data table.

Outputs

• Time series
Data table reiterpreted as time series.

1.2.2 Description

This widget reinterprets any data table as a time series, so it can be used with the rest of the widgets in this add-on.
In the widget, you can set which data attribute represents the time variable.

1. The time attribute, the values of which imply measurements order and spacing. This can be any continuous
attribute.
2. Alternatively, you can specify that the time series sequence is implied by instance order.

1.2.3 Example

The input to this widget comes from any data-emitting widget, e.g. File widget. Note, whenever you do some
processing with Orange core widgets, like the Select Columns widget, you need to re-apply the conversion into time
series with this widget.

1.3. Interpolate 3
Orange3-Timeseries Documentation, Release

1.3 Interpolate

Induce missing values in the time series by interpolation.

1.3.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

Outputs

• Time series
The input time series but preset with chosen default interpolation method for when algorithms require interpo-
lated time series (without missing values).
• Interpolated time series
The input time series with any missing values interpolated according to chosen interpolation method.

1.3.2 Description

Most time series algorithms assume, you don’t have any missing values in your data. In this widget, you can chose
the interpolation method to impute the missing values with. By default, it’s linear interpolation (fast and reasonable
default).

4 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1. Interpolation type. You can select one of linear, cubic spline, nearest, or mean interpolation. Linear interpo-
lation replaces missing values with linearly-spaced values between the two nearest defined data points. Spline
interpolation fits a cubic polynomial to the points around missing values. This is a painfully slow method that
usually gives best results. Nearest interpolation replaces missing values with the previous defined value. Mean
interpolation replaces missing values with the series mean.
2. Select Multi-variate interpolation to interpolate the whole series table as a two-dimensional plane instead of
as separate single-dimensional series.

Note: Missing values on the series’ end points (head and tail) are always interpolated using nearest method.

Note: Unless the interpolation method is set to nearest, discrete time series (i.e. sequences) are always imputed with
the series mode (most frequent value).

1.3.3 Example

Pass a time series with missing values in, get interpolated time series out.

1.4 Aggregate

Aggregate data by second, minute, hour, day, week, month, or year.

1.4.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

Outputs

• Time series
Aggregated time series.

1.4.2 Description

1. Interval to aggregate the time series by. Options are: second, minute, hour, say, week, month, or year.
2. Aggregation function for each of the time series in the table.

Note: Discrete variables (sequences) can only be aggregated using mode (i.e. most frequent value), whereas string
variables can only be aggregated using string concatenation.

1.4. Aggregate 5
Orange3-Timeseries Documentation, Release

6 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.4.3 See also

Moving Transform

1.5 Difference

Make the time series stationary by replacing it with 1st or 2nd order discrete difference along its values.

1.5.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

Outputs

• Time series
Differenced time series.

1.5. Difference 7
Orange3-Timeseries Documentation, Release

1.5.2 Description

1. Order of differencing. Can be 1 or 2.


2. The shift before differencing. Value of 1 equals to discrete differencing. You can use higher values to compute
the difference between now and this many steps ahead.
3. Invert the differencing direction.
4. Select the series to difference.

Note: To integrate the differences back into the original series (e.g. the forecasts), use the Moving Transform widget.

1.6 Seasonal Adjustment

Decompose the time series into seasonal, trend, and residual components.

8 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.6.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

Outputs

• Time series
Original time series with some additional columns: seasonal component, trend component, residual component,
and seasonally adjusted time series.

1.6.2 Description

1. Length of the season in periods (e.g. 12 for monthly data).


2. Time series decomposition model, additive or multiplicative.
3. The series to seasonally adjust.

1.6.3 See also

Moving Transform

1.6.4 Examples

1.7 Moving Transform

Apply rolling window functions to the time series. Use this widget to get a series’ mean.

1.7. Moving Transform 9


Orange3-Timeseries Documentation, Release

10 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.7.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

Outputs

• Time series
The input time series with added series transformations.

1.7.2 Description

In this widget, you define what aggregation functions to run over the time series and with what window sizes.

1. Define a new transformation.


2. Remove the selected transformation.
3. Time series you want to run the transformation over.
4. Desired window size.

1.7. Moving Transform 11


Orange3-Timeseries Documentation, Release

5. Aggregation function to aggregate the values in the window with. Options are: mean, sum, max, min, median,
mode, standard deviation, variance, product, linearly-weighted moving average, exponential moving average,
harmonic mean, geometric mean, non-zero count, cumulative sum, and cumulative product.
6. Select Non-overlapping windows options if you don’t want the moving windows to overlap but instead be placed
side-to-side with zero intersection.
7. In the case of non-overlapping windows, define the fixed window width (overrides and widths set in (4).

1.7.3 See also

Seasonal Adjustment

1.7.4 Example

To get a 5-day moving average, we can use a rolling window with mean aggregation.
To integrate a differenced time series, use Cumulative sum aggregation over a window wide enough to grasp the whole
series.

1.8 Correlogram

Visualize variables’ auto-correlation.

1.8.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

1.8.2 Description

In this widget, you can visualize the autocorrelation coefficients for selected time series.
1. Select the series to calculate autocorrelation for.
2. See the autocorrelation coefficients.
3. Choose to calculate the coefficients using partial autocorrelation function (PACF) instead.
4. Choose to plot the 95% significance interval (dotted horizontal line). Coefficients that reach outside of this
interval might be significant.

1.8.3 See also

Periodogram

12 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.8. Correlogram 13
Orange3-Timeseries Documentation, Release

14 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.9 Periodogram

Visualize time series’ cycles, seasonality, periodicity, and most significant periods.

1.9.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

1.9.2 Description

In this widget, you can visualize the most significant periods of the time series.
1. Select the series to calculate the periodogram for.
2. See the periods and their respective relative power spectral density estimates.

Note: Periodogram for non-equispaced series is calculated using Lomb-Scargle method.

1.9. Periodogram 15
Orange3-Timeseries Documentation, Release

1.9.3 See also

Correlogram

1.10 Line Chart

Visualize time series’ sequence and progression in the most basic time series visualization imaginable.

1.10.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.
• Forecast
Time series forecast as output by one of the models (like VAR or ARIMA).

1.10.2 Description

You can visualize the time series in this widget.


1. Stack a new line chart below the current charts.

16 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

2. Remove the associated stacked chart.


3. Type of chart to draw. Options are: line, step line, column, area, spline.
4. Switch between linear and logarithmic y axis.
5. Select the time series to preview (select multiple series using Ctrl key).
6. See the selected series in this area.

1.10.3 Example

Attach the model’s forecast to the Forecast input signal to preview it. The forecast is drawn with a dotted line and the
confidence intervals as an ranged area.

1.11 Spiralogram

Visualize variables’ auto-correlation.

1.11.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

1.11.2 Description

In this widget, you can visualize the autocorrelation coefficients for selected time series.

1.11. Spiralogram 17
Orange3-Timeseries Documentation, Release

18 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1. Unit of the vertical axis. Options are: years, months, or days (as present in the series); months of year, days of
week, days of month, days of year, weeks of year, weeks of month, hours of day, minutes of hour.
2. Unit of the radial axis (options are the same as for (1)).
3. Aggregation function. The series is aggregated on intervals selected in (1) and (2).
4. Select the series to include.

1.11.3 See also

Aggregate

1.11.4 Example

In the example image above that shows traffic for select French highways, we see a strong seasonal pattern (high
summer) and somewhat of an anomaly on July 1992. In this month, there was an important trucker strike in protest of
new road laws.

1.12 ARIMA Model

Model the time series using ARMA, ARIMA, or ARIMAX model.

1.12. ARIMA Model 19


Orange3-Timeseries Documentation, Release

1.12.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.
• Exogenous data
Time series of additional independent variables that can be used in an ARIMAX model.

Outputs

• Time series model


The ARIMA model fitted to input time series.
• Forecast
The forecast time series.
• Fitted values
The values that the model was actually fitted to, equals to original values - residuals.
• Residuals
The errors the model made at each step.

1.12.2 Description

Using this widget, you can model the time series with ARIMA model.
1. Model’s name. By default, the name is derived from the model and its parameters.
2. ARIMA p, d, q parameters.
3. Use exogenous data. Using this option, you need to connect additional series on the Exogenous data input
signal.
4. Number of forecast steps the model should output, along with the desired confidence intervals values at each
step.

1.12.3 See also

VAR Model, Model Evaluation

1.12.4 Example

1.13 VAR Model

Model the time series using vector autoregression (VAR) model.

20 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.13. VAR Model 21


Orange3-Timeseries Documentation, Release

22 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.13.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

Outputs

• Time series model


The VAR model fitted to input time series.
• Forecast
The forecast time series.
• Fitted values
The values that the model was actually fitted to, equals to original values - residuals.
• Residuals
The errors the model made at each step.

1.13.2 Description

Using this widget, you can model the time series using VAR model.
1. Model’s name. By default, the name is derived from the model and its parameters.
2. Desired model order (number of parameters).
3. If other than None, optimize the number of model parameters (up to the value selected in (2)) with the selected
information criterion (one of: AIC, BIC, HQIC, FPE, or a mix thereof).
4. Choose this option to add additional “trend” columns to the data. If Constant, a single column of ones is added.
If Constant and linear, a column of ones and a column of linearly increasing numbers are added. If Constant,
linear and quadratic, an additional column of quadratics is added.
5. Number of forecast steps the model should output, along with the desired confidence intervals values at each
step.

1.13.3 See also

ARIMA Model, Model Evaluation

1.13.4 Example

1.14 Model Evaluation

Evaluate different time series’ models by comparing the errors they make in terms of: root mean squared error (RMSE),
median absolute error (MAE), mean absolute percent error (MAPE), prediction of change in direction (POCID),
coefficient of determination (R²), Akaike information criterion (AIC), and Bayesian information criterion (BIC).

1.14. Model Evaluation 23


Orange3-Timeseries Documentation, Release

24 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.14. Model Evaluation 25


Orange3-Timeseries Documentation, Release

1.14.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.
• Time series model (multiple)
The time series model to evaluate (e.g. VAR or ARIMA).

1.14.2 Description

1. Number of folds for time series cross-validation.


2. Number of forecast steps to produce in each fold.
3. Results for various error measures and information criteria on cross-validated and in-sample data.

Note: This slide (source) shows how cross validation on time series is performed. In this case, the number of folds
(1) is 10 and the number of forecast steps in each fold (2) is 1.

Note: In-sample errors are the errors calculated on the training data itself. A stable model is one where in-sample
errors and out-of-sample errors don’t differ significantly.

1.14.3 See also

ARIMA Model, VAR Model

1.15 Granger Causality

Test if one time series Granger-causes (i.e. can be an indicator of) another time series.

26 Chapter 1. Widgets
Orange3-Timeseries Documentation, Release

1.15.1 Signals

Inputs

• Time series
Time series as output by As Timeseries widget.

1.15.2 Description

This widgets performs a series of statistical tests to determine the series that cause other series so we can use the
former to forecast the latter.

1. Desired level of confidence.


2. Maximum lag to test to.
3. Runs the test.
4. Denotes the minimum lag at which one series can be said to cause another. In the first line of the example above,
if we have the monthly unemployment rate time series for Austria, we can say something about unemployment
rate in Hungary 10 months ahead.
5. The causing (antecedent) series.
6. The effect (consequent) series.

Tip: The time series that Granger-cause the series you are interested in are good candidates to have in the same VAR
model.

Warning: Even if one series is said to Granger-cause another, this doesn’t mean there really exists a causal
relationship. Mind your conclusions.

1.15. Granger Causality 27


Orange3-Timeseries Documentation, Release

28 Chapter 1. Widgets
CHAPTER 2

Python Scripting

2.1 Scripting Tutorial

Start by importing the relevant objects:


>>> from orangecontrib.timeseries import *

Let’s load new Timeseries, for example:


>>> data = Timeseries('airpassengers')

Timeseries object is just an Orange.data.Table object with some extensions.


Find more info and function docstrings in the reference.

2.1.1 Periodicity

You can compute periodogram values using periodogram() or periodogram_nonequispaced() (Lomb-


Scargle) for non-uniformly spaced time series.
With our air passengers example, calculate the periodogram on the only data-bearing column, which also happens to
be a class variable:
>>> periods, pgram_values = periodogram(data.Y, detrend='diff')
>>> periods
array([ 2.38333333, 3.04255319, 3.97222222, 5.95833333, 11.91666667])
>>> pgram_values
array([ 0.14585092, 0.17023564, 0.23531016, 1. , 0.90136873])

Obviously, 6 and 12 are important periods for this data set.

2.1.2 Autocorrelation

Compute autocorrelation or partial autocorrelation coefficients using autocorrelation() or


partial_autocorrelation() functions. For example:
>>> acf = autocorrelation(data.Y)
>>> acf[:4]
array([[ 12. , 0.82952186],
[ 24. , 0.6386278 ],
[ 36. , 0.4493648 ],

29
Orange3-Timeseries Documentation, Release

[ 48. , 0.19895185]])
>>> pacf = partial_autocorrelation(data.Y)
>>> pacf[:4]
array([[ 9. , 0.23248854],
[ 13. , -0.53969124],
[ 25. , -0.16274616],
[ 40. , -0.08833969]])

2.1.3 Interpolation

Let’s say your data is missing some values:


>>> data.Y[7:11]
array([ 148., 136., 119., 104.])
>>> data.Y[7:11] = np.nan

You can interpolate those values with one of supported interpolation methods using
interpolate_timeseries() function:
>>> interpolated = interpolate_timeseries(data, method='cubic')
>>> interpolated[7:11].Y
array([ 151.22663433, 146.80661022, 137.77326894, 127.15995178])
>>> data = interpolated

2.1.4 Seasonal decomposition

To decompose the time series into trend, seasonal and residual components, use seasonal_decompose() func-
tion:
>>> passengers = Timeseries(Domain(['Air passengers'], source=data.domain), data)
>>> decomposed = seasonal_decompose(passengers, model='multiplicative', period=12)
>>> decomposed.domain
[Air passengers (season. adj.), Air passengers (seasonal), Air passengers (trend), Air passengers (re

To use this decomposed time series effectively, we just have to add back the time variable that was stripped in the first
step above:
>>> ts = Timeseries(Timeseries.concatenate((data, decomposed)))
>>> ts.time_variable = data.time_variable

Just kidding. Use statsmodels.seasonal.seasonal_decompose() instead.

2.1.5 Moving transform

It’s easy enough to apply moving windows transforms over any raw data in Python. In Orange3-Timeseries, you can
use moving_transform() function. It accepts a time series object and a transform specification (list of tuples
(Variable, window length, aggregation function)). For example:
>>> spec = [(data.domain['Air passengers'], 10, np.nanmean), ] # Just 10-year SMA
>>> transformed = moving_transform(data, spec)
>>> transformed.domain
[Month, Air passengers (10; nanmean) | Air passengers]
>>> transformed
[[1949-01-01, 112.000 | 112.000],
[1949-02-01, 115.000 | 118.000],

30 Chapter 2. Python Scripting


Orange3-Timeseries Documentation, Release

[1949-03-01, 120.667 | 132.000],


[1949-04-01, 122.750 | 129.000],
[1949-05-01, 122.400 | 121.000],
...
]

There are a couple of nan-safe aggregation functions available in orangecontrib.timeseries.agg_funcs


module.

2.1.6 Time series modelling and forecast

There are, as of yet, two models available: ARIMA and VAR. Both models have a common interface, so the usage of
one is similar to the other. Let’s look at an example. The data we model must have defined a class variable:
>>> data = Timeseries('airpassengers')
>>> data.domain
[Month | Air passengers]
>>> data.domain.class_var
ContinuousVariable(name='Air passengers', number_of_decimals=3)

We define the model with its parameters (see the reference for what arguments each model accepts):
>>> model = ARIMA((2, 1, 1))

Now we fit the data:


>>> model.fit(data)
<...ARIMA object at 0x...>

After fitting, we can get the forecast along with desired confidence intervals:
>>> forecast, ci95_low, ci95_high = model.predict(steps=10, alpha=.05)

We can also output the prediction as a Timeseries object:


>>> forecast = model.predict(10, as_table=True)
>>> forecast.domain
[Air passengers (forecast), Air passengers (95%CI low), Air passengers (95%CI high)]
>>> np.set_printoptions(precision=1)
>>> forecast.X
array([[ 470.5, 417.8, 523.2],
[ 492.6, 414.1, 571.1],
[ 498.5, 411.5, 585.4],
...
[ 492.7, 403. , 582.4],
[ 497.1, 407.3, 586.8]])

We can examine model’s fitted values and residuals with appropriately-named methods:
>>> model.fittedvalues(as_table=False)
array([ 114.7, 121.7, ..., 440.4, 386.8])
>>> model.residuals(as_table=False)
array([ 3.3, 10.3, ..., -50.4, 45.2])

We can evaluate the model on in-sample, fitted values:


>>> for measure, error in sorted(model.errors().items()):
... print('{:7s} {:>6.2f}'.format(measure.upper(), error))
MAE 19.67

2.1. Scripting Tutorial 31


Orange3-Timeseries Documentation, Release

MAPE 0.08
POCID 58.45
R2 0.95
RMSE 27.06

Finally, one should more robustly evaluate their models using cross validation. An example, edited for some clarity:
>>> models = [ARIMA((1, 1, 0)), ARIMA((2, 1, 2)), VAR(1), VAR(3)]
>>> model_evaluation(data, models, n_folds=10, forecast_steps=3)
[['Model', 'RMSE', 'MAE', 'MAPE', 'POCID', 'R²', 'AIC', 'BIC'],
['ARIMA(1,1,0)', 47.318, 36.803, 0.093, 68.965, 0.625, 1059.3, 1067.4],
['ARIMA(1,1,0) (in-sample)', 32.040, 20.340, 0.089, 58.450, 0.927, 1403.4, 1412.3],
['ARIMA(2,1,2)', 44.659, 28.332, 0.075, 72.413, 0.666, 1032.8, 1049.2],
['ARIMA(2,1,2) (in-sample)', 25.057, 16.159, 0.070, 59.859, 0.955, 1344.0, 1361.8],
['VAR(1)', 63.185, 45.553, 0.118, 68.965, 0.332, 28.704, 28.849],
['VAR(1) (in-sample)', 31.316, 19.001, 0.084, 54.929, 0.930, 29.131, 29.255],
['VAR(3)', 46.210, 28.526, 0.085, 82.758, 0.643, 28.140, 28.482],
['VAR(3) (in-sample)', 25.642, 18.010, 0.072, 61.428, 0.953, 28.406, 28.698]]

2.1.7 Granger Causality

Use granger_causality() to estimate causality between series. A synthetic example:


>>> series = np.arange(100)
>>> X = np.column_stack((series, np.roll(series, 1), np.roll(series, 3)))
>>> threecol = Timeseries(Domain.from_numpy(X), X)
>>> for lag, ante, cons in granger_causality(threecol, 10):
... if lag > 1:
... print('Series {cons} lags by {ante} by {lag} lags.'.format(**locals()))
...
Series Feature 1 lags by Feature 2 by 5 lags.
Series Feature 1 lags by Feature 3 by 4 lags.
Series Feature 2 lags by Feature 3 by 2 lags.

Use this knowledge wisely.

2.2 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

32 Chapter 2. Python Scripting


Orange3-Timeseries Documentation, Release

• 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, pe-
riod_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*pe-
riod_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.

2.2. Module Reference 33


Orange3-Timeseries Documentation, Release

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 interpola-
tion method to use.
• multivariate (bool) – Whether to perform multivariate (2d) interpolation first. Uni-
variate 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 itera-
tion.
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.

34 Chapter 2. Python Scripting


Orange3-Timeseries Documentation, Release

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, func-
tion: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

2.2. Module Reference 35


Orange3-Timeseries Documentation, Release

36 Chapter 2. Python Scripting


CHAPTER 3

Indices and tables

• genindex
• modindex
• search

37
Orange3-Timeseries Documentation, Release

38 Chapter 3. Indices and tables


Python Module Index

f
functions, 32

39
Orange3-Timeseries Documentation, Release

40 Python Module Index


Index

A
autocorrelation() (in module functions), 33

F
functions (module), 32

G
granger_causality() (in module functions), 34

I
interpolate_timeseries() (in module functions), 34

M
mae() (in module functions), 32
mape() (in module functions), 32
model_evaluation() (in module functions), 35
moving_transform() (in module functions), 35

P
partial_autocorrelation() (in module functions), 33
periodogram() (in module functions), 32
periodogram_nonequispaced() (in module functions), 33
pocid() (in module functions), 32

R
r2() (in module functions), 32
rmse() (in module functions), 32

S
seasonal_decompose() (in module functions), 34

41

You might also like