Define analytics

Create custom analytic functions for window processing that drive advanced analytic use cases

Pre-computed metrics generated by the Metrics Engine can be used within a custom processing component. For example, events could be filtered by user-defined metrics using time intervals, scoring models use metrics as part of the input feature space or build KPIs that combine metrics with event data.

Requirements

See Setting up the environment documentation

Note all gradle commands must be execute at the root of the project directory

Development steps

API

The below API is provided for developers to implement.

public interface AnalyticsFunction<T> {

    /**
     * Set function parameters
     *
     * @param parameters
     */
    void setParameters(Properties parameters);

    /**
     * Referenceable function ID for use in projections and window processing
     * 
     * @return name of function as String
     */
    String getVariablePostFixID();

    /**
     * Analytic function to compute
     *
     * @param values to use in the computation
     * @param previousValue computed
     * @return computed result
     */
    T compute(Number[] values, Number previousValue);
}

Development steps

  1. Implement AnalyticsFunction interface

  2. Validate and test

  3. Deploy

  4. Add to a use case DSL

Explaining each step

Step 1: Implement AnalyticsFunction interface

See the Bollinger bands example

Step 2: Build, test and package

The template project provides basic JUnit test to validate DSL. The project will execute these tests during the gradle build cycle and deploy to your local maven repository.

gradle build publishToMavenLocal

Step 3: Deploy

Once your package has been successfully created you are ready to deploy to a Joule project. The resulting jar artefact needs to be placed in to the userlibs directory in your Joule projects directory. See provided examples documentation for further directions.

cp build/libs/<your-connector>.jar <location>/userlibs

Step 4: Add to a use case DSL

Now the jar is created and deployed the use case can use the implementation within the DSL definition file.

Example

processing unit:
  pipeline:
    - filter:
      expression: "symbol == 'CVCO'"
    - sliding window analytics:
        function: com.fractalworks.examples.banking.analytics.BollingerBands
        windowSize: 5
        fields: [ ask ]
        parameters:
          deviations: 2

Last updated