IBM Streams 4.2.1

Operator VAR2

Primitive operator image not displayed. Problem loading file: ../../image/tk$com.ibm.streams.timeseries/op$com.ibm.streams.timeseries.modeling$VAR2.svg

The VAR2 operator tracks data movement and predicts the next expected time series by using a multivariate autoregressive model. The VAR2 operator can be used for short-term prediction and anomaly detection. The VAR2 operator can also perform a Granger Causality test on predicted time series.

The VAR2 operator is a multivariate operator. It takes a vector time series as input (a list of variables that share the same timestamp) and produces a vector time series as output. The operator uses early data to train the model as specified by using the initSamples parameter. The operator can be updated at run time by using the updateTupleCount parameter.

The VAR2 operator supports an optional control port that can used to control the behavior of the operator at run time.

Behavior in a consistent region

  • The operator cannot be the start of a consistent region. An error occurs when you compile your streams processing application.

Exceptions

The VAR2 operator throws an exception in the following case:

  • The value of the initSamples parameter is 0.
Examples

Summary

Ports
This operator has 2 input ports and 2 output ports.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 10 parameters.

Required: inputTimeSeries

Optional: controlPartitionBy, controlSignal, initSamples, inputCoefficient, inputTimestamp, order, partitionBy, updateParams, updateTupleCount

Metrics
This operator does not report any metrics.

Properties

Implementation
C++
Threading
Always - Operator always provides a single threaded execution context.

Input Ports

Ports (0)

This port consumes data for training and scoring against the model. The inputTimeSeries parameter specifies the name of the attribute on this port that contains the time series data. The accepted data types are float64 and list<float64>.

Properties

Ports (1)

This port accepts control signals to control the behavior of the operator. The controlSignal parameter specifies the name of the attribute on this port that contains the control signal type. The inputCoefficient parameter specifies the attribute name on this port that contains the new input coefficents. The updateParams parameter specifies the attribute name on this port that contains the new parameter values.

Properties

Output Ports

Assignments
This operator allows any SPL expression of the correct type to be assigned to output attributes.
Output Functions
VAR_COF
<any T> T predictedTimeSeries()

Returns the values of predicted time series data either as vector time series (list<float64>) or univariate time series (float64), depending on the input time series format.

<any T> T predictedTimestamp()

Returns the predicted timestamp values. An output timestamp is produced only if the input timestamp is regular. Otherwise, a timestamp object with a value of 0 is returned and a message is logged.

<any T> T AsIs (T v)

The default function for output attributes. By default, this function assigns the output attribute to the value of the input attribute with the same name.

Getcoeff
map<uint32,map<uint32,list<float64> > > coefficients()

Submits a tuple that contains the VAR coefficients. This port submits a tuple each time a Monitor signal is consumed on the input control port. The coefficients() output function is used to assign the value of the coefficients to an attribute.

<any T> T AsIs(T v)

The default function for output attributes. By default, this function assigns the output attribute to the value of the input attribute with the same name.

map<uint32, list<uint32>> getGrangerCausality()

Returns Granger causality test results as a map. The key is the index of a focus time series (as represented in the input list) and the values are the set of indices of time series that has Granger-causal relationship with that key

Ports (0)

This port submits a tuple that contains the next predicted value. This port submits a tuple each time a prediction is made. Custom output functions are used to specify the value of the output tuple attributes. The output tuple attributes whose assignments are not specified are assigned from input attributes.

Properties

Ports (1)

This port submits a tuple that contains the coefficients that are used by the filter. This port submits a tuple each time a Monitor signal is consumed on the input control port. The coefficients() output function is used to assign the value of the coefficients to an attributes. The expected data type of the attribute is map<uint32,map<uint32,list<float64>>>.

Properties

Parameters

This operator supports 10 parameters.

Required: inputTimeSeries

Optional: controlPartitionBy, controlSignal, initSamples, inputCoefficient, inputTimestamp, order, partitionBy, updateParams, updateTupleCount

controlPartitionBy

Specifies the name of the attribute that contains the key values that are associated with the time series values in the input tuple on the control port.

Properties

controlSignal

Specifies the name of the attribute in the control port, which holds the control signal. The supported control signals are: TSSignal.Retrain, TSSignal.Monitor, TSSignal.Load, TSSignal.UpdateParams.

Properties

initSamples

Specifies the number of input time series values that are used to initialize the model. This value must be greater than 0.

Properties

inputCoefficient

Specifies the name of the attribute in the control port, which ingests the coefficients that are used for loading the model. If this parameter is not specified, by default, the inputCoefficient attribute is used. If the default attribute or the inputCoefficient parameter is not provided, the operator throws an exception. If the attribute or the parameter value does not contain valid coefficients, the load operation fails and the operator logs a warning message for each failed operation. The operator continues to predict values by using the older coefficients.

Properties

inputTimeSeries

Specifies the name of the attribute that contains the time series data in the input tuple. The supported data types are float64 and list<float64>.

Properties

inputTimestamp

Specifies the name of the attribute in the input stream that contains the timestamp values. The supported data types are uint64 and timestamp. If the data type is uint64, the parameter value represents the number of nanoseconds since UNIX epoch.

Properties

order

Specifies the order of the multivariate autoregressive model. The default value is 1u.

Properties

partitionBy

Specifies the name of the attribute that contains the key values that are associated with the time series values in the input tuple.

Properties

updateParams

Specifies the name of the attribute in the control port, which ingests the new parameter values. If this parameter is not specified, by default, the updateParams attribute is used. If the default attribute or the updateParams parameter is not provided, parameter values are not updated. If valid parameter values are not provided, an error message is logged and no parameter values are updated. The valid key values for the map are "initSamples", "order" and "updateTupleCount".

Properties

updateTupleCount

Specifies the frequency at which the model is updated. For example, if the parameter value is 10u, the model is updated every 10th tuple. If this parameter is not specified, the model can be updated only by using the TSSignal.Retrain control signal.

Properties

Code Templates

VAR2
stream<${schema}> ${outputStream} = VAR2(${inputStream}) 
{
	param
		inputTimeSeries:		${timeSeriesExpression};

	output
		${outputStream}: ${outputExpression};
}
      

Libraries

No description for library.
Library Name: tsatapi
Library Path: ../../../impl/lib
Include Path: ../../../impl/include
No description for library.
Library Name: tstimelag
Library Path: ../../../impl/lib
Include Path: ../../../impl/include