The MLSolutionResult API provides methods for managing cluster information and members of a clustering solution. You can embed the results in business logic.

Note: This API has been deprecated and is intended to be removed in a future release. Refer to Using ML APIs for the most recent guidelines.

MLSolutionResult - MLSolutionResult()

Instantiates a new MLSolutionResult object.

Table 1. Parameters
Name Type Description
None

MLSolutionResult - findActiveSolution(String solutionName)

Returns the solution object.

This 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 .

Table 2. Parameters
Name Type Description
solutionName String Name of the clustering ml_solution record.
Table 3. Returns
Type Description
Object Clustering solution object for the specified solutionName if the ml_solution definition and solution is active, null otherwise.

Example

var solutionName = 'ml_incident_assignment';
  var MLS = new MLSolutionResult();
  var solution = MLS.findActiveSolution(solutionName);
  gs.print(solution);
        

MLSolutionResult - getClusterAssignments(String solutionName, Object options)

Returns all members of a clustering solution.

Table 5. Returns
Type Description
Array Array of outcome objects including:
  • segmentation – Field name by which to group data
  • cluster_num – Unique cluster number within a solution of clusters (that is, label)
  • rec_sys_id – The sys_id from the table record that the cluster solution is based on
  • rec_display_id – Name of the record associated with the record sys_id.

Example

The following example shows how to return all cluster members for a solution without setting values for the options object.

var solutionName = "<Name_of_Active_Cluster_Solution>";
var solutionResult = new MLSolutionResult();
var outcome_array = solutionResult.getClusterAssignments(solutionName);
for (var i = 0; i < outcome_array.length; i++) {
   gs.print(outcome_array [i].segmentation + ' ' + outcome_array [i].cluster_num + ' ' + outcome_array [i].rec_sys_id + ' ' + outcome_array [i].rec_display_id);
}

Example

The following example shows how to return all cluster members for one record using options.rec_sys_id.

var now_GR = new GlideRecord('incident');
now_GR.get('sys_id');

var solutionName = "solution_example";
var solutionResult = new MLSolutionResult();
var options = { "rec_sys_id": now_GR.getUniqueValue() };
var outcome_array = solutionResult.getClusterAssignments(solutionName, options);
for (var i = 0; i < outcome_array.length; i++) {
   gs.print(outcome_array [i].segmentation + ' ' + outcome_array [i].cluster_num + ' ' + outcome_array [i].rec_sys_id + ' ' + outcome_array [i].rec_display_id);
}

MLSolutionResult - getClusterInfo(String solutionName, Object options)

Returns all outcome information for a clustering solution.

Table 7. Returns
Type Description
Array Array of outcome objects including:
  • segmentation – Field name by which to group data
  • cluster_num – Unique cluster number within a solution of clusters (that is, label)
  • total_members – Number of records in cluster (that is, size)
  • cluster_quality – Cluster quality percentile value

Example

var solutionName = "solution_example";
var solutionResult = new MLSolutionResult();
var outcome_array = solutionResult.getClusterInfo(solutionName);
for (var i = 0; i < outcome_array.length; i++) {
gs.print(outcome_array[i].segmentation + ' ' + outcome_array[i].cluster_num + ' ' + outcome_array[i].total_members + ' ' + outcome_array[i].cluster_quality);
}