interoperability-integratedml-adapter


Follow
0
Star
0
Details
Releases
Issues
This application is not supported by InterSystems Corporation. Use it at your own risk.

What's new in this version

ZPM package version issue fix

interoperability-integratedml-adapter

An IRIS Interoperability adapter to use ML models managed by IRIS IntegratedML.

Contents

Project description

The projetc's goal is to let interoperability developers use ML models capabilities in their interoperability productions. Such functionalty is achieve by IRIS Interoperability extension framework, through a custom adapter which access ML models managed by IRIS IntegratedML.

How to run the example

Open the production and start it (user/password for IRIS instance: SuperUser/SYS). As an example of adapter's use, a model for credit card transactions fraud detection was used to simulate a simple financial production. A service starts to receive transactions to process and when a suspicious transaction is detected, an alert is issued.

Results are also persisted in iris-shared/output/valid-transactions.txt file.

Installation

Clone/git pull the repo into any local directory

$ https://github.com/jrpereirajr/interoperability-integratedml-adapter.git

Open a Docker terminal in this directory and run:

$ docker-compose build
  1. Run the IRIS container, and Jupyter notebook server images:
$ docker-compose up -d

Installation (ZPM)

If you just wanna the adaptor, you could install it through ZPM. Open Terminal and call:

USER>zpm "install interoperability-integratedml-adapter"

How to use the adapter?

Create a host class (aBusiness Process or Business Operation class) which uses as adapter the class dc.ENS.Adapter.ClassificationMLAdapter.

After saving the class, you must to configure the model's name into parameter "Model", like this:

The adaptor loads all classification models available in the namespace, so you can choose the one which best fits to your needs.

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

This method returns a object of the class dc.Ens.Adapter.ClassificationResult. As you can see, this class has properties for prediction and probability calculated by the classification model.

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:

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.

How it works?

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:

In a similar way, the class dc.Ens.Adapter.RegressionMLAdapter executes a SQL but just using the PREDICT function for estimation of regression models.

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)

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

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':

In such way it's possible to interoperability developers use ML models in their workflows without care about specific SQL sintax.

What would be its advantages?

Once the adapter lets interoperability users to just use ML into their work flows without caring about ML models prototyping and implementation, this adapter could help developers by:

  • provinding decoupling from ML and interoperability;
  • helping teams to focus on their responsabilities - ML team cares about model stuffs while Interoperability team cares about integrating systems.

Jupyter notebooks

A notebook explaing the process of analysis and model prototype development is presented at http://localhost:8896/tree.

References

This work was based in templates for IRIS Interoperability and IRIS intergrated ML:

Data used for examples, was adapted from public repositories avaible in Kaggle:

ZPM installation
zpm "install interoperability-integratedml-adapter"
Category
Interoperability
Works with
InterSystems IRISEnsemble
Tags
Info
Version
1.0.10
Last updated
2020-11-23
Repository
Open
Documentation
Open
License
Link