{{announcement.body}}
{{announcement.title}}

Decisioning and Explainability Using Red Hat Decision Manager

DZone 's Guide to

Decisioning and Explainability Using Red Hat Decision Manager

In this article, explore decisioning and explainability using the Red Hat Decision Maker.

· AI Zone ·
Free Resource

Overview

The abundance of computational power and data has made Intelligent Decisioning a reality today. An interesting aspect of this is to provide context-aware actions like providing hyper-personalized customer experience and smart service management. With data comes responsibility. Enabling explainability metrics around these decisions is essential to both the customers as well as businesses. With data regulation rules, customers have the right to understand why certain decisions are made. The same benefits the organizations as well, as it provides a clearer picture of how the decision models are performing allowing them to be improved based on market needs.

In a previous article, I described why having real-time business insights is such a critical piece of a business process system. I also described what it takes to enable integration between Red Hat Process Automation Manager and Elasticsearch. In this article, let us see how we can push Decision metrics to Elasticsearch.

The DMN (Decision Model Notation) standard provides a graphical notation for defining Decision flows. Based on open standards, DMN provides a way for business users to easily create and extend the decision artifacts without having to depend on IT. Having traceability in the decision execution metrics is key for identifying trends and enforcing process improvements.

As we discussed in the previous article, Elasticsearch provides full-text search capabilities that can be used to create a business-friendly dashboard using Kibana.

Customer Eligibility Usecase

Let us now look at a sample use case for our demonstration. We have a Customer Eligibility Decision which determines the eligibility of a customer for a proposed service. Decision Manager allows you to pull in PMML models to be executed as a part of the decision process. In this example, we can see that Risk Checks are performed on a Machine Learning model (Risk Model).

Customer Eligibility Decision Model


As is evident from the Decision model, there are multiple factors that determine eligibility. Also, there are multiple levels at which the eligibility criteria is determined. Having auditing at a granular level, helps us understand the taxonomy of the business case. 

DMN Listener for Elastic Integration

Red Hat Decision Manager provides a way to register a DMN listener in order to be notified of several events during DMN model evaluations. The CustomDMNListener will be used to push Decision execution metrics to Elasticsearch. 

A sample implementation of the listener can be found here.

Let us look at the key highlights of the listener.

First, we use the HttpClientBuilder to authenticate and connect to the elastic cluster. Note that for the purpose of this exercise, we have bypassed the certificate authentication. In production, it is necessary to authenticate using a valid certificate.

Java
 




xxxxxxxxxx
1
24


 
1
protected static CloseableHttpClient buildClient() throws Exception{
2
 
          
3
        HttpClientBuilder builder = HttpClients.custom();
4
 
          
5
        if (elasticSearchUser != null && elasticSearchPassword != null) {
6
            SSLContextBuilder builder1 = new SSLContextBuilder();
7
            builder1.loadTrustMaterial(null, new TrustStrategy() {
8
                @Override
9
                public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
10
                    return true;
11
                }
12
            });
13
            CredentialsProvider provider = new BasicCredentialsProvider();
14
            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(elasticSearchUser, elasticSearchPassword);
15
            provider.setCredentials(AuthScope.ANY, credentials);
16
            SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(builder1.build(),  new NoopHostnameVerifier());
17
            builder.setDefaultCredentialsProvider(provider);
18
            builder.setSSLSocketFactory(sslConnectionSocketFactory).build();
19
        }
20
 
          
21
        return builder.build();
22
}



Next, we define a simple Audit object which we will use to push metrics to Elastic.

Java
 




x


 
1
public class AuditObject {
2
 
          
3
    private String decisionName;
4
    private Date decisionExecutedAt;
5
    private Object inputs;
6
    private String status;
7
    private Object result;
8
   ....



We then override the afterEvaluateDecisionEvent. This is where we populate the Audit Object and finally perform a POST to the Elastic URL.

Java
 




x


1
@Override
2
public void afterEvaluateDecision(AfterEvaluateDecisionEvent e) {
3
 
          
4
DecisionNode decisionNode = e.getDecision();
5
String decisionNodeName = decisionNode.getName();
6
DMNDecisionResult result = e.getResult().getDecisionResultByName(decisionNodeName);
7
 
          
8
//populate the Audit Object
9
 
          
10
AuditObject auditObject = new AuditObject();
11
auditObject.setDecisionName(decisionNodeName);
12
auditObject.setDecisionExecutedAt(new Date());
13
auditObject.setStatus(result.getEvaluationStatus().name());
14
Map<String, Object> mapInputs = e.getResult().getContext().getAll();
15
Map<String, Object> auditMap = new HashMap<>();
16
auditMap.put(str, String.valueOf(mapInputs.get(str)));
17
auditObject.setInputs(auditMap);
18
auditObject.setResult(String.valueOf(result.getResult()));
19
String json = new Gson().toJson(auditObject);
20
 
          
21
//POST to Elastic REST URL
22
HttpPost httpPut = new HttpPost(elasticSearchUrl + "/cust/cust");
23
httpPut.setEntity(new StringEntity(json, "UTF-8"));
24
httpPut.setHeader("Content-Type", "application/json");
25
httpPut.setHeader("Accept", "application/json");
26
 
          
27
. . .
28
 
          
29
}
30
 
          



Business User Visualization

Now that the data has been pushed to Elastic, let us now visualize the data using visual dashboards so that the business user can understand the trends of the Rule execution.


Let us first look at a minimal dashboard visualization of the Rule Metrics using Kibana. The visualization below shows a monitoring view, categorizing the rules by name, time, and result.

Most of the time, business-specific dashboards are important to understand the explainability of the decisions. As we described in our example, there are several factors that determine Customer Eligibility. Reporting on these factors will help better understand how the decisions are being made. Here is a sample visualization.


We are now able to gather insights into the various factors that go in, in determining Customer Eligibility. Not only are we able to visualize overall trends, but we can also drill down into specific customer data. Let us look at the breakdown for a customer.


We can clearly see how the eligibility decision was made based on all the variables involved in the equation.

Summary

This approach also allows us to measure the effectiveness of the Decision and AI models used in conjunction with profile-based decisions. By providing an ability for the business users to make context-aware decisions provides for both auditability as well as the ability to measure the effectiveness of decision models.

Topics:
ai, artificial intelligence, kibana, red hat, red hat decision manager 7

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}