CORAL WIKI

LinearRegressionActor

The LinearRegression is a Coral Actor which performs prediction on the streaming data, based on the behavior of past observations.

Creating a LinearRegressionActor

The creation JSON of the LinearRegression actor (see Coral Actor) has "type": "linearregression". The params value contains the following fields:

field type required description
weights JObject yes An object containing the feature names and coefficients of the model.
intercept Double yes The intercept of the linear regression model.

Example

{
  "data": {
      "type": "actors",
      "attributes": {
          "type": "linearregression",
          "params": {
              "intercept": 3.972,
              "weights": {
                "salary": 0.47353,
                "tnxcount1month": 1.86766,
                "age": 4.52352
              }
          }
      }
  }
}

Trigger

The LinearRegressionActor accepts JSON objects that contain the fields that were defined in the constructor. An example of a JSON object that comes in is as follows:

{
  "salary": 3000,
  "tnxcount1month": 25,
  "age": 30
}

Based on this input object, the LinearRegressionActor would calculate the following:

The score that is calculated is intercept + weightSalary * salary + weightTnxcount1month * tnxcount1month + weightAge * age, which is 3.972 + 0.47353 * 3000 + 1.86766 * 25 + 4.52352 * 30, which is 1606,9591.

Emit

The LinearRegressionActor enriches the received trigger JSON with the predicted score and emits it. It looks like the following:

{
   "salary": 3000,
   "tnxcount1month": 25,
   "age": 30,
   "score": 1606.9591
}

State

The LinearRegressionActor does not keep any state.

Collect

The LinearRegressionActor does not collect state from other actors.

Timer

The LinearRegressionActor does not provide timer actions.