Article
· Nov 16, 2020 3m read

Using IntegratedML to create a ML adapter for IRIS Interoperability

Update: added support for regression model
Hi everyone!

In this brief article, I'll show you how to write an adapter for IRIS Interoperability for use ML models managed by IRIS IntegratedML.

The adapter

The adapter just uses IntegratedML SQL functions PREDICT and PROBABILITY, to get the predicted class from model and its probability. It's just a simple SQL:

code1


Notice that the model name is referenced by Model property. Such property must be defined in host class that uses the adapter, otherwise an exception will be thown. For example:



The model list in the adaptor settings is done by two steps:

  1. Creating a method into a class which extends %ZEN.Portal.ContextSearch to load all classification models and returning them (dc.Ens.Adapter.ClassficationMLContextSearch)

    code2

  2. Configuring such class and method as feeder for property Model into SETTINGS parameter in the adaptor class (dc.Ens.Adapter.ClassificationMLAdapter)

    code3


    For regression models, there's the class dc.Ens.Adapter.RegressionMLContextSearch, which loads all regression models.

In this case, the MODE_TYPE filter is set to 'regression' instead of 'classfication':

Using the adapter

For demonstration, I simulated a simple credit card transaction payment system with fraud detection capabilities, using a ML classification model. When a suspicious transaction is detected, an alert is issued.

In order to use the adapter, create a host class (a Business Process or Business Operation class) which uses as adapter the class dc.ENS.Adapter.ClassificationMLAdapter.

code4


Now, you can use adapter's method Classify(), and provide a sample of features expected by the model:

In order to use it, create a host class (aBusiness Process or Business Operation class) which uses as adapter the class dc.ENS.Adapter.ClassificationMLAdapter

code5


You can use them as your needs. In the example, just the result for fraud prediction was necessary, so the Business Operation class just use value returned into Predicted property:

code6


For regression models, the results is modeled by dc.Ens.Adapter.RegressionResult class. This class has a property called Estimated.

For get a estimation value from a sample, the adapter class for regression model has the Estimate method.

The final result is displayed below:

code7


The complete code is available in OpenExchange.
Hope this could be useful.
José

Discussion (0)1
Log in or sign up to continue