Table of Contents | ||
---|---|---|
|
This extension facilitates you to use the machine learning models which you generate using WSO2 ML within WSO2 Complex Event Processor (CEP) for making predictions. Thereby, it integrates WSO2 ML with WSO2 CEP, to perform realtime predictions on an event stream by applying a model generated by WSO2 ML. An input event stream which is received by an event receiver of WSO2 CEP is processed by executing an execution plan within WSO2 CEP. This execution plan is written using Siddhi language. It processes the input event stream by applying the model generated using WSO2 ML. The output of this processing which includes the prediction will be published to an output stream through an event publisher of WSO2 CEP. For more information on WSO2 CEP, go to WSO2 CEP Documentation.
AnchorSiddhi syntax for the extension Siddhi syntax for the extension
Siddhi syntax for the extension
Siddhi syntax for the extension | |
Siddhi syntax for the extension |
There are two possible Siddhi query syntaxes to use the extension in an execution plan as follows.
< double | float|long|int|string|boolean >
predict(<string>
pathToMLModel, <string> dataType)- Extension Type: StreamProcessor
- Description: Returns an output event with the additional attribute with the response variable name of the model, set with the predicted value, using the feature values extracted from the input event.
- Parameter: pathToMLModel: The file path or the registry path where ML model is located. If the model storage location is registry, the value of this this parameter should have the prefix “
registry:
” Parameter: dataType: Data type of the predicted value (double, float, long, integer/int, string, boolean/bool).
Example:
predict(‘registry:/_system/governance/mlmodels/indian-diabetes-model’)
< double | float|long|int|string|boolean >
predict(<string>
pathToMLModel, <string> dataType,<double>
input)- Extension Type: StreamProcessor
- Description: Returns an output event with the additional attribute with the response variable name of the model, set with the predicted value, using the feature values extracted from the input event.
- Parameter: pathToMLModel: The file path or the registry path where ML model is located. If the model storage location is registry, the value of this parameter should have the prefix “
registry:
” Parameter: dataType: Data type of the predicted value (double, float, long, integer/int, string, boolean/bool).
Parameter : input: A variable attribute value of the input stream which is sent to the ML model as feature values for predictions. Function does not accept any constant values as input parameters. You can have multiple input parameters.
Example:
predict(‘registry:/_system/governance/mlmodels/indian-diabetes-model’, NumPregnancies, TSFT, DPF, BMI, DBP, PG2, Age, SI2)
...
Generate a model using WSO2 ML which you will use to make the predictions. For instructions on generating a model in WSO2 ML, see Generating Models.
Tip |
---|
When following the instructions in Generating Models , do the following changes.
|
...
- Download WSO2 CEP, and start the server. For instructions, see Getting Started.
Installing required features in WSO2 CEP
- Install the WSO2 Machine Learner (ML) Features. For detailed instructions to install WSO2 ML features, see Installing Machine Learner Features.
Creating the input stream
...
- Log in to the CEP management console using the following URL, if you are not already logged in: https://<CEP_HOME>:<CEP_PORT>/carbon/
- Click Tools, and then click Event Simulator.
- Select
InputStream:1.0.0
for the Event Stream Name. Enter the feature values to predict, in the Stream Attributes input fields as shown below.
Click Send, to send the events. You view the values of the output stream named PredictionStream logged by the event publisher in the back end console logs of WSO2 CEP as shown below.