Run the inference engine
You can run the inference engine as a REST API.
POST
http://<IP>:<PORT>/analytics/models/v1/model_predict/
The inference engine input is a JSON that consists of the following elements:
- riskModelTrained: the trained risk model JSON
- toBeScoredData: the list of risk indicator values (current and historical if any) used for scoring
The following code is a sample JSON input:
{
"riskModelTrained": {
"metadata": {
"applyDecay": true
},
"nodes": [{
"lookupcode": "RD15",
"level": 0,
"name": "Risk",
"threshold": [0.33, 0.75],
"source": "Comm",
"id": "15",
"subcategory": "NO_DISPLAY",
"category": "Derived",
"probabilities": [
[1, 1, 0.999, 1, 1, 0.999, 0.997, 0.001, 0.019],
[0, 0, 0.001, 0, 0, 0.001, 0.003, 0.999, 0.981]
],
"outcome": ["low", "medium", "high"],
"parents": ["27", "26"],
"desc": "Risk"
}, {
"lookupcode": "RD27",
"level": 1,
"name": "Comm",
"threshold": [0.33, 0.75],
"source": "Comm",
"id": "27",
"subcategory": "NO_DISPLAY",
"category": "Derived",
"probabilities": [
[1, 0, 0, 0, 0, 0.001, 0, 0.002, 0.333, 0, 0, 0.001, 0, 0, 0.005, 0.001, 0.003, 0.333, 0, 0.002, 0.333, 0.001, 0.004, 0.019, 0.019, 0.333, 0.333, 0, 0, 0.002, 0, 0, 0.004, 0.002, 0.003, 0.019, 0, 0, 0.005, 0, 0.001, 0.01, 0.002, 0.019, 0.333, 0.001, 0.005, 0.333, 0.002, 0.004, 0.333, 0.333, 0.333, 0.333, 0, 0.001, 0.019, 0.001, 0.002, 0.019, 0.01, 0.333, 0.333, 0.001, 0.003, 0.019, 0.003, 0.01, 0.333, 0.019, 0.333, 0.333, 0.01, 0.01, 0.333, 0.333, 0.333, 0.333, 0.333, 0.333, 0.333],
[0, 1, 0, 1, 1, 0.001, 0, 0.002, 0.333, 1, 1, 0.001, 1, 1, 0.005, 0.001, 0.003, 0.333, 0, 0.002, 0.333, 0.001, 0.004, 0.019, 0.019, 0.333, 0.333, 1, 1, 0.002, 1, 1, 0.004, 0.002, 0.003, 0.019, 1, 1, 0.005, 1, 0.999, 0.01, 0.002, 0.019, 0.333, 0.001, 0.005, 0.333, 0.002, 0.004, 0.333, 0.333, 0.333, 0.333, 0, 0.001, 0.019, 0.001, 0.002, 0.019, 0.01, 0.333, 0.333, 0.001, 0.003, 0.019, 0.003, 0.01, 0.333, 0.019, 0.333, 0.333, 0.01, 0.01, 0.333, 0.333, 0.333, 0.333, 0.333, 0.333, 0.333],
[0, 0, 0.999, 0, 0, 0.998, 0.999, 0.997, 0.333, 0, 0, 0.998, 0, 0, 0.99, 0.998, 0.994, 0.333, 0.999, 0.995, 0.333, 0.998, 0.992, 0.961, 0.961, 0.333, 0.333, 0, 0, 0.997, 0, 0, 0.992, 0.996, 0.993, 0.961, 0, 0, 0.99, 0, 0.001, 0.98, 0.996, 0.961, 0.333, 0.998, 0.99, 0.333, 0.995, 0.992, 0.333, 0.333, 0.333, 0.333, 0.999, 0.998, 0.961, 0.998, 0.996, 0.961, 0.98, 0.333, 0.333, 0.998, 0.995, 0.961, 0.994, 0.98, 0.333, 0.961, 0.333, 0.333, 0.98, 0.98, 0.333, 0.333, 0.333, 0.333, 0.333, 0.333, 0.333]
],
"outcome": ["low", "medium", "high"],
"parents": ["25", "24", "23", "22"],
"desc": "Risk observed from Communication data"
}, {
"lookupcode": "RD25",
"level": 2,
"name": "Efforts on Recruit Co-conspirators",
"threshold": [0.33, 0.75],
"source": "Comm",
"id": "25",
"subcategory": "NO_DISPLAY",
"category": "Comm",
"probabilities": [0.729, 0.258, 0.013],
"outcome": ["low", "medium", "high"],
"parents": [],
"desc": "Mass communications sent by $party_name to influence co-traders"
}, {
"lookupcode": "RD24",
"level": 2,
"name": "Efforts on Recruit Victims",
"threshold": [0.33, 0.75],
"source": "Comm",
"id": "24",
"subcategory": "NO_DISPLAY",
"category": "Comm",
"probabilities": [0.725, 0.263, 0.013],
"outcome": ["low", "medium", "high"],
"parents": [],
"desc": "Mass communications sent by $party_name to influence investors"
}, {
"lookupcode": "RD23",
"level": 2,
"name": "Recruit Co-conspirators",
"threshold": [0.33, 0.75],
"source": "Comm",
"id": "23",
"subcategory": "NO_DISPLAY",
"category": "Comm",
"probabilities": [0.726, 0.26, 0.013],
"outcome": ["low", "medium", "high"],
"parents": [],
"desc": "Communication sent by $party_name to influence co-traders"
}, {
"lookupcode": "RD22",
"level": 2,
"name": "Recruit Victims",
"threshold": [0.33, 0.75],
"source": "Comm",
"id": "22",
"subcategory": "NO_DISPLAY",
"category": "Comm",
"probabilities": [0.733, 0.251, 0.016],
"outcome": ["low", "medium", "high"],
"parents": [],
"desc": "Communication sent by $party_name to influence investors"
}, {
"lookupcode": "RD26",
"level": 1,
"name": "Trade",
"threshold": [0.33, 0.75],
"source": "Trade",
"id": "26",
"subcategory": "NO_DISPLAY",
"category": "Derived",
"probabilities": [
[1, 0, 0.002, 0, 0, 0.005, 0.002, 0.004, 0.072],
[0, 1, 0.002, 1, 0.999, 0.005, 0.002, 0.004, 0.072],
[0, 0, 0.996, 0, 0, 0.99, 0.996, 0.991, 0.855]
],
"outcome": ["low", "medium", "high"],
"parents": ["16", "21"],
"desc": "Risk observed from Trade data"
}, {
"lookupcode": "RD16",
"level": 2,
"name": "Pump",
"threshold": [0.33, 0.75],
"source": "Trade",
"id": "16",
"subcategory": "NO_DISPLAY",
"category": "Trade",
"probabilities": [0.721, 0.265, 0.015],
"outcome": ["low", "medium", "high"],
"parents": [],
"desc": "Pump in progress in the ticker"
}, {
"lookupcode": "RD21",
"level": 2,
"name": "Dump",
"threshold": [0.33, 0.75],
"source": "Trade",
"id": "21",
"subcategory": "NO_DISPLAY",
"category": "Trade",
"probabilities": [0.729, 0.257, 0.014],
"outcome": ["low", "medium", "high"],
"parents": [],
"desc": "Dump in progress in the ticker"
}],
"edges": [{
"source": "27",
"target": "15"
}, {
"source": "25",
"target": "27"
}, {
"source": "24",
"target": "27"
}, {
"source": "23",
"target": "27"
}, {
"source": "22",
"target": "27"
}, {
"source": "26",
"target": "15"
}, {
"source": "16",
"target": "26"
}, {
"source": "21",
"target": "26"
}]
},
"toBeScoredData": {
"ticker": "PDZ",
"nodes": [{
"id": "22",
"value": 1
}]
}
}
The result is a string in JSON format that contains the outcome of the inference engine. The following is an example of a response.
{
"results": [{
"score": 1,
"id": "33"
}, {
"score": 0.9,
"id": "34"
}, {
"score": 0.7135125,
"id": "35"
}, {
"score": 0.15500289242473736,
"id": "36"
}, {
"score": 0,
"id": "37"
}, {
"score": 0.75,
"id": "15"
}, {
"score": 1,
"id": "26"
}, {
"score": 0.33,
"id": "27"
}, {
"score": 0.9,
"id": "30"
}, {
"score": 0,
"id": "31"
}, {
"score": 0.887188235294118,
"id": "32"
}],
"alert": {
"isAlert": true,
"score": 0.75
},
"status": {
"code": 200,
"message": "success"
}
}
The isAlert field gives the outcome of whether an alert needs to be created.
The score field contains the alert score that is consolidated from the
individual risk indicator scores.
The status field indicates the overall status of the inference.
The inference engine returns whether the inputs are risky enough to cause an alert. Whether a new alert needs to be created or an existing alert needs to be updated depends on the use case implementation. The inference engine does not consider new alert or updating an existing alert.