Making Predictions via PMML Model


This application demonstrates how to configure a pretrained PMML model to predict required raw materials from sweet production events and view the output on the console.


  1. Download siddhi-gpl-execution-pmml-x.x.x.jar from the following link and copy the jar to {WSO2SIHome}/lib
  2. Save this sample.
  3. If there is no syntax error, the following message is shown on the console:
    • Siddhi App PmmlModelProcessor successfully deployed.

Executing the Sample:

  1. Replace with the SweetProductionRatePrediction.pmml file's absolute path - {WSO2SIHome}/samples/artifacts/PMMLModelProcessorSample/SweetProductionRatePrediction.pmml
  2. Start the Siddhi application by clicking on 'Run'.
  3. If the Siddhi application starts successfully, the following messages would be shown on the console.
    • PmmlModelProcessor.siddhi - Started Successfully!


If you edit this application while it's running, stop the application -> Save -> Start. * Stop this Siddhi application (Click 'Run' on menu bar -> 'Stop') * Start the application and check whether the specified events from the jms provider appear on the console.

Testing the Sample:

Send events through one or more of the following methods. * You may send events to SweetProductionStream, via event simulator: 1. Open the event simulator by clicking on the second icon or pressing Ctrl+Shift+I. 2. In the Single Simulation tab of the panel, specify the values as follows: * Siddhi App Name : PmmlModelProcessor * Stream Name : SweetProductionStream 3. In the name and amount fields, enter 'candy', 20, 23 respectively and then click Send to send the event. 4. Send more events as desired.

  • Send events to the HTTP endpoint defined by 'publish.url' in the Sink configuration through the curl command:

    1. Open a new terminal and issue the following command:
      • curl -X POST -d '{"streamName": "SweetProductionStream", "siddhiAppName": "PmmlModelProcessor","data": ['candy', 20, 23]}' http://localhost:9390/simulation/single -H 'content-type: text/plain'
    2. If there is no error, the following messages are shown on the terminal:
      • {"status":"OK","message":"Single Event simulation started successfully"}
  • Publish events with Postman:

    1. Install 'Postman' application from Chrome web store.
    2. Launch the application.
    3. Make a 'Post' request to the 'http://localhost:9390/simulation/single' endpoint. Set the Content-Type to 'text/plain' and set the request body in text as follows:
    4. Click 'send'. If there is no error, the following messages are shown on the console:
      • "status": "OK",
      • "message": "Single Event simulation started successfully"


  • Accepted values for the 'name' field should be either candy, caramel-bar, peanut-butter-cup or truffle for the specific pretrained PMML model.

Viewing the Results:

See the prediction as output on the in the console.


Stop this Siddhi application, once you are done with the execution.

-- Please refer to on getting started with SP editor.

@App:description('Use a pretrained PMML model to predict required raw materials. View the output on the console.')
@Source(type = 'tcp', context='SweetProductionStream',
define stream SweetProductionStream (name string, currentHourAmount  double, previousHourAmount double );

define stream PredictionStream (name string, currentHourAmount double, previousHourAmount double, Predicted_nextHourAmount string);

from SweetProductionStream#pmml:predict('<SweetProductionRatePrediction_model_path>')
select *
insert into PredictionStream;