{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":845,"path":"api-reference/server-api-reference/MLSolutionAPI.md","title":null,"bundle":null,"doc_type":null,"release":null,"body":"---\ntitle: MLSolution - Global\ndescription: The MLSolution API provides methods for handling Predictive Intelligence predictions and retrieving solution objects for all capabilities: similarity, classification, and clustering\\).Gets the prediction result for a classification solution and applies it to the input GlideRecord if the confidence value is higher than the threshold.Gets the capability information of a trained solution.Gets assignments for a clustering solution.Gets the cluster information for a clustering solution.Gets information for a specified clustering solution.Gets the version of the active solution.Determines if a solution is active.Gets the prediction results from the prediction server given a GlideRecord or an array of key-value pairs.\nlocale: en-US\ncanonical_url: https://www.servicenow.com/docs/r/australia/api-reference/server-api-reference/MLSolutionAPI.html\nrelease: australia\nproduct: Server API Reference\nclassification: server-api-reference\ntopic_type: concept\nlast_updated: \"2026-03-12\"\nreading_time_minutes: 6\nbreadcrumb: [Server API reference, API reference, API implementation and reference]\n---\n\n# MLSolution- Global\n\nThe MLSolution API provides methods for handling Predictive Intelligence predictions and retrieving solution objects for all capabilities: similarity, classification, and clustering\\).\n\nThis API provides methods commonly used among all solution capabilities and methods unique to classification and clustering solutions.\n\n-   Common methods used for all solution objects:\n    -   getCapability\\(\\)\n    -   getVersion\\(\\)\n    -   isActive\\(\\)\n    -   predict\\(\\)\n-   Methods only used for classification and regression solutions:\n    -   applyPrediction\\(\\)\n-   Methods only used for clustering solutions:\n    -   getClusterAssignments\\(\\)\n    -   getClusterForRecord\\(\\)\n    -   getClusterInfo\\(\\)\n\nThe MLSolution API requires the Predictive Intelligence plugin \\(com.glide.platform\\_ml\\) and is provided within the `sn_ml` namespace.\n\nThe methods in this object are instantiated using [MLSolutionFactory](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/MLSolutionFactoryAPI.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[MLSolutionUtil](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/MLSolutionUtilAPI.md)\n\n[REST API: Get predictions for multiple solutions](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/agent-intelligence-api.md)\n\n## MLSolution - applyPrediction\\(GlideRecord now\\_GR\\)\n\nGets the prediction result for a classification solution and applies it to the input GlideRecord if the confidence value is higher than the threshold.\n\n|Name|Type|Description|\n|----|----|-----------|\n|now\\_GR|GlideRecord|GlideRecord object containing values on which to run a prediction and apply the results.|\n\n<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\nBoolean\n\n</td><td>\n\nFlag that indicates whether the prediction was applied:\n\n -   true: Prediction applied\n-   false: Prediction rejected\n\n</td></tr></tbody>\n</table>```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"ml_incident_categorization\");\n\nvar inputGR = new GlideRecord(\"incident\");\ninputGR.get(\"0ef47232db801300864adfea5e961912\");\n\nmlSolution.applyPrediction(inputGR);\n```\n\n## MLSolution - getCapability\\(\\)\n\nGets the capability information of a trained solution.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_fm3_pfx_ggb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nType of trained solution.Possible values:\n\n-   Similarity\n-   Classification\n-   Clustering\n\n</td></tr></tbody>\n</table>```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"ml_x_global_clustering\");\n\n// configure optional parameters\nvar options = {};\noptions.group_by = 'network';\noptions.cluster_id = 1;\noptions.top_n_per_cluster = 3;\n\nif (mlSolution.getCapability() == 'clustering') {\n\tvar results = mlSolution.getClusterAssignments(options);\n\t// pretty print JSON results\n\tgs.print(JSON.stringify(JSON.parse(results), null, 2));\n}\n```\n\n## MLSolution - getClusterAssignments\\(Object options\\)\n\nGets assignments for a clustering solution.\n\n<table id=\"table_t1q_hxt_rhb\" 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\noptions\n\n</td><td>\n\nObject\n\n</td><td>\n\nOptional. Values to use to narrow down the returned results by group and level within a clustering solution. Default: Return cluster memberships for all clusters.\n\n</td></tr><tr><td>\n\noptions.group\\_by\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Identifies the segmentation field for which to retrieve cluster memberships, for example, assignment\\_group.This field provides the same grouping as options provided in the **Use Group By** check box in the **Clustering Definition** form. The information provided varies based on the table selected in the **Table** field. For more information, see [Create and train a clustering solution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/create-clustering-solution.md).\n\n</td></tr><tr><td>\n\noptions.cluster\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Cluster ID of a trained solution in the Cluster Summary \\[ml\\_cluster\\_summary\\] table.\n\n</td></tr><tr><td>\n\noptions.top\\_n\\_per\\_cluster\n\n</td><td>\n\nNumber\n\n</td><td>\n\nNumber of top results to receive for each cluster.\n\n</td></tr></tbody>\n</table><table id=\"table_u1q_hxt_rhb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nJSON array containing cluster information in increasing order by cluster\\_id:-   cluster\\_id: String. Unique cluster number within a solution of clusters.\n-   rec\\_display\\_id: String. Record type and number.\n-   rec\\_sys\\_id: String. Record sys\\_id.\n-   group\\_by: If grouped, name of the segmentation field associated with this cluster.\n\n</td></tr></tbody>\n</table>```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"ml_x_global_clustering\");\n\n// configure optional parameters\nvar options = {};\noptions.group_by = 'network';\noptions.cluster_id = '1';\n// returns top 3 results per cluster\noptions.top_n_per_cluster = 3;\n\nvar results = mlSolution.getClusterAssignments(options);\n\n\n```\n\nOutput:\n\n```\n[{\"cluster_id\":\"1\",\"rec_display_id\":\"Incident: INC0014483\",\"rec_sys_id\":\"04e33e7adb401300864adfea5e961900\",\"group_by\":\"network\"},\n {\"cluster_id\":\"1\",\"rec_display_id\":\"Incident: INC0011133\",\"rec_sys_id\":\"5bd23af2db401300864adfea5e96194d\",\"group_by\":\"network\"}]\n```\n\n## MLSolution - getClusterForRecord\\(GlideRecord now\\_GR\\)\n\nGets the cluster information for a clustering solution.\n\n|Name|Type|Description|\n|----|----|-----------|\n|now\\_GR|GlideRecord|Name of the input GlideRecord.|\n\n|Type|Description|\n|----|-----------|\n|String|The cluster\\_id from the Cluster Summary \\[ml\\_cluster\\_summary\\] table if the record belongs to a cluster. Empty string returns if the record does not belong to a cluster.|\n\n```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"solution_name\");\nvar now_GR = new GlideRecord('incident');\nif (mlSolution.getCapability() == 'clustering') {\nvar clusterId = mlSolution.getClusterForRecord(now_GR);\n}\n```\n\n## MLSolution - getClusterInfo\\(Object options\\)\n\nGets information for a specified clustering solution.\n\n<table id=\"table_ak2_xcn_rhb\" 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\noptions\n\n</td><td>\n\nObject\n\n</td><td>\n\nOptional. Narrows down the returned results by group and level within a clustering solution. Default: Return cluster memberships for all clusters.\n\n</td></tr><tr><td>\n\noptions.group\\_by\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Identifies the segmentation field for which to retrieve cluster memberships, for example, assignment\\_group.This field provides the same grouping as options provided in the **Use Group By** check box in the **Clustering Definition** form. The information provided varies based on the table selected in the **Table** field. For more information, see [Create and train a clustering solution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/create-clustering-solution.md).\n\n</td></tr><tr><td>\n\noptions.cluster\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Cluster ID of a trained solution in the Cluster Summary \\[ml\\_cluster\\_summary\\] table.\n\n</td></tr></tbody>\n</table><table id=\"table_bk2_xcn_rhb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nJSON array containing cluster information in increasing order by cluster\\_id:-   cluster\\_id: String. Unique cluster number within a solution of clusters.\n-   cluster\\_quality: String. Number from 0 to 100. Higher numbers indicate higher cluster density.\n-   cluster\\_size: String. Number of records in a cluster.\n-   group\\_by: If grouped, name of the segmentation field associated with this cluster.\n-   cluster\\_concept: String. Set of words that describe the cluster in descending order of frequency.\n\n</td></tr></tbody>\n</table>```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"ml_x_global_clustering\");\n\n// configure optional parameters\nvar options = {};\noptions.group_by = 'network';\noptions.cluster_id = 1;\n\nvar results = mlSolution.getClusterInfo(options);\n```\n\nOutput:\n\n```\n[ {\"cluster_id\":\"1\",\"cluster_quality\":\"56.6\",\"cluster_size\":\"46\",\"group_by\":\"SLA\",\"cluster_concept\":\"issue occur capacity ...\"},\n  {\"cluster_id\":\"2\",\"cluster_quality\":\"55.47\",\"cluster_size\":\"75\",\"group_by\":\"SLA\",\"cluster_concept\":\"clone instance request ...\"},\n... ]\n```\n\n## MLSolution - getVersion\\(\\)\n\nGets the version of the active solution.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Version of the active solution.|\n\n```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"solution_name\");\n\nvar solutionVersion = mlSolution.getVersion();\n```\n\n## MLSolution - isActive\\(\\)\n\nDetermines if a solution is active.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_yzj_lgx_ggb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the solution is active.-   true: Solution active\n-   false: Solution inactive\n\n</td></tr></tbody>\n</table>```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"solution_name\");\n\nvar isActive = mlSolution.isActive();\n```\n\n## MLSolution - predict\\(Object input, Object options\\)\n\nGets the prediction results from the prediction server given a GlideRecord or an array of key-value pairs.\n\nYou can use this method to call prediction with multiple input records because GlideRecord is an iterator.\n\n<table id=\"table_vv5_yfx_ggb\" 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\n[GlideRecord](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) or array of JSON objects containing field names and values as key-value pairs.\n\n</td></tr><tr><td>\n\noptions\n\n</td><td>\n\nObject\n\n</td><td>\n\nOptional. JSON 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_khq_hgx_ggb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nJSON object containing the prediction results 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 mlSolution = sn_ml.MLSolutionFactory.getSolution(\"ml_incident_categorization\");\n\n// single GlideRecord input\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 results = mlSolution.predict(input, options);\n// pretty print JSON results\ngs.print(JSON.stringify(JSON.parse(results), null, 2));\n```\n\n```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"ml_incident_categorization\");\n\n// multiple GlideRecord input\nvar input = new GlideRecord(\"incident\");\ninput.addQuery(\"sys_created_onONLast week@javascript:gs.beginningOfLastWeek()@javascript:gs.endOfLastWeek()\");\ninput.query();\n\n// configure optional parameters\nvar options = {};\noptions.top_n = 3;\noptions.apply_threshold = false;\n\nvar results = mlSolution.predict(input, options);\n// pretty print JSON results\ngs.print(JSON.stringify(JSON.parse(results), null, 2));\n```\n\nOutput:\n\n```\n{\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\n```\nvar mlSolution = sn_ml.MLSolutionFactory.getSolution(\"ml_incident_categorization\");\n\n// key-value pairs input\nvar input = [{\"short_description\":\"my email is not working\"}, \n\t\t\t{short_description:\"need help with password\"}];\n\n// configure optional parameters\nvar options = {};\noptions.top_n = 3;\noptions.apply_threshold = false;\n\nvar results = mlSolution.predict(input, options);\n// pretty print JSON results\ngs.print(JSON.stringify(JSON.parse(results), null, 2));\n```\n\n"}}