Module Reference
- class timeseries.TimeDelta(time_values)
- class timeseries.Timeseries(*args, **kwargs)
- copy()
Return a copy of the table
- classmethod from_data_table(table, time_attr=None)
- classmethod convert_from_data_table(table, time_attr=None)
Create TimeSeries and re-assign the original arrays to the new table
The goal of this is to ensure the timeseries objects owns its data if it can. Therefore, re-assignment happens only if an array is a view into the table (which also means that the table itself is not a view)
- classmethod from_domain(*args, time_attr=None, **kwargs)
Construct a new Table with the given number of rows for the given domain. The optional vector of weights is initialized to 1’s.
- Parameters:
domain (Orange.data.Domain) – domain for the Table
n_rows (int) – number of rows in the new table
weights (bool) – indicates whether to construct a vector of weights
- Returns:
a new table
- Return type:
Orange.data.Table
- classmethod from_table(domain, source, *args, time_attr=None, **kwargs)
Create a new table from selected columns and/or rows of an existing one. The columns are chosen using a domain. The domain may also include variables that do not appear in the source table; they are computed from source variables if possible.
The resulting data may be a view or a copy of the existing data.
- Parameters:
domain (Orange.data.Domain) – the domain for the new table
source (Orange.data.Table) – the source table
row_indices (a slice or a sequence) – indices of the rows to include
- Returns:
a new table
- Return type:
Orange.data.Table
- classmethod from_numpy(*args, time_attr=None, **kwargs)
Construct a table from numpy arrays with the given domain. The number of variables in the domain must match the number of columns in the corresponding arrays. All arrays must have the same number of rows. Arrays may be of different numpy types, and may be dense or sparse.
- Parameters:
domain (Orange.data.Domain) – the domain for the new table
X (np.array) – array with attribute values
Y (np.array) – array with class values
metas (np.array) – array with meta attributes
W (np.array) – array with weights
- Returns:
- classmethod from_list(*args, **kwargs)
- classmethod from_file(*args, **kwargs)
Read a data table from a file. The path can be absolute or relative.
- Parameters:
filename (str) – File name
sheet (str) – Sheet in a file (optional)
- Returns:
a new data table
- Return type:
Orange.data.Table
- classmethod from_url(*args, **kwargs)
- classmethod make_timeseries_from_sequence(table, delta=None, start=None, name='T', have_date=True, have_time=True)
- classmethod make_timeseries_from_continuous_var(table, attr)
- property time_values
Time series measurements times
- property time_variable
The
TimeVariable
orContinuousVariable
that represents the time variable in the time series
- set_interpolation(method='linear', multivariate=False)
- interp(attrs=None)
Return values of variables in attrs, interpolated by method set with set_interpolated().
- Parameters:
attrs (str or list or None) – Variable or List of variables to interpolate. If None, the whole table is returned interpolated.
- Returns:
X – Interpolated variables attrs in columns.
- Return type:
array (n_inst x n_attrs) or Timeseries
- 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.
args – As accepted by scipy.signal.periodogram.
kwargs – 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, 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.
args – As accepted by statsmodels.tsa.stattools.acf.
kwargs – 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(len(x)//2 - 1, len(x) - 1))
args – As accepted by statsmodels.tsa.stattools.pacf.
kwargs – 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:
- 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:
- 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, p-value, 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.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
- exception models.NotFittedError
Raised when model predictions made without fitting
- name
attribute name
- obj
object
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class models.ARIMA(order=(1, 0, 0), use_exog=False)
Autoregressive integrated moving average (ARIMA) model
An auto regression (AR) and moving average (MA) model with differencing.
If exogenous variables are provided in fit() method, this becomes an ARIMAX model.
- Parameters:
order (tuple (p, d, q)) – Tuple of three non-negative integers: (p) the AR order, (d) the degree of differencing, and (q) the order of MA model. If d = 0, this becomes an ARMA model.
- Return type:
unfitted_model
- clear()
Reset (unfit) the current model
- copy()
Copy the current model
- errors()
Return dict of RMSE/MAE/MAPE/POCID/R² errors on in-sample, fitted values
- Returns:
errors – Mapping of error measure str -> error value.
- Return type:
dict
- fit(endog, exog=None)
Fit the model to endogenous variable endog, optionally given exogenous column variables exog.
- Parameters:
endog (array_like) – Dependent variable (y) of shape
[nobs, k]
(k = 1
for a single variable;k > 1
for vector models).exog (array_like) – If model supports it, the additional independent variables (X) of shape
[nobs, k_vars]
.
- Return type:
fitted_model
- fittedvalues(as_table=False)
Return predictions for in-sample observations, i.e. the model’s approximations of the original training values.
- Parameters:
as_table (bool) – If True, return results as an Orange.data.Table.
- Returns:
fitted_values
- Return type:
array_like
- predict(steps=1, exog=None, *, alpha=0.05, as_table=False)
Make the forecast of future values.
- Parameters:
steps (int) – The number of steps to make forecast for.
exog (array_like) – The exogenous variables some models require.
alpha (float) – Calculate and return (1-alpha)100% confidence intervals.
as_table (bool) – If True, return results as an Orange.data.Table.
- Returns:
forecast – (forecast, low, high)
- Return type:
array_like
- residuals(as_table=True)
Return residuals (prediction errors) for in-sample observations,
- Parameters:
as_table (bool) – If True, return results as an Orange.data.Table.
- Returns:
residuals
- Return type:
array_like
- class models.VAR(maxlags=None, ic=None, trend='c')
Vector auto-regression (VAR) model
A multivariate auto regression model of multiple inter-dependent variables.
- Parameters:
maxlags (int) – The exact number of lags (order) to construct the model with or the maximum number of lags to check for order selection (see ic parameter). Defaults to
12*(nobs/10)**.5
.ic ({‘aic’, ‘fpe’, ‘hqic’, ‘bic’, 'magic', None}) – The information criterion to optimize order (maxlags) on.
trend ({'c', 'ct', 'ctt', 'nc'}) – Constant (c); constant and trend (ct); constant, linear and quadratic trend (ctt); no constant, no trend (nc). These are prepended to the columns of the data set.
- Return type:
unfitted_model
- clear()
Reset (unfit) the current model
- copy()
Copy the current model
- errors()
Return dict of RMSE/MAE/MAPE/POCID/R² errors on in-sample, fitted values
- Returns:
errors – Mapping of error measure str -> error value.
- Return type:
dict
- fit(endog, exog=None)
Fit the model to endogenous variable endog, optionally given exogenous column variables exog.
- Parameters:
endog (array_like) – Dependent variable (y) of shape
[nobs, k]
(k = 1
for a single variable;k > 1
for vector models).exog (array_like) – If model supports it, the additional independent variables (X) of shape
[nobs, k_vars]
.
- Return type:
fitted_model
- fittedvalues(as_table=False)
Return predictions for in-sample observations, i.e. the model’s approximations of the original training values.
- Parameters:
as_table (bool) – If True, return results as an Orange.data.Table.
- Returns:
fitted_values
- Return type:
array_like
- predict(steps=1, exog=None, *, alpha=0.05, as_table=False)
Make the forecast of future values.
- Parameters:
steps (int) – The number of steps to make forecast for.
exog (array_like) – The exogenous variables some models require.
alpha (float) – Calculate and return (1-alpha)100% confidence intervals.
as_table (bool) – If True, return results as an Orange.data.Table.
- Returns:
forecast – (forecast, low, high)
- Return type:
array_like
- residuals(as_table=True)
Return residuals (prediction errors) for in-sample observations,
- Parameters:
as_table (bool) – If True, return results as an Orange.data.Table.
- Returns:
residuals
- Return type:
array_like
- datasources.quandl_data(symbol, since=None, until=None, *, collapse='daily', api_key='')
- Parameters:
symbol –
since –
until –
collapse (none|daily|weekly|monthly|quarterly|annual) –
api_key –
- datasources.finance_data(symbol, since=None, until=None)
Fetch Yahoo Finance data for stock or index symbol within the period after since and before until (both inclusive).
- Parameters:
symbol (str) – A stock or index symbol, as supported by Yahoo Finance.
since (date) – A start date (default: 1900-01-01).
until (date) – An end date (default: today).
- Returns:
data
- Return type: