{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":847,"path":"api-reference/server-api-reference/MLSolutionResultAPI.md","title":"MLSolutionResult - Global \\(deprecated\\)","bundle":null,"doc_type":null,"release":"australia","body":"\n# MLSolutionResult- Global \\(deprecated\\)\n\nThe MLSolutionResult API provides methods for managing cluster information and members of a clustering solution. You can embed the results in business logic.\n\n**Note:** This API has been deprecated and is intended to be removed in a future release. Refer to [Using ML APIs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/using-ml-apis.md) for the most recent guidelines.\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## MLSolutionResult - MLSolutionResult\\(\\)\n\nInstantiates a new MLSolutionResult object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n## MLSolutionResult - findActiveSolution\\(String solutionName\\)\n\nReturns the solution object.\n\nThis method only returns the solutions if the ml\\_solution definition and solution are active \\(that is, trained\\). For information, see [Create and train a clustering solution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/create-clustering-solution.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|solutionName|String|Name of the clustering ml\\_solution record.|\n\n|Type|Description|\n|----|-----------|\n|Object|Clustering solution object for the specified `solutionName` if the ml\\_solution definition and solution is active, null otherwise.|\n\n```\nvar solutionName = 'ml_incident_assignment';\n  var MLS = new MLSolutionResult();\n  var solution = MLS.findActiveSolution(solutionName);\n  gs.print(solution);\n        \n```\n\n## MLSolutionResult - getClusterAssignments\\(String solutionName, Object options\\)\n\nReturns all members of 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\nsolutionName\n\n</td><td>\n\nString\n\n</td><td>\n\nName of active cluster solution.\n\n</td></tr><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.segmentation\\_field\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 via **Use Group By** check box in **Clustering Solution Definitions** table. Information provided varies by table selected in the **Table** field. For 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. The sys\\_id from the ml\\_cluster\\_summary table.\n\n</td></tr><tr><td>\n\noptions.rec\\_sys\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. The sys\\_id from the table record the cluster solution is based on.\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\nArray\n\n</td><td>\n\nArray of outcome objects including:-   segmentation – Field name by which to group data\n-   cluster\\_num – Unique cluster number within a solution of clusters \\(that is, label\\)\n-   rec\\_sys\\_id – The sys\\_id from the table record that the cluster solution is based on\n-   rec\\_display\\_id – Name of the record associated with the record sys\\_id.\n\n</td></tr></tbody>\n</table>The following example shows how to return all cluster members for a solution without setting values for the options object.\n\n```\nvar solutionName = \"<Name_of_Active_Cluster_Solution>\";\nvar solutionResult = new MLSolutionResult();\nvar outcome_array = solutionResult.getClusterAssignments(solutionName);\nfor (var i = 0; i < outcome_array.length; i++) {\n   gs.print(outcome_array [i].segmentation + ' ' + outcome_array [i].cluster_num + ' ' + outcome_array [i].rec_sys_id + ' ' + outcome_array [i].rec_display_id);\n}\n```\n\nThe following example shows how to return all cluster members for one record using options.rec\\_sys\\_id.\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.get('sys_id');\n\nvar solutionName = \"solution_example\";\nvar solutionResult = new MLSolutionResult();\nvar options = { \"rec_sys_id\": now_GR.getUniqueValue() };\nvar outcome_array = solutionResult.getClusterAssignments(solutionName, options);\nfor (var i = 0; i < outcome_array.length; i++) {\n   gs.print(outcome_array [i].segmentation + ' ' + outcome_array [i].cluster_num + ' ' + outcome_array [i].rec_sys_id + ' ' + outcome_array [i].rec_display_id);\n}\n```\n\n## MLSolutionResult - getClusterInfo\\(String solutionName, Object options\\)\n\nReturns all outcome information for a 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\nsolutionName\n\n</td><td>\n\nString\n\n</td><td>\n\nName of active cluster solution.\n\n</td></tr><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.segmentation\\_field\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 via **Use Group By** check box in **Clustering Solution Definitions** table. Information provided varies by table selected in the **Table** field. For 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. The sys\\_id from the 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\nArray\n\n</td><td>\n\nArray of outcome objects including:-   segmentation – Field name by which to group data\n-   cluster\\_num – Unique cluster number within a solution of clusters \\(that is, label\\)\n-   total\\_members – Number of records in cluster \\(that is, size\\)\n-   cluster\\_quality – Cluster quality percentile value\n\n</td></tr></tbody>\n</table>```\nvar solutionName = \"solution_example\";\nvar solutionResult = new MLSolutionResult();\nvar outcome_array = solutionResult.getClusterInfo(solutionName);\nfor (var i = 0; i < outcome_array.length; i++) {\ngs.print(outcome_array[i].segmentation + ' ' + outcome_array[i].cluster_num + ' ' + outcome_array[i].total_members + ' ' + outcome_array[i].cluster_quality);\n}\n```\n\n"}}