MLSolutionUtil - Global
The MLSolutionUtil script include provides methods for getting Predictive Intelligence predictions.
This script include requires the Predictive Intelligence plugin (com.glide.platform_ml) and is provided within the sn_ml namespace.
For more information, see Using ML APIs.
MLSolutionUtil - MLSolutionUtil()
Instantiates a new MLSolutionUtil object.
| Name | Type | Description |
|---|---|---|
| None |
var mlSolutionUtil = new MLSolutionUtil();
MLSolutionUtil - getPredictions(Object input, Array solutionNames, Object options)
Gets predictions for one or more specified solutions.
| Name | Type | Description |
|---|---|---|
| input | Object | GlideRecord or array of JSON objects as key-value pairs. |
| solutionNames | Array | Array of solution names to retrieve predictions from. |
| options | Object | Optional. JSON object key-value pair with the following properties:
|
| Type | Description |
|---|---|
| Array | JSON key-value pair containing the prediction result grouped by solution name
and sorted by sys_id or record_number.
|
var solutionNames = ['soluton1', 'solution2'];
var input = new GlideRecord("incident");
input.get("0ef47232db801300864adfea5e961912");
// configure optional parameters
var options = {};
options.top_n = 3;
options.apply_threshold = false;
var mlSolutionUtil = new MLSolutionUtil();
var results = mlSolutionUtil.getPredictions(input, solutionNames, options);
// pretty print JSON results
gs.print(JSON.stringify(JSON.parse(results), null, 2));
Output:
{
solution1: {
input_gr_sys_id1: [
{
predictedValue : xxx,
predictedSysId : xx0,
confidence : xxx,
threshold : xxx
},
{
predictedValue : yyy,
predictedSysId : xx1,
confidence : xxx,
threshold : xxx
}
],
input_gr_sys_id2 : [
{
predictedValue : xxx,
predictedSysId : xx0,
confidence : xxx,
threshold : xxx
},
...
]
}
solution2: {
...
}