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


---

# ClusteringSolutionVersion - Global

# ClusteringSolutionVersion - Global {#ariaid-title1}

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

The ClusteringSolutionVersion API is a scriptable object used in Predictive Intelligence stores.

This API requires the Predictive Intelligence plugin (com.glide.platform_ml) and is provided within the `sn_ml` namespace.

It is used for working with solution versions based on [ClusteringSolution API](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSolutionAPI "The ClusteringSolution API is a scriptable object used in Predictive Intelligence stores.") objects in the [ClusteringSolution store](https://servicenow-prod.fluidtopics.net/WcUoxo34dGjAbOCgbnQYMQ#ClusteringSolutionStoreAPI "Enables storing and retrieving solutions.").

The system creates a solution version each time you train
a solution definition. Most versions are created during scheduled solution
training.  
Methods in this API are accessible using the following ClusteringSolution methods:

* [getActiveVersion()](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSol-getActiveVersion "Gets the active ClusteringSolutionVersion object.")
* [getAllVersions()](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSol-getAllVersions "Gets all versions of a clustering solution.")
* [getLatestVersion()](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSol-getLatestVersion "Gets the latest version of a solution.")
* [getVersion()](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSol-getVersion_S "Gets a solution by provided version number.")
{#ClusteringSolutionVersionAPI__ul_ycl_fzf_tlb}

## ClusteringSolutionVersion - cancelUpdateJob() {#ariaid-title2}

Cancels an update job on a trainer.
{#C-cancelUpdateJob__table_cb4_q3b_rlb__entry__3}

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

{#C-cancelUpdateJob__table_cb4_q3b_rlb} {#C-cancelUpdateJob__table_db4_q3b_rlb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 2. Returns]

{#C-cancelUpdateJob__table_db4_q3b_rlb}  
The following example shows how to cancel an active training job that has been submitted
using the [submitTrainingJob()](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSol-submitTrainingJob "Submits a training job.") method.

    var myCluster = new sn_ml.ClusteringSolutionStore.get("ml_x_snc_global_global_clustering_solution");
    var mlSolutionVersion = myCluster.getActiveVersion();

    mlSolutionVersion.cancelUpdateJob();

## ClusteringSolutionVersion - deleteClusterAssignments(Object options) {#ariaid-title3}

Deletes cluster assignments from rows by position in table sequence or
GlideDateTime.
{#C-deleteClusterAssignments_O__table_cwv_r3b_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| options | Object | Object defining one option for deleting cluster assignments. Note: Only one delete option is valid. |
| options.updatedUntil | String | Deletes rows for clusters with updated_since values occurring before this value. Format must be provided as [GlideDateTime](https://servicenow-prod.fluidtopics.net/tvAoVJXo8tw~UsFkybHP0g#c_GlideDateTimeAPI "The GlideDateTime class provides methods for performing operations on GlideDateTime objects."). { "updatedUntil" : "String" } |
| options.sequenceUntil | String | Deletes rows for clusters with insert_sequence values occurring before this value in the ML Cluster Detail \[ml_cluster_detail\] table. The sequence position starting point value is 1. { "sequenceUntil" : Number } |
[Table 3. Parameters]

{#C-deleteClusterAssignments_O__table_cwv_r3b_rlb} {#C-deleteClusterAssignments_O__table_dwv_r3b_rlb__entry__2}

| Type | Description |
|-|-|
| Number | Number of rows deleted from the ML Cluster Detail \[ml_cluster_detail\] table. |
[Table 4. Returns]

{#C-deleteClusterAssignments_O__table_dwv_r3b_rlb}  
The following example shows how to delete rows for clusters with
updated_since time preceding <kbd class="ph userinput">'2020-06-28 02:50:53'</kbd>.

    var mlSolution = sn_ml.ClusteringSolutionStore.get("ml_x_snc_global_global_clustering_solution");

    var mlSolutionVersion = mlSolution.getActiveVersion();

    var options = {};
    options.updatedUntil = '2020-06-28 02:50:53';

    var results = mlSolutionVersion.deleteClusterAssignments(options);

    gs.print("Number of deleted rows: "+results);

Output:

    Number of deleted rows: 6417

The following example shows how to delete rows for clusters with
updated_since that are sequentially positioned prior to
<kbd class="ph userinput">1000</kbd>.

    var mlSolution = sn_ml.ClusteringSolutionStore.get("ml_x_snc_global_global_clustering_solution");

    var mlSolutionVersion = mlSolution.getActiveVersion();

    var options = {};
    options.sequenceUntil = 1000;

    var results = mlSolutionVersion.deleteClusterAssignments(options);

    gs.print("Number of deleted rows: "+results);

Output:

    Number of deleted rows: 999

## ClusteringSolutionVersion - getClusterAssignments(Object options) {#ariaid-title4}

Gets assignments for a clustering solution.
{#C-getClusterAssignments_O__table_gby_x2w_plb__entry__3}{#C-getClusterAssignments_O__ml-cluster-create-xbl}

| Name | Type | Description |
|-|-|-|
| options | Object | Values to use to narrow down the returned results by group, level, system update times, and table row number within a clustering solution. Minimum of one argument must be specified. { "cluster_id": "String", "group_by": "String", "limit": Number, "sequenceSince": Number, "sequenceUntil": Number, "topNPerCluster": Number, "updatedSince": "String", "updatedUntil": "String" } |
| options.cluster_id | String | Optional. Cluster ID of a trained solution in the Cluster Summary \[ml_cluster_summary\] table. |
| options.group_by | String | Optional. 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://www.servicenow.com/docs/access?context=create-clustering-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US) . |
| options.limit | Number | Optional. Maximum number of cluster assignments to retrieve. |
| options.sequenceSince | Number | Starting position in a table sequence. Returns information for clusters with insert_sequence enabled and positioned after this value in the ML Cluster Detail \[ml_cluster_detail\] table. The sequence position starting point value is 1. |
| options.sequenceUntil | Number | Returns assignments for clusters with insert_sequence values occurring before this value in the ML Cluster Detail \[ml_cluster_detail\] table. The sequence position starting point value is 1. |
| options.topNPerCluster | Number | Number of top results to receive for each cluster. |
| options.updatedSince | String | Optional. Date and time. Returns information for clusters with sys_updated_on after the value provided in [GlideDateTime](https://servicenow-prod.fluidtopics.net/tvAoVJXo8tw~UsFkybHP0g#c_GlideDateTimeAPI "The GlideDateTime class provides methods for performing operations on GlideDateTime objects."). |
| options.updatedUntil | String | Optional. Date and time. Returns information for clusters with sys_updated_on before the value provided in [GlideDateTime](https://servicenow-prod.fluidtopics.net/tvAoVJXo8tw~UsFkybHP0g#c_GlideDateTimeAPI "The GlideDateTime class provides methods for performing operations on GlideDateTime objects."). |
[Table 5. Parameters]

{#C-getClusterAssignments_O__table_gby_x2w_plb} {#C-getClusterAssignments_O__table_u1q_hxt_rhb__entry__2}

| Type | Description |
|-|-|
| Array | List of objects containing cluster information in increasing order by cluster_id. [ { "cluster_id": "String", "group_by": "String", "rec_display_id": "String", "rec_sys_id": "String" } ] |
| \<object\>.cluster_id | Unique cluster number within a solution of clusters. |
| \<object\>.group_by | If grouped, name of the segmentation field associated with this cluster. |
| \<object\>.rec_display_id | Record type and number. |
| \<object\>.rec_sys_id | Record sys_id. |
[Table 6. Returns]

{#C-getClusterAssignments_O__table_u1q_hxt_rhb}  
The following example shows how to use the options object to filter
clustering results.

    var mlSolution = sn_ml.ClusteringSolutionStore.get("solution_name");

    var mlSolutionVersion = mlSolution.getActiveVersion();

    var options = {};
    options.clusterId = 56;
    options.topNPerCluster = 10;
    options.updatedUntil = '2020-01-17 23:16:14'; 
    options.updatedSince = '2020-01-17 23:16:13'; 
    options.sequenceUntil = 1000; 
    options.sequenceSince = 1100; 
    options.limit = 100;

    var results = mlSolutionVersion.getClusterAssignments(options)

    gs.print(results);

Output:

    [{"cluster_id":"1","rec_display_id":"Incident": "INC0014483","rec_sys_id":"04e33e7adb401300864adfea5e961900","group_by":"network"},
     {"cluster_id":"1","rec_display_id":"Incident": "INC0011133","rec_sys_id":"5bd23af2db401300864adfea5e96194d","group_by":"network"}]

## ClusteringSolutionVersion - getClusterInfo(Object options) {#ariaid-title5}

Gets information for a specified clustering solution in the store. The purity measurement provides insights as a percentage for the clustering
fields on which the purity is based.
{#C-getClusterInfo_O__table_gby_x2w_plb__entry__3}{#C-getClusterInfo_O__ml-cluster-create-xbl}

| Name | Type | Description |
|-|-|-|
| options | Object | Optional. Object containing properties that enable filtering results within a clustering solution. { "clusterId": "String", "groupBy": "String", "limit": "String", "recSysId": "String", "sequenceSince": Number, "sequenceUntil": Number, "updatedSince": "String", "updatedUntil": "String" } Default: Return cluster memberships for all clusters. |
| options.clusterId | String | Optional. Cluster ID of a trained solution in the Cluster Summary \[ml_cluster_summary\] table. |
| options.groupBy | String | Optional. 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://www.servicenow.com/docs/access?context=create-clustering-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US) . |
| options.limit | Number | Optional. Maximum number of cluster assignments to retrieve. |
| options.recSysId | String | Optional. Sys_id of a record by which to find cluster information. |
| options.sequenceSince | Number | Starting position in a table sequence. Returns information for clusters with insert_sequence enabled and positioned after this value in the ML Cluster Detail \[ml_cluster_detail\] table. The sequence position starting point value is 1. |
| options.sequenceUntil | Number | Optional. Ending position in a table sequence. Returns assignments for clusters with insert_sequence values occurring before this value in the ML Cluster Detail \[ml_cluster_detail\] table. The sequence position starting point value is 1. |
| options.updatedSince | String | Optional. Date and time. Returns information for clusters with sys_updated_on after the value provided in [GlideDateTime](https://servicenow-prod.fluidtopics.net/tvAoVJXo8tw~UsFkybHP0g#c_GlideDateTimeAPI "The GlideDateTime class provides methods for performing operations on GlideDateTime objects.") format. |
| options.updatedUntil | String | Optional. Date and time. Returns information for clusters with sys_updated_on before the value provided in [GlideDateTime](https://servicenow-prod.fluidtopics.net/tvAoVJXo8tw~UsFkybHP0g#c_GlideDateTimeAPI "The GlideDateTime class provides methods for performing operations on GlideDateTime objects."). |
[Table 7. Parameters]

{#C-getClusterInfo_O__table_gby_x2w_plb} {#C-getClusterInfo_O__table_xk3_v3b_rlb__entry__2}

| Type | Description |
|-|-|
| Array | List of objects containing cluster information. [ { "cluster_concept": "String", "cluster_id": "String", "cluster_quality": "String", "cluster_size": "String", "group_by": "String", "insert_sequence": "String", "purity": "String", "sys_updated_on": "String" } ] |
| \<object\>.cluster_concept | Set of words that describe the cluster in descending order of frequency. Data type: String |
| \<object\>.cluster_id | Unique cluster number within a solution of clusters. |
| \<object\>.cluster_quality | Number from 0 to 100. Higher numbers indicate higher cluster density. Data type: String |
| \<object\>.cluster_size | Number of records in a cluster. Data type: String |
| \<object\>.group_by | If grouped, name of the segmentation field associated with this cluster. Data type: String |
| \<object\>.insert_sequence | Sequential position number of the cluster in the Cluster Summary \[ml_cluster_summary\] table. Data type: String |
| \<object\>.purity | Percentage value representing the purity of cluster quality. |
| \<object\>.sys_updated_on | System [GlideDateTime](https://servicenow-prod.fluidtopics.net/xOhnNqU1cKMjoQSfmtxVCw#c_GlideDateTimeScoped "The scoped GlideDateTime class provides methods for performing operations on GlideDateTime objects.") value representing the date and time at which this cluster was last updated. Data type: String |
[Table 8. Returns]

{#C-getClusterInfo_O__table_xk3_v3b_rlb}  
The following example shows how to set the options object parameter and print the filtered
cluster results.

    var mlSolution = sn_ml.ClusteringSolutionStore.get("ml_x_snc_global_global_clustering_solution");

    var mlSolutionVersion = mlSolution.getActiveVersion();

    var options = {};
    options.updatedSince = '2020-05-28 02:09:53'; 
    options.updatedUntil = '2020-05-28 03:15:00';
    options.sequenceSince = 1;
    options.limit = 10;

    var results = mlSolutionVersion.getClusterInfo(options);

    gs.print(JSON.stringify(JSON.parse(results), null, 2));

Output:

    [
      {
        "cluster_id": "1",
        "cluster_quality": "100",
        "cluster_size": "17",
        "purity": "",
        "insert_sequence": "8",
        "group_by": "VPN   Customer",
        "sys_updated_on": "2020-05-28 02:09:53",
        "cluster_concept": "vpn instance connection ldap user log unable usability tunnel"
      },
      {
        "cluster_id": "1",
        "cluster_quality": "100",
        "cluster_size": "10",
        "purity": "",
        "insert_sequence": "24",
        "group_by": "Live Feed",
        "sys_updated_on": "2020-05-28 02:09:53",
        "cluster_concept": "feed live user note work disable group default usability sort"
      },
      {
        "cluster_id": "1",
        "cluster_quality": "100",
        "cluster_size": "18",
        "purity": "",
        "insert_sequence": "40",
        "group_by": "Integrations",
        "sys_updated_on": "2020-05-28 02:09:53",
        "cluster_concept": "integrate usability certificate error"
      },
    ...
    ]

## ClusteringSolutionVersion - getProperties() {#ariaid-title6}

Gets solution object properties
and version number.
{#C-getProperties__table_d2m_zwz_4lb__entry__3}

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

{#C-getProperties__table_d2m_zwz_4lb} {#C-getProperties__table_e2m_zwz_4lb__entry__2}{#C-getProperties__solution-obj-group-desc}

| Type | Description |
|-|-|
| Object | Contents of the Dataset and [ClusteringSolution](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSol-ClusteringSolution_O "Creates a cluster solution.") version details. Results vary by object property setup. { "algorithmConfig": {Object}, "datasetProperties": {Object}, "domainName": "String", "groupByFieldName": "String", "inputFieldNames": [Array], "isActive": Boolean, "label": "String", "minRecordsPerCluster": Number, "name": "String", "processingLanguage": "String", "scope": "String", "stopwords": [Array], "trainingFrequency": "String", "updateFrequency": "String", "versionNumber": Number } |
| \<Object\>.algorithmConfig | JavaScript object containing algorithm configuration properties. Property results vary by the value set in the algorithm property. Data type: Object 'algorithmConfig' : { "algorithm": "String", // See algorithmConfig.algorithm setting description for property settings based on algorithm } |
| \<Object\>.algorithmConfig.algorithm | Method for encoding your solution. Properties for dbscan: 'algorithmConfig': { "algorithm": "dbscan", "distanceMetric": "String", "epsilon": Number, "minimumNeighbours": Number } Properties for kmeans: 'algorithmConfig': { "algorithm": "kmeans", "targetCoverage": Number } Data type: String |
| \<Object\>.algorithmConfig.distanceMetric | DBSCAN algorithm only. Distance metric to scan for similar data objects. Data type: String |
| \<Object\>.algorithmConfig.epsilon | DBSCAN algorithm only. Decimal value between 0 and 1 representing the size of the neighborhood search radius. Data type: Number |
| \<Object\>.algorithmConfig.minimumNeighbours | DBSCAN algorithm only. Minimum number of neighbors required in a point to be a part of a cluster. For levenshteinDistance the value must be 1 so that no points are excluded from the dataset. Data type: Number |
| \<Object\>.algorithmConfig.targetCoverage | K-means algorithm only. Percentile field to filter out records that are less similar to each other. Data type: Number |
| \<Object\>.datasetProperties | Lists the properties of the [DatatsetDefinition](https://servicenow-prod.fluidtopics.net/5PRN6njd2wF_we1ri_egPw#DatasetDefinitionAPI "The DatasetDefinition API provides methods to identify a set of records including a table name, columns, and row selection criteria to use as input for ML training algorithms. Datasets don't contain the actual data.") object associated with the solution. { "encodedQuery": "String", "fieldDetails": [Array], "fieldNames": [Array], "tableName": "String" } Data type: Object |
| \<Object\>.datasetProperties.encodedQuery | Encoded query string in standard Glide format. See [Encoded query strings](https://www.servicenow.com/docs/access?context=c_EncodedQueryStrings&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US). Data type: String |
| \<Object\>.datasetProperties.fieldDetails | List of JavaScript objects that specify field properties. Data type: Array of Objects [ { "name": "String", "type": "String" } ] |
| \<Object\>.datasetProperties.fieldDetails.name | Name of the field defining the type of information to restrict this dataset to. Data type: String |
| \<Object\>.datasetProperties.fieldDetails.type | Machine-learning field type. Data type: String |
| \<Object\>.datasetProperties.fieldNames | List of field names from the specified table as strings. For example, `"fieldNames" : ["short_description", "priority"]`. Data type: Array |
| \<Object\>.datasetProperties.tableName | Name of the table for the dataset. For example, `"tableName" : "Incident"`. Data type: String |
| \<Object\>.domainName | Domain name associated with this dataset. See [Domain separation and Predictive Intelligence](https://www.servicenow.com/docs/access?context=domain-separation-predictive-intelligence&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). Data type: String |
| Object.groupByFieldName | Field name by which the system groups records into one or more clusters. Data type: String |
| Object.inputFieldNames | List of input field names as strings. The model uses these fields used to make predictions. Data type: String |
| \<Object\>.isActive | Flag that indicates whether this version is active. Valid values: * true: Version is active. * false: Version is not active. {#C-getProperties__ul_i5m_lp1_dmb} Data type: String |
| \<Object\>.label | Identifies the prediction task. { "label": "my first prediction" } Data type: String |
| \<Object\>.minRecordsPerCluster | Minimum number of records to allow in any cluster. Data type: Number |
| \<Object\>.name | System-assigned name. Data type: String |
| \<Object\>.processingLanguage | Processing language in two-letter ISO 639-1 language code format. Data type: String |
| \<Object\>.scope | Object scope. Currently the only valid value is `global`. Data type: String |
| \<Object\>.stopwords | Optional. Preset list of strings that the system automatically generates based on the language property setting. For details, see [Create a custom stopwords list](https://www.servicenow.com/docs/access?context=create-custom-stopwords-list&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). Data type: Array |
| \<Object\>.trainingFrequency | The frequency to retrain the model. Possible values: * every_30_days * every_60_days * every_90_days * every_120_days * every_180_days * run_once {#C-getProperties__ul_pmw_523_plb}Default: run_once Data type: String |
| \<Object\>.updateFrequency | The frequency at which the model for the solution definition must be rebuilt. Possible values: * do_not_update * every_1_day * every_1_hour * every_6_hours * every_12_hours * every_1_minute * every_15_minutes * every_30_minutes {#C-getProperties__ul_kjm_2jh_3mb}Default: do_not_update Data type: String |
| \<Object\>.versionNumber | Version number of the ClusteringSolution object. |
[Table 10. Returns]

{#C-getProperties__table_e2m_zwz_4lb}  
The following example gets properties of the active object
version in the store.

    // Get properties
    var mlSolution = sn_ml.ClusteringSolutionStore.get('ml_x_snc_global_global_clustering_solution');

    gs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getProperties()), null, 2));

Output:

    *** Script: {
      "algorithmConfig": {
        "algorithm": "kmeans",
        "targetCoverage": "90"
      },
      "datasetProperties": {
        "tableName": "incident",
        "fieldNames": [
          "category",
          "short_description",
          "state",
          "description"
        ],
        "encodedQuery": "activeANYTHING"
      },
      "domainName": "global",
      "groupByFieldName": "category",
      "inputFieldNames": [
        "short_description"
      ],
      "isActive": "true",
      "label": "clustering solution",
      "minRecordsPerCluster": 2,
      "name": "ml_x_snc_global_global_clustering_solution",
      "processingLanguage": "en",
      "stopwords": [
        "Default English Stopwords"
      ],
      "updateFrequency": "do_not_update",
      "versionNumber": "1"
    }

## ClusteringSolutionVersion - getStatus(Boolean includeDetails) {#ariaid-title7}

Gets training completion status.
{#C-getStatus_B__table_xfh_vbw_plb__entry__3}

| Name | Type | Description |
|-|-|-|
| includeDetails | Boolean | Flag that indicates whether to return status details. Valid values: * true: Return additional details. * false: Don't return additional details. {#C-getStatus_B__ul_n33_ckw_plb} Default: False |
[Table 11. Parameters]

{#C-getStatus_B__table_xfh_vbw_plb} {#C-getStatus_B__table_yfh_vbw_plb__entry__2}

| Type | Description |
|-|-|
| Object | JavaScript object containing training status information for a [ClusteringSolution](https://servicenow-prod.fluidtopics.net/1UtA64JFiuMrifx24cx4og#ClusteringSolutionAPI "The ClusteringSolution API is a scriptable object used in Predictive Intelligence stores.") object. { "state": "String", "percentComplete": "Number as a String", "hasJobEnded": "Boolean value as a String", "details": {Object} } |
| \<Object\>.state | Training completion state. If the training job reaches a terminal state, the job does not leave that state. If the state is terminal, the hasJobEnded property is set to `true`. Possible values: * fetching_files_for_training * preparing_data * retry * solution_cancelled (terminal) * solution_complete (terminal) * solution_error (terminal) * solution_incomplete * training_request_received * training_request_timed_out (terminal) * training_solution * uploading_solution * waiting_for_training {#C-getStatus_B__ul_a5q_gh4_vlb} Data type: String |
| \<Object\>.hasJobEnded | Flag that indicates whether training is complete. Valid values: * true: Training is complete. * false: Training is incomplete. {#C-getStatus_B__ul_icy_zjx_rlb} Data type: Boolean value as a String |
| \<Object\>.percentComplete | Training percent complete. If the completion percentage is less than 100, the job might be in a terminal state. For example, if training times out. Data type: Number as a String Range: 0 thru 100 |
| \<Object\>.details | Object containing a list of additional training details. Data type: Object |
[Table 12. Returns]

{#C-getStatus_B__table_yfh_vbw_plb}  
The following example shows a successful result
with training complete.

    // Get status
    var mlSolution = sn_ml.ClusteringSolutionStore.get('ml_x_snc_global_global_cluster_solution');

    gs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getStatus(true), null, 2)));

Output:

    {
     "state":"solution_complete",
     "percentComplete":"100",
     "hasJobEnded":"true",
     "details":{"stepLabel":"Solution Complete"} // This information is only returned if getStatus(true);
    }

The following example shows an unsuccessful
result with training complete.

    // Get status
    var solutionName = 'ml_x_snc_global_global_cluster_solution';
    var mlSolution = sn_ml.ClusteringSolutionStore.get(solutionName);
    var trainingStatus = mlSolution.getLatestVersion().getStatus();

    gs.print(JSON.stringify(JSON.parse(trainingStatus), null, 2));

Output:

    {
     "state":"solution_error",
     "percentComplete":"100",
     "hasJobEnded":"true"
    }

## ClusteringSolutionVersion - getTopNPurityInfo(Object options) {#ariaid-title8}

Gets the top purity results for a clustering solution. The purity measurement provides
insights as a percentage for the clustering fields on which the purity is based.
{#C-getTopNPurityInfo_O__table_q13_tk3_wnb__entry__3}

| Name | Type | Description |
|-|-|-|
| options | Object | Options that determine the number and format of the top cluster purity results. { "clusterIds": [Array], "groupBy": [Array], "purityFields": [Array], "topN": Number, "topNFields": Number } |
| options.clusterIds | Array | Optional. List of cluster IDs provided as strings. A cluster ID is provided in the Cluster Summary \[ml_cluster_summary\] table. If provided, this method returns purity cluster information for each specified cluster. Default: This method returns purity information for all clusters. |
| options.groupBy | Array | Optional. List of group_by field strings from your table to help the system identify the class which is most frequent in the cluster. If provided, returns purity information for cluster solutions using group_by fields. The Cluster Summary \[ml_cluster_summary\] table lists clusters and any associated Group by values. This field only applies to clusters that use group by in the clustering definition. Eligible fields are listed in the Table field. For details on the group by feature, refer to [Create and train a clustering solution](https://www.servicenow.com/docs/access?context=create-clustering-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). |
| options.purityFields | Array | Optional. List of purity field strings. If provided, this method only returns information for these purity fields. You can view purity values for a cluster in the Cluster Summary \[ml_cluster_summary\] table lists. Note: If both purity_fields and top_n_fields are provided, this method returns top_n_fields first, then selects fields from purity_fields. Default: Return purity information for all purity fields saved for the cluster. |
| options.topN | Number | Optional. Restricts the number of predictions to return to the highest values for each purity field. Maximum value: 10 Default: Return all purity information for each purity field. |
| options.topNFields | Number | Optional. Restricts the number of purity fields returned to fields with the highest purity for each cluster. Maximum value: 10 Default: Return all fields in the cluster. |
[Table 13. Parameters]

{#C-getTopNPurityInfo_O__table_q13_tk3_wnb} {#C-getTopNPurityInfo_O__table_r13_tk3_wnb__entry__2}

| Type | Description |
|-|-|
| String | JSON-formatted string containing a list of clusters with purity fields and details. Note: Results vary based on settings made in the options input parameter. The following information illustrates how cluster purity results are sorted and categorized. Refer to the example for actual output. { "<clusterID>":[ // List sorted by purity per field { "<fieldName>":[ // List sorted by purity per field value {"<field_val1_1>":"<purity>"}, // Additional field values ]}, // Additional fields ], // Additional clusters } |
| String.\<clusterID\> | List of clusters arranged in descending order by purity value per cluster. Data type: Array |
| String.\<clusterID\>.\<field\> | List of objects representing purity fields arranged in descending order by purity value per field. The options.top_n_fields input object parameter property determines the number of fields returned. "<field>":[{"<field_val>":"<purity>"}]} Data type: Array |
| String.\<clusterID\>.\<field\>.\<values\> | List of objects containing field value and purity. For example, `{"priority":[{"5":"100"}]}` is a priority field with a score of 5 and a purity value of 100 percent. Results list in descending order by purity percentage. The options.top_n input object parameter property determines the number of results returned. Data type: Array |
[Table 14. Returns]

{#C-getTopNPurityInfo_O__table_r13_tk3_wnb}  
The following example shows how to get the top two purity results for the category field in
specific cluster solutions.

    var solution = new GlideRecord('ml_solution');
    solution.addQuery('sys_id', '<clustering_solution_sys_id>');
    solution.addQuery('active', 'true');
    solution.query();

    while (solution.next()) {

      var options = {};
      options.clusterIds = ['1', '3', '5'];
      options.purityFields = ['category'];
      options.topN = '2';
      options.topNFields = '2';

      var clustering = new sn_ml.ClusteringSolutionVersion(solution);
      var results = clustering.getTopNPurityInfo(options);

      gs.info(results);
    }

Output displays purity insights based on the settings provided in the options
parameter.

    {"1":[{"category":[{"network":"99.96"},{"inquiry":"0.04"}]}],"3":[{"category":[{"Systems Engineering":"100"}]}],
    "5":[{"category":[{"Security":"100"}]}]}

## ClusteringSolutionVersion - getUpdateStatus() {#ariaid-title9}

Gets the status of the most recent clustering solution update job.
{#C-getUpdateStatus__table_kx2_w3b_rlb__entry__3}

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

{#C-getUpdateStatus__table_kx2_w3b_rlb} {#C-getUpdateStatus__table_lx2_w3b_rlb__entry__2}

| Type | Description |
|-|-|
| String | State of the clustering solution update. States: * Configuration or network error * Error while updating solution * Fetching files for updating * Preparing data * Unauthorized * Update complete * Updating is cancelled * Updating request received * Updating request timed out * Updating solution * Uploading * Waiting {#C-getUpdateStatus__ul_fgs_w54_wlb} |
[Table 16. Returns]

{#C-getUpdateStatus__table_lx2_w3b_rlb}  
The following example shows how to get the update status of a clustering solution.

    var myCluster = new sn_ml.ClusteringSolutionStore.get("ml_x_snc_global_global_clustering_solution");

    gs.print(JSON.stringify(myCluster.getActiveVersion().getUpdateStatus()));

Output:

    "Update Complete"

## ClusteringSolutionVersion - getVersionNumber() {#ariaid-title10}

Gets the version number of a solution object.
{#C-getVersionNumber__table_jsz_sbw_plb__entry__3}

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

{#C-getVersionNumber__table_jsz_sbw_plb} {#C-getVersionNumber__table_ksz_sbw_plb__entry__2}

| Type | Description |
|-|-|
| String | Version number. |
[Table 18. Returns]

{#C-getVersionNumber__table_ksz_sbw_plb}  
The following example shows how to get a version
number.

    // Get version number
    var mlSolution = sn_ml.ClusteringSolutionStore.get('ml_x_snc_global_global_clustering_solution');

    gs.print("Version number: "+JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getVersionNumber()), null, 2));

Output:

    Version number: 1

## ClusteringSolutionVersion - submitUpdateJob(Object options) {#ariaid-title11}

Submits clustering update jobs with options to narrow results to a specific table and
filter for matching records.
{#C-submitUpdateJob_O__table_gby_x2w_plb__entry__3}

| Name | Type | Description |
|-|-|-|
| options | Object | JavaScript object containing options on which to base a clustering solution update. { "filter" : "String", "table" : "String" } |
| options.filter | String | Encoded query string in standard Glide format. See [Encoded query strings](https://www.servicenow.com/docs/access?context=c_EncodedQueryStrings&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US). Enables running an update job based on the filter provided. |
| options.table | String | Name of the table on which to run an update job. |
[Table 19. Parameters]

{#C-submitUpdateJob_O__table_gby_x2w_plb} {#C-submitUpdateJob_O__table_qpm_x3b_rlb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 20. Returns]

{#C-submitUpdateJob_O__table_qpm_x3b_rlb}  
The following example shows how to submit an update job.

    var myCluster = new sn_ml.ClusteringSolutionStore.get("ml_x_snc_global_global_clustering_solution");

    var options = {"filter" : "precision", "table" : "incident"};

    myCluster.getActiveVersion().submitUpdateJob(options);


