---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# MLSolutionUtil - Global

# MLSolutionUtil - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

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](https://www.servicenow.com/docs/access?context=using-ml-apis&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US).
**Related concepts**   

* [MLSolution](https://servicenow-prod.fluidtopics.net/T3s5VejYlP~j3rbn2wZ4JQ#MLSolutionAPI "The MLSolution API provides methods for handling Predictive Intelligence predictions and retrieving solution objects for all capabilities: similarity, classification, and clustering).")
* [MLSolutionFactory](https://servicenow-prod.fluidtopics.net/xyZUi2WTJ_1ypDwYtT86jg#MLSolutionFactoryAPI "The MLSolutionFactory API is a factory class to get an MLSolution scriptable object.")

## MLSolutionUtil - MLSolutionUtil() {#ariaid-title2}

Instantiates a new MLSolutionUtil object.
{#MLSU-MLSolutionUtil__table_btj_twt_rhb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#MLSU-MLSolutionUtil__table_btj_twt_rhb}  


    var mlSolutionUtil = new MLSolutionUtil();

## MLSolutionUtil - getPredictions(Object input, Array solutionNames, Object options) {#ariaid-title3}

Gets predictions for one or more specified solutions.
{#MLSU-getPredictions_O_A_O__table_hqw_pbm_yfb__entry__3}

| 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: * top_n: Number. If provided, returns the top results, up to the specified number of predictions.{#MLSU-getPredictions_O_A_O__solution-prediction-topn} * apply_threshold: Boolean. Checks the threshold value for the solution and applies it to the result set. The threshold value is solution threshold for similarity or class-level threshold for classification. Default value is true.{#MLSU-getPredictions_O_A_O__solution-prediction-thresh} * custom_results_filter: String. Similarity solutions only. Specifies the allowed set from which results are returned using an encoded query.{#MLSU-getPredictions_O_A_O__solution-prediction-custom} {#MLSU-getPredictions_O_A_O__ul_hdp_2cs_ckb} |
[Table 2. Parameters]

{#MLSU-getPredictions_O_A_O__table_hqw_pbm_yfb} {#MLSU-getPredictions_O_A_O__table_iqw_pbm_yfb__entry__2}

| Type | Description |
|-|-|
| Array | JSON key-value pair containing the prediction result grouped by solution name and sorted by sys_id or record_number. * predictedValue: String. Value representing the prediction result.{#MLSU-getPredictions_O_A_O__ml-returnsVal} * predictedSysId: String. The sys_id of the predicted value. Results can be from any table on which information is being predicted.{#MLSU-getPredictions_O_A_O__ml-returnsID} * confidence: Number. Value of the confidence associated with the prediction. For example, 53.84.{#MLSU-getPredictions_O_A_O__ml-returnsConf} * threshold: Number. Value of the configured threshold associated with the prediction.{#MLSU-getPredictions_O_A_O__ml-returnsThrsh} {#MLSU-getPredictions_O_A_O__ul_nlj_5cs_ckb} |
[Table 3. Returns]

{#MLSU-getPredictions_O_A_O__table_iqw_pbm_yfb}  

    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:  {
          ...
    }


