{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":848,"path":"api-reference/server-api-reference/MLSolutionUtilAPI.md","title":"MLSolutionUtil - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# MLSolutionUtil- Global\n\nThe MLSolutionUtil script include provides methods for getting Predictive Intelligence predictions.\n\nThis script include requires the Predictive Intelligence plugin \\(com.glide.platform\\_ml\\) and is provided within the `sn_ml` namespace.\n\nFor more information, see [Using ML APIs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/using-ml-apis.md).\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n**Related topics**  \n\n\n[MLSolution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/MLSolutionAPI.md)\n\n[MLSolutionFactory](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/MLSolutionFactoryAPI.md)\n\n## MLSolutionUtil - MLSolutionUtil\\(\\)\n\nInstantiates a new MLSolutionUtil object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n```\n\nvar mlSolutionUtil = new MLSolutionUtil();\n\n```\n\n## MLSolutionUtil - getPredictions\\(Object input, Array solutionNames, Object options\\)\n\nGets predictions for one or more specified solutions.\n\n<table id=\"table_hqw_pbm_yfb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ninput\n\n</td><td>\n\nObject\n\n</td><td>\n\nGlideRecord or array of JSON objects as key-value pairs.\n\n</td></tr><tr><td>\n\nsolutionNames\n\n</td><td>\n\nArray\n\n</td><td>\n\nArray of solution names to retrieve predictions from.\n\n</td></tr><tr><td>\n\noptions\n\n</td><td>\n\nObject\n\n</td><td>\n\nOptional. 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.\n-   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.\n-   custom\\_results\\_filter: String. Similarity solutions only. Specifies the allowed set from which results are returned using an encoded query.\n\n</td></tr></tbody>\n</table><table id=\"table_iqw_pbm_yfb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nArray\n\n</td><td>\n\nJSON 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.\n-   predictedSysId: String. The sys\\_id of the predicted value. Results can be from any table on which information is being predicted.\n-   confidence: Number. Value of the confidence associated with the prediction. For example, 53.84.\n-   threshold: Number. Value of the configured threshold associated with the prediction.\n\n</td></tr></tbody>\n</table>```\nvar solutionNames = ['soluton1', 'solution2'];\n\nvar input = new GlideRecord(\"incident\");\ninput.get(\"0ef47232db801300864adfea5e961912\");\n\n// configure optional parameters\nvar options = {};\noptions.top_n = 3;\noptions.apply_threshold = false;\n\nvar mlSolutionUtil = new MLSolutionUtil();\nvar results = mlSolutionUtil.getPredictions(input, solutionNames, options);\n\n// pretty print JSON results\ngs.print(JSON.stringify(JSON.parse(results), null, 2));\n```\n\nOutput:\n\n```\n{\n  solution1:  {\n    input_gr_sys_id1: [\n                {\n                    predictedValue : xxx,\n                    predictedSysId : xx0,\n                    confidence : xxx,\n                    threshold : xxx\n\n                }, \n                {\n                    predictedValue : yyy,\n                    predictedSysId : xx1,\n                    confidence : xxx,\n                    threshold : xxx\n                }\n        ],\n    input_gr_sys_id2 : [\n                {\n                    predictedValue : xxx,\n                    predictedSysId : xx0,\n                    confidence : xxx,\n                    threshold : xxx\n\n                }, \n            ...\n        ]\n  }\n\n  solution2:  {\n      ...\n}\n```\n\n"}}