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


---

# ClassificationSolutionVersion - Global

# ClassificationSolutionVersion - Global {#ariaid-title1}

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

The ClassificationSolutionVersion 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.

This API is used for working with solution versions based on [ClassificationSolution API](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassificationSolutionAPI "The ClassificationSolution API is a scriptable object used in Predictive Intelligence stores.") objects in the [ClassificationSolution store](https://servicenow-prod.fluidtopics.net/qGtKN6FosUL3scH7MfLfHw#ClassificationSolutionStoreAPI "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 [ClassificationSolution - Global](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassificationSolutionAPI "The ClassificationSolution API is a scriptable object used in Predictive Intelligence stores.") methods:

* [getActiveVersion()](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassifictnSol-getActiveVersion "Gets the active ClassificationSolutionVersion object.")
* [getAllVersions()](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassifictnSol-getAllVersions "Gets all versions of a classification solution.")
* [getLatestVersion()](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassifictnSol-getLatestVersion "Gets the latest version of a solution.")
* [getVersion()](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassifictnSol-getVersion_S "Gets a solution by provided version number.")
{#ClassificationSolutionVersionAPI__ul_ycl_fzf_tlb}

## ClassificationSolutionVersion - getPredictionPerformance(Object options) {#ariaid-title2}

Calculates solution precision and coverage.
To use this method, you must first create settings using the
setPredictionSettings() method.
{#ClssfnV-getPredictionPerformance_O__table_gby_x2w_plb__entry__3}

| Name | Type | Description |
|-|-|-|
| options | Object | Selects a metric to retrieve within a span of dates. For more information, see [Configuring target metrics](https://www.servicenow.com/docs/access?context=configuring-target-metrics-trained-classification-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). { "fromDate": "String", "metricName": "String", "toDate": "String" } |
| options.fromDate | String | Optional. Start date from which to retrieve metrics in system date time format. |
| options.metricName | String | Name of the metric. Valid values: * precision * coverage {#ClssfnV-getPredictionPerformance_O__ul_ncd_ldx_plb} |
| options.toDate | String | Optional. End date from which to retrieve metrics. Formnt: System date time format. |
[Table 1. Parameters]

{#ClssfnV-getPredictionPerformance_O__table_gby_x2w_plb} {#ClssfnV-getPredictionPerformance_O__table_hby_x2w_plb__entry__2}

| Type | Description |
|-|-|
| Object | Parseable JavaScript object containing the results for the input metric. { "metricName" : "String", "metricValue" : "String", "numberOfPredictionsConsidered" : "String" } |
| Object.metricName | Name of metric selected as input. Data type: String |
| Object.metricValue | Value of the selected metric. Data type: String |
| Object.numberOfRecordsConsidered | Number of records in the Predictor Results \[ml_predictor_results\] table considered for calculations. Data type: String |
[Table 2. Returns]

{#ClssfnV-getPredictionPerformance_O__table_hby_x2w_plb}  
The following example shows how to get a precision value from the active version of a
solution.

    // Get precision value
    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

    gs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getPredictionPerformance({"metricName": "precision"})), null, 2));

Output:

    {
      "metricName": "precision",
      "metricValue": "70.10",
      "numberOfPredictionsConsidered": "10"
    }

## ClassificationSolutionVersion - getPredictionSettings() {#ariaid-title3}

Gets estimated precision, estimated coverage, estimated recall values from the ML
Solutions \[ml_solution\] table and records from the Class Confidence \[ml_class\]
table.
{#ClssfnV-getPredictionSettings__table_eq3_xbw_plb__entry__3}

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

{#ClssfnV-getPredictionSettings__table_eq3_xbw_plb} {#ClssfnV-getPredictionSettings__table_wph_2dw_plb__entry__2}

| Type | Description |
|-|-|
| Object | Returns prediction settings for each class. Data includes precision, coverage, recall, and distribution values of all classes included in the trained model from the ML Solutions \[ml_solution\] table. For details, see [Predictive model components](https://www.servicenow.com/docs/access?context=predictive-intelligence&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). { "<class name>": {Object} } |
| \<Object\>.\<class name\> | Training statistics data from the Class Confidence \[ml_class\] table. For more information, see [Configuring target metrics](https://www.servicenow.com/docs/access?context=configuring-target-metrics-trained-classification-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). Data type: Object { "precision": "String", "coverage": "String", "recall": "String" } |
| \<Object\>.\<class name\>.precision | Estimated solution precision metric for this class. Data type: String (numerical value) |
| \<Object\>.\<class name\>.coverage | Estimated solution coverage metric for this class. Data type: String (numerical value) |
| \<Object\>.\<class name\>.recall | Estimated solution recall metric for this class. Data type: String (numerical value) |
[Table 4. Returns]

{#ClssfnV-getPredictionSettings__table_wph_2dw_plb}  
The following example shows how to get prediction settings of an active solution
version.

    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

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

Output:

    {
      "solutionSettings": {
        "precision": "61.69",
        "coverage": "66.75",
        "recall": "57.54"
      },
      "classSettings": {
        "Approvals": {
          "precision": "100",
          "coverage": "0",
          "recall": "0"
        },
        "Authentication": {
          "precision": "38.71",
          "coverage": "98.44",
          "recall": "56.25"
        },
        "Automation": {
          "precision": "100",
          "coverage": "0",
          "recall": "0"
        }, ...

## ClassificationSolutionVersion - getProperties() {#ariaid-title4}

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

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

{#ClssfnV-getProperties__table_d2m_zwz_4lb} {#ClssfnV-getProperties__table_e2m_zwz_4lb__entry__2}{#ClssfnV-getProperties__classification-obj-group-desc}

| Type | Description |
|-|-|
| Object | Contents of the Dataset and [ClassificationSolution](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassifictnSol-ClassificationSolution_O "Creates a classification solution.") version details. Results vary by object property setup. { "algorithmConfig": { "algorithm": "String", "targetClassRecall": "String" }, "datasetProperties": {Object}, "domainName": "String", "encoder": {Object}, "groupByFieldName": "String", "inputFieldNames": [Array], "isActive": Boolean, "label": "String", "name": "String", "predictedFieldName": "String", "processingLanguage": "String", "scope": "String", "stopwords": [Array], "stopwords": [Array], "trainingFrequency": "String", "versionNumber": "Number" } |
| \<Object\>.algorithmConfig | Method for encoding the solution. Data type: Object |
| \<Object\>.algorithmConfig.algorithm | Name of the encoding algorithm for training this solution. Possible values: * xgboost: XGBoost encoding to optimize the training. * logisticRegression: Method using the logistic regression model for categorical targets such as nominal or ordinal. {#ClssfnV-getProperties__ul_wtd_l2k_xlb} Data type: String |
| \<Object\>.algorithmConfig.targetClassRecall | Class recall parameter to steer a solution's training to bias a specific class. The recall value is a number between 0 and 100 representing a percentage. Data type: String |
| \<Object\>.datasetProperties | Lists the properties of the [DatasetDefinition()](https://servicenow-prod.fluidtopics.net/5PRN6njd2wF_we1ri_egPw#DDef-DatasetDefinition_O "Creates an instance of the DatasetDefinition class, enabling you to define a dataset by table name, fields, and query.") object associated with the solution. Data type: Object { "encodedQuery": "String", "fieldDetails": [Array], "fieldNames": [Array], "tableName": "String" } |
| \<Object\>.datasetProperties.tableName | Name of the table for the dataset. For example, `"tableName" : "Incident"`. 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.fieldNames.fieldDetails | List of JavaScript objects that specify field properties. Data type: Array of Objects [ { "name": "String", "type": "String" } ] |
| \<Object\>.datasetProperties.fieldNames.fieldDetails.\<object\>.name | Name of the field defining the type of information to restrict this dataset to. Data type: String |
| \<Object\>.datasetProperties.fieldDetails.\<object\>.type | Machine-learning field type. Data type: String |
| \<Object\>.datasetProperties.fieldDetails.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\>.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\>.encoder | Encoder object assigned to this solution. See [Encoder - Encoder(Object config)](https://servicenow-prod.fluidtopics.net/lD2dU3P5hPYTlVdnWNZofg#Encoder-Encoder_O "Creates an encoder."). Data type: Object |
| \<Object\>.groupByFieldName | Field name by which the system groups records to build classification solutions. 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. {#ClssfnV-getProperties__ul_i5m_lp1_dmb} Data type: String |
| \<Object\>.label | Identifies the prediction task. { "label": "my first prediction" } Data type: String |
| \<Object\>.name | System-assigned name. Data type: String |
| \<Object\>.predictedFieldName | Identifies a field to be trained for predictability. 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 {#ClssfnV-getProperties__ul_pmw_523_plb}Default: run_once Data type: String |
| \<Object\>.versionNumber | Version number of the ClassificationSolution object. Data type: String |
[Table 6. Returns]

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

    // Get properties
    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

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

Output:

    *** Script: {
      "datasetProperties": {
        "encodedQuery": "activeANYTHING^EQ",
        "fieldNames": [
          "short_description",
          "category"
        ],
        "tableName": "incident"
      },
      "domainName": "global",
      "inputFieldNames": [
        "short_description"
      ],
      "isActive": "true",
      "label": "Incident Categorization_Trainer",
      "name": "ml_incident_categorization",
      "predictedFieldName": "category",
      "processingLanguage": "en",
      "stopwords": [
        "Default English Stopwords"
      ],
      "versionNumber": "1"
    }

## ClassificationSolutionVersion - getStatus(Boolean includeDetails) {#ariaid-title5}

Gets training completion status.
{#ClssfnV-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. {#ClssfnV-getStatus_B__ul_n33_ckw_plb} Default: False |
[Table 7. Parameters]

{#ClssfnV-getStatus_B__table_xfh_vbw_plb} {#ClssfnV-getStatus_B__table_yfh_vbw_plb__entry__2}

| Type | Description |
|-|-|
| Object | JavaScript object containing training status information for a [ClassificationSolution](https://servicenow-prod.fluidtopics.net/n0ITHoNNnE5DnGxbNhqWtg#ClassificationSolutionAPI "The ClassificationSolution 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 {#ClssfnV-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. {#ClssfnV-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 8. Returns]

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

    // Get status
    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

    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_classification_solution';
    var mlSolution = sn_ml.ClassificationSolutionStore.get(solutionName);
    var trainingStatus = mlSolution.getLatestVersion().getStatus();

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

Output:

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

## ClassificationSolutionVersion - getTrainingStatistics() {#ariaid-title6}

Gets all the training statistics for a given solution.
{#ClssfnV-getTrainingStatistics__table_vph_2dw_plb__entry__3}

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

{#ClssfnV-getTrainingStatistics__table_vph_2dw_plb} {#ClssfnV-getTrainingStatistics__table_wph_2dw_plb__entry__2}

| Type | Description |
|-|-|
| Object | JavaScript object with statistics for each class included in training and values for each class that was excluded from training. For details, see [Predictive model components](https://www.servicenow.com/docs/access?context=predictive-intelligence&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). { "includedClasses": {Object}, "excludedClasses": {Object} } |
| \<Object\>.includedClasses | Object containing precision, coverage, recall, and distribution values of each class in the trained model. Data type: Object "includedClasses": { "<class name>": { "distribution": "String", "statistics": [Array] }, |
| \<Object\>.includedClasses.\<class name\>.distribution | Value of the outcome probability distribution for this class. Data type: String |
| \<Object\>.includedClasses.\<class name\>.statistics | List of objects providing training statistics data. For more information, see [Configuring target metrics](https://www.servicenow.com/docs/access?context=configuring-target-metrics-trained-classification-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). Data type: Array of Objects [ { "coverage": "String", "precision": "String", "recall": "String", "selected": "String" } ] |
| \<Object\>.includedClasses.\<class name\>.statistics.coverage | Estimated solution coverage metric for this class. Data type: String (numerical value) |
| \<Object\>.includedClasses.\<class name\>.statistics.precision | Estimated solution precision metric for this class. Data type: String (numerical value) |
| \<Object\>.includedClasses.\<class name\>.statistics.recall | Estimated solution recall metric for this class. Data type: String (numerical value) |
| \<Object\>.includedClasses.\<class name\>.statistics.selected | Flag that indicates whether this class contains records included in solution training. Valid values: * true: This class contains records selected for training the solution. * false: This class is excluded from training. {#ClssfnV-getTrainingStatistics__ul_sht_4cx_plb} Data type: String (Boolean value) Default: false |
| \<Object\>.excludedClasses | Distribution and row count of all the classes excluded from training. Data type: Object "excludedClasses": { "<class name>": { "distribution": "0.11", "rowCount": "9" } |
| \<Object\>.excludedClasses.\<class name\>.distribution | Value of the outcome probability distribution for this class. Data type: String |
| \<Object\>.excludedClasses.\<class name\>.rowCount | Number of rows excluded from training. Data type: String (numerical value) |
[Table 10. Returns]

{#ClssfnV-getTrainingStatistics__table_wph_2dw_plb}  
The following example shows how to get training statistics from the active solution.

    // Get training stats
    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

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

Output:

    {
      "includedClasses": {
        "Approvals": {
          "distribution": "0.43",
          "statistics": [
            {
              "precision": "100",
              "coverage": "0",
              "recall": "0",
              "selected": "true"
            }
          ]
        }, 
        "Authentication": {
          "distribution": "4.3",
          "statistics": [
            {
              "precision": "39.33",
              "coverage": "95.31",
              "recall": "54.69",
              "selected": "false"
            },
            {
              "precision": "100",
              "coverage": "0",
              "recall": "0",
              "selected": "false"
            },
         ...
        }
        ...
      "excludedClasses": {
        "ACE": {
          "distribution": "0.11",
          "rowCount": "9"
        },
        "AHA": {
          "distribution": "0.01",
          "rowCount": "1"
        }, 
        ...
    }

## ClassificationSolutionVersion - getVersionNumber() {#ariaid-title7}

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

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

{#ClssfnV-getVersionNumber__table_jsz_sbw_plb} {#ClssfnV-getVersionNumber__table_ksz_sbw_plb__entry__2}

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

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

    // Get version number
    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

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

Output:

    Version number: 1

## ClassificationSolutionVersion - predict(Object input, Object options) {#ariaid-title8}

Gets the input data for a prediction.
{#ClssfnV-predict_O_O__table_wwz_pbw_plb__entry__3}

| Name | Type | Description |
|-|-|-|
| input | Object | [GlideRecord](https://servicenow-prod.fluidtopics.net/nRmUiaC7a08cr2N5iZGqoQ#c_GlideRecordAPI "The GlideRecord API is used for database operations.") or array of JSON objects containing field names and values as key-value pairs. |
| options | Object | Optional values for filtering prediction results. { "apply_threshold": Boolean, "top_n": Number } |
| options.apply_threshold | Boolean | Flag that indicates whether to check the threshold value for the solution and apply it to the result set. Valid values: * true: Return results in which confidence is greater than threshold. * false: Return all results. {#ClssfnV-predict_O_O__ul_f4d_xyx_slb} Default: True |
| options.top_n | Number | If provided, returns the top results, up to the specified number of predictions. |
[Table 13. Parameters]

{#ClssfnV-predict_O_O__table_wwz_pbw_plb} {#ClssfnV-predict_O_O__table_xwz_pbw_plb__entry__2}

| Type | Description |
|-|-|
| Object | JSON object containing the prediction results sorted by sys_id or record_number. { <identifier>: [Array] } |
| \<Object\>.\<identifier\> | List of objects with details for each prediction result. Data type: Array of Objects <identifier>: [ { "confidence": Number, "predictedSysId": "String", "predictedValue": "String", "threshold": Number } ] |
| \<Object\>.\<identifier\>.\<object\>.confidence | Value of the confidence associated with the prediction. For example, 53.84. Data type: Number |
| \<Object\>.\<identifier\>.\<object\>.predictedSysId | The sys_id of the predicted value. Results can be from any table on which information is being predicted. Data type: String |
| \<Object\>.\<identifier\>.\<object\>.predictedValue | Value representing the prediction result. Data type: String |
| \<Object\>.\<identifier\>.\<object\>.threshold | Value of the configured threshold associated with the prediction. Data type: Number |
[Table 14. Returns]

{#ClssfnV-predict_O_O__table_xwz_pbw_plb}  
The following example shows how to display prediction
results for a predict() method that takes a GlideRecord by
sys_id for input and includes optional parameters to restrict to top three results
and exclude the threshold value.

    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

    // single GlideRecord input
    var input = new GlideRecord("incident");
    input.get("<sys_id>");

    // configure optional parameters
    var options = {};
    options.top_n = 3;
    options.apply_threshold = false;

    var results = mlSolution.getVersion(1).predict(input, options);
    // pretty print JSON results
    gs.print(JSON.stringify(JSON.parse(results), null, 2));

Output:

    {
      "<sys_id/gr>": [
        {
          "confidence": 62.10782320780268,
          "threshold": 20.36,
          "predictedValue": "Clone Issues",
          "predictedSysId": ""
        },
        {
          "confidence": 6.945237375770391,
          "threshold": 16.63,
          "predictedValue": "Instance Administration",
          "predictedSysId": ""
        },
        {
          "confidence": 5.321061076300759,
          "threshold": 23.7,
          "predictedValue": "Administration",
          "predictedSysId": ""
        }
      ]
    }

The following example shows how to display prediction
results for a predict() method that takes an array of field
names as key-value pairs for input and includes optional parameters to restrict to
top three results and exclude the threshold value.

    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');

    // key-value pairs input
    var input = [{"short_description":"my email is not working"}, {short_description:"need help with password"}];

    // configure optional parameters
    var options = {};
    options.top_n = 3;
    options.apply_threshold = false;
    var results = mlSolution.predict(input, options);

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

Output:

    {
      "1": [
        {
          "confidence": 37.5023032262591,
          "threshold": 10.72,
          "predictedValue": "Authentication",
          "predictedSysId": ""
        },
        {
          "confidence": 24.439964862166583,
          "threshold": 23.7,
          "predictedValue": "Administration",
          "predictedSysId": ""
        },
        {
          "confidence": 11.736320486031047,
          "threshold": 100,
          "predictedValue": "Security",
          "predictedSysId": ""
        }
      ],
      "2": [
        {
          "confidence": 99,
          "threshold": 17.77,
          "predictedValue": "Email",
          "predictedSysId": ""
        },
        {
          "confidence": 3.182137005157543,
          "threshold": 10.72,
          "predictedValue": "Authentication",
          "predictedSysId": ""
        },
        {
          "confidence": 2.8773826570713514,
          "threshold": -1,
          "predictedValue": "Email (I/f)",
          "predictedSysId": ""
        }
      ]
    }

## ClassificationSolutionVersion - setPredictionSettings(Object options) {#ariaid-title9}

Sets precision, coverage, or recall values at solution level or class
level.
{#ClssfnV-setPredictionSettings_O__table_b45_tdw_plb__entry__3}

| Name | Type | Description |
|-|-|-|
| options | Object | Metric configuration values. For information about these features, see [Configuring target metrics](https://www.servicenow.com/docs/access?context=configuring-target-metrics-trained-classification-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US). { "metricName" : "String", "metricValue" : "String", "className" : "String" } |
| options.metricName | String | Name of the metric to set. Valid values: * coverage{#ClssfnV-setPredictionSettings_O__classification-v-metrics-coverage} * precision{#ClssfnV-setPredictionSettings_O__classification-v-metrics-precision} * recall{#ClssfnV-setPredictionSettings_O__classification-v-metrics-recall} {#ClssfnV-setPredictionSettings_O__ul_ncd_ldx_plb} |
| options.metricValue | String | Numeric value to assign to the metric. |
| options.className | String | Optional. Name of the class to restrict results to. Use the [getTrainingStatistics()](https://servicenow-prod.fluidtopics.net/AL0AXV7FLmJf60UR28zYkg#ClssfnV-getTrainingStatistics "Gets all the training statistics for a given solution.") method to retrieve a complete list of classes for a solution. |
[Table 15. Parameters]

{#ClssfnV-setPredictionSettings_O__table_b45_tdw_plb} {#ClssfnV-setPredictionSettings_O__table_c45_tdw_plb__entry__2}

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

{#ClssfnV-setPredictionSettings_O__table_c45_tdw_plb}  
The following example shows how to set a precision metric to 89.5 for a class named
`Clone Issues`.

    var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_x_snc_global_global_classification');
    var input = {"metricName" : "precision", "metricValue" : "89.5", "className" : "Clone Issues"};

    mlSolution.getActiveVersion().setTrainingStatistics(input);


