WSO2 Complex Event Processor is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.
Skip to end of metadata
Go to start of metadata


This sample demonstrates how to run Linear Regression using the Timeseries Toolbox. This sample uses Event simulator for inputs and the logger publisher for logging the outputs to the CEP console.

The data used for the regression is from a baseball stats dataset. The dependent variable (predictor variable) is the salary of the Baseball player based on his performance statistics which are the independent variables – rbi, walks, strikeouts and errors.

The execution plan used in this sample is as follows:


from baseballData#timeseries:regress(2, 10000, 0.95, salary, rbi, walks, strikeouts, errors)
select *
insert into regResults;

The inputs to the regression function are as follows.

  • Calculation Interval – 2

  • Batch size – 10,000

  • Confidence Interval – 0.95

  • Y (dependent) variable – salary

  • X (independent) variables – rbi, walks, strikeouts, errors

The output of the query will be the coefficients of the regression equation for the accumulated dataset at each 2nd event. The output attributes will include the input variable values, beta coefficients for each X variable, beta zero and the standard error.

For more detail on input and output parameters of regression see Regression.


Set up the prerequisites required for all samples.

Building the sample

Start the WSO2 CEP server with the sample configuration numbered 0116. For instructions, see Starting sample CEP configurations. This sample configuration does the following:

  •  Points the default Axis2 repo to the <CEP_HOME>/samples/cep/artifacts/0116 directory (by default, the Axis2 repo is <CEP_HOME>/repository/deployment/server).

Executing the sample

  1. Log into the CEP management console which is located at https://localhost:9443/carbon.

  2. Go to Tools -> Event Simulator. Under the Multiple Events section, the BaseballData.csv file is listed. This file contains the sample data. Click Play to start sending sample events from the file.

  3. See the output events received from the CEP console. This sample uses the logger adaptor to log output events to the console.

For example, given below is a screenshot of the final regression output for this data.

  • No labels