Table of Contents | ||
---|---|---|
|
...
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)
...
- 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 Main, and then click Execution Plans in the Streaming Analytics menu.
- Click Add Execution Plan.
- Select
inputStreamInputStream:1.0.0
for Import Stream from the list, and click Import. Enter the name of the output stream (
PredictionStream
) for Value Of, selectPredictionStream:1.0.0
from the Stream ID list, and click Export for Export Stream.Enter the following Siddhi query as shown below.
Tip Replace your file or registry path where to locate the downloaded ML model as the first argument and the response variable data-type as the second variable of the
predict()
function in the below execution plan as described in Siddhi syntax for the extension.Code Block language sql from inputStream#mlInputStream#ml:predict('registry:/_system/governance/ml/indian-diabetes-model', 'double') select * insert into PredictionStream;
Click Validate Query Expressions, to validate the query you entered.
- Click Add Execution Plan to save the execution plan in the system. You view the execution plan added to the list of all available execution plans as shown below.
...
- 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
inputStreamInputStream: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.