Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Log in to the WSO2 ESB management console using admin/admin credentials.
  2. Click Main, and then click Proxy Service.
  3. Click Pass Throgh Proxy.
  4. Enter the details as shown below.
    • Enter a name for Proxy Service Name (E.g. PredictMediatirTestProxy).
    • Enter  http://localhost:9000/services/SimpleStockQuoteService  for Target URL.
  5.   Click  Create . You view the proxy service created as shown below.
    proxy services list

    Tip

    Follow the steps below to view the source view of the proxy service configuration you added.

  6. Log in to the WSO2 ESB management console using admin/admin credentials.
  7. Click Main, and then click List in the Services menu.
  8. Click the corresponding Source View link of the WSDL based proxy service you added above. You view its configuration in the source view as follows.

    Code Block
    languagexml
    <proxy xmlns="http://ws.apache.org/ns/synapse" name="PredictMediatirTestProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <log level="custom"> <property name="before-predict-mediator" expression="fn:concat('ML Mediator Prediction : ',get-property('result'))"/> </log> <predict> <model storage-location="/Users/praneesha/Documents/Product_Packs/ML/wso2ml-1.0.0-SNAPSHOT/samples/ml-model-usage/src/main/resources/downloaded-ml-model"/> <features> <feature name="SI2" expression="$body/features/SI2"/> <feature name="PG2" expression="$body/features/PG2"/> <feature name="Age" expression="$body/features/Age"/> <feature name="DBP" expression="$body/features/DBP"/> <feature name="BMI" expression="$body/features/BMI"/> <feature name="DPF" expression="$body/features/DPF"/> <feature name="TSFT" expression="$body/features/TSFT"/> <feature name="NumPregnancies" expression="$body/features/NumPregnancies"/> </features> <predictionOutput property="result"/> </predict> <log level="custom"> <property name="after-predict-mediator" expression="fn:concat('ML Mediator Prediction : ',get-property('result'))"/> </log> <drop/> </inSequence> <outSequence> <send/> </outSequence> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </target> <description/> </proxy>

     

Adding Log, Predict and Drop Mediators to the Sequence

...

  1. Log in to the WSO2 ESB management console using admin/admin credentials.
  2. Click Main, and then click List in the Services menu.
  3. Click the corresponding Design View link of the WSDL based proxy service you added above.
  4. Click Next in the Step 1 of 3 - Basic Settings screen to proceed to step 2.
  5. In the Step 2 of 3 - In Sequence and Endpoint Options screen, Select Define Inline, and then click the Create link as shown below.
    define inline
  6. In the Design in Sequence screen, click the Add Child option which is next to the Root element.
  7. Select Coreand then select  Log  from the drop down menu as shown below.
    add log mediator
  8. Enter the following details in the Log Mediator section as shown below.
    • Select INFO for Log Category.

    • Select Custom for Log Level.

    • Click Add Property.

    • Enter before-predict-mediator for Property Name.

    • Select Expression from the Property Value drop down list.

    • Enter the following expression for Value/Expressionfn:concat('ML Mediator Prediction : ',get-property('result'))

  9. Click Update.

  10. Click on the Log element, and then click the Add Sibling option which is next to it.
  11. Select Agent and then select Predict from the drop down menu as shown below.
    add predict mediator
  12. Enter the path to generated model , which that you want to use in predictions for Model Storage Location as shown in the example below.

    You can give the folder path of the <ML_HOME>/samples/model-usage/src/main/resources/downloaded-ml-model sample model
    Tip
    Info

    The model should be downloaded and saved in the registry or any location in your machine.

  13. Selection_002.png Click Load Model. It loads thefeatures list of the model as shown below.
    Selection_004.pngImage Modified
    Info

    The the model that you are using for predictions is using an algorithm of the Anomaly Detection algorithm type, the Predict mediator is displayed with the Percentile Value as shown in the example below.

    Expand
    titleClick to view Predict mediator with Percentile Value

    Image Added

  14. Enter the following XPath (or JSONPath) expressions in the Expression field for the displayed features list associated with the model, to extract the feature values from the mediating message.

    Feature nameXPath expression
    Age $body/features/Age
    BMI $body/features/BMI
    DBP $body/features/DBP
    DPF $body/features/DPF
    NumPregnancies $body/features/NumPregnancies
    PG2 $body/features/PG2
    SI2 $body/features/SI2
    TSFT $body/features/TSFT
    Tip

     If you are defining a namespace in the XPATH expression, click the corresponding Namespaces link of the features to add namespaces. Then, in the Namespace Editor, add any number of namespace prefixes and URL that you have used in the expression as shown below.

  15. In the Prediction Output section, the message context property name (e.g. result), to which the prediction output value needs to be set as shown below.

  16. Click Update.
  17. Click on the Predict element, and then click the Add Sibling option which is next to it.
  18. Select  Core  and then select  Log  from the drop down menu as shown below.
    add second log mediator
  19. Enter the following details in the Log Mediator section as shown below.
    after log mediator
    • Select INFO for Log Category.

    • Select Custom for Log Level.

    • Click Add Property.

    • Enter after-predict-mediator for Property Name.

    • Select Expression from the Property Value drop down list.

    • Enter the following expression for Value/Expression fn:concat('ML Mediator Prediction : ',get-property('result'))

  20. Click Update.

  21. Click on the Log element, and then click the Add Sibling option which is next to it.
  22. Select  Core  and then select  Drop  from the drop down menu as shown below.
    add drop mediator
  23. Click Save & Close.
  24. Click Next in the Step 2 of 3 - In Sequence and Endpoint Options screen.

  25. Click Finish in the Step 3 of 3 0 Out Sequence and Fault Sequence Options screen.

...