Operator FunctionEvaluator
The FunctionEvaluator operator applies a function to each value in a time series.
The control and knot points, which are required to apply the function, are specified as values of the functionSpecification parameter, which has a data type of map.
FunctionSpecification: {
<knot_1>:[<control_11>, <control_12> ... <control_1d>],
<knot_2>:[<control_21>, <control_22> ... <control_2d>],
...
<knot_n>:[<control_n1> ,<control_n2> ... <control_nd>]
}
Currently only the linear interpolation function is supported. For example:

In this example, X0 and X1 are control points and Y0 and Y1 represents knot points. The line between those points is the linear interpolation. The input time series is X and the output (Y) is calculated by using the linear interpolation.
Behavior in a consistent region
- The operator is not supported in a consistent region. A warning occurs when you compile your streams processing application.
- The operator cannot be the start of a consistent region. An error occurs when you compile your streams processing application.
Execptions
The FunctionEvaluator operator throws an exception in the following cases:
- The input time series is out of the bounds of the function specification.
- At least two control points must be specified for the function evaluator to work.
Examples
The following example is a linear interpolation that uses the FunctionEvaluator operator:
use com.teracloud.streams.timeseries.analysis::FunctionEvaluator;
composite Main{
graph
stream<float64 x> In=FileSource(){
param
file: "tsList.dat";
format: csv;
}
stream<In, tuple<list<float64> y>>
Out=FunctionEvaluator(In)
{
param
inputTimeSeries: x;
functionSpecification:{
0.0:[0.679880,0.136652]; // mapping points
0.1:[0.858402,0.199834];
}
output Out:
y = evaluateTimeSeries();
}
}
Summary
- Ports
- This operator has 1 input port and 1 output port.
- Windowing
- This operator does not accept any windowing configurations.
- Parameters
- This operator supports 2 parameters.
Required: functionSpecification, inputTimeSeries
- Metrics
- This operator does not report any metrics.
Properties
- Implementation
- C++
- Threading
- Always - Operator always provides a single threaded execution context.
- Ports (0)
-
Consumes time series data to be processed by the function evaluator algorithm. The inputTimeSeries parameter specifies the name of the attribute on this port that contains the time series data. The accepted data type is list<float64>.
- Properties
-
- Optional: false
- ControlPort: false
- TupleMutationAllowed: false
- WindowingMode: NonWindowed
- WindowPunctuationInputMode: Oblivious
- Assignments
- This operator allows any SPL expression of the correct type to be assigned to output attributes.
- Output Functions
-
- FunctionEvaluator
-
- <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.
- list<float64> evaluateTimeSeries()
-
Returns the time series after applying the functions coefficients.
- Ports (0)
-
This port submits a tuple that contains the time series values after applying the function coefficients. This port submits a tuple for each input tuple that is processed. 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
-
- Optional: false
- TupleMutationAllowed: false
- WindowPunctuationOutputMode: Generating
Required: functionSpecification, inputTimeSeries
- functionSpecification
-
Specifies the map that will be applied on the incoming timeseries. The map key is control point, and the map value is the list of knot points. The map value must contain at least two control points.
- Properties
-
- Type: map<float64,list<float64>>
- Cardinality: 1
- Optional: false
- ExpressionMode: Expression
- inputTimeSeries
-
Specifies the name of the attribute that contains the input data in the tuple. The supported data type is list<float64>.
- Properties
-
- Type: float64
- Cardinality: 1
- Optional: false
- ExpressionMode: Expression
- FunctionEvaluator
-
stream<${schema}> ${outputStream} = FunctionEvaluator(${inputStream}) { param inputTimeSeries: ${timeSeriesExpression}; functionSpecification: ${functionSpecificationExpression}; output ${outputStream}: ${outputExpression}; }
- tsaToolkitLibrary