{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":728,"path":"api-reference/server-api-reference/ClassificationSolutionVersionAPI.md","title":"ClassificationSolutionVersion - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# ClassificationSolutionVersion- Global\n\nThe ClassificationSolutionVersion API is a scriptable object used in Predictive Intelligence stores.\n\nThis API requires the Predictive Intelligence plugin \\(com.glide.platform\\_ml\\) and is provided within the `sn_ml` namespace.\n\nThis API is used for working with solution versions based on [ClassificationSolution API](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.md) objects in the [ClassificationSolution store](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionStoreAPI.md).\n\nThe system creates a solution version each time you train a solution definition. Most versions are created during scheduled solution training.\n\nMethods in this API are accessible using the following [ClassificationSolution - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.md) methods:\n\n-   [getActiveVersion\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.md)\n-   [getAllVersions\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.md)\n-   [getLatestVersion\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.md)\n-   [getVersion\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.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## ClassificationSolutionVersion - getPredictionPerformance\\(Object options\\)\n\nCalculates solution precision and coverage.\n\nTo use this method, you must first create settings using the setPredictionSettings\\(\\) method.\n\n<table id=\"table_gby_x2w_plb\" 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\nSelects a metric to retrieve within a span of dates. For more information, see [Configuring target metrics](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/configuring-target-metrics-trained-classification-solution.md).```\n{\n  \"fromDate\": \"String\",\n  \"metricName\": \"String\",\n  \"toDate\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\noptions.fromDate\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Start date from which to retrieve metrics in system date time format.\n\n</td></tr><tr><td>\n\noptions.metricName\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the metric.Valid values:\n\n-   **precision**\n-   **coverage**\n\n</td></tr><tr><td>\n\noptions.toDate\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. End date from which to retrieve metrics.Formnt: System date time format.\n\n</td></tr></tbody>\n</table><table id=\"table_hby_x2w_plb\" 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\nParseable JavaScript object containing the results for the input metric.```\n{\n  \"metricName\" : \"String\",\n  \"metricValue\" : \"String\",\n  \"numberOfPredictionsConsidered\" : \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nObject.metricName\n\n</td><td>\n\nName of metric selected as input.Data type: String\n\n</td></tr><tr><td>\n\nObject.metricValue\n\n</td><td>\n\nValue of the selected metric.Data type: String\n\n</td></tr><tr><td>\n\nObject.numberOfRecordsConsidered\n\n</td><td>\n\nNumber of records in the Predictor Results \\[ml\\_predictor\\_results\\] table considered for calculations.Data type: String\n\n</td></tr></tbody>\n</table>The following example shows how to get a precision value from the active version of a solution.\n\n```\n// Get precision value\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\ngs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getPredictionPerformance({\"metricName\": \"precision\"})), null, 2));\n```\n\nOutput:\n\n```\n{\n  \"metricName\": \"precision\",\n  \"metricValue\": \"70.10\",\n  \"numberOfPredictionsConsidered\": \"10\"\n}\n```\n\n## ClassificationSolutionVersion - getPredictionSettings\\(\\)\n\nGets estimated precision, estimated coverage, estimated recall values from the ML Solutions \\[ml\\_solution\\] table and records from the Class Confidence \\[ml\\_class\\] table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_wph_2dw_plb\" 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\nReturns 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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/predictive-intelligence.md).```\n{\n  \"<class name>\": {Object}\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;class name&gt;\n\n</td><td>\n\nTraining statistics data from the Class Confidence \\[ml\\_class\\] table. For more information, see [Configuring target metrics](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/configuring-target-metrics-trained-classification-solution.md).Data type: Object\n\n```\n{\n  \"precision\": \"String\",\n  \"coverage\": \"String\",\n  \"recall\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;class name&gt;.precision\n\n</td><td>\n\nEstimated solution precision metric for this class.Data type: String \\(numerical value\\)\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;class name&gt;.coverage\n\n</td><td>\n\nEstimated solution coverage metric for this class.Data type: String \\(numerical value\\)\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;class name&gt;.recall\n\n</td><td>\n\nEstimated solution recall metric for this class.Data type: String \\(numerical value\\)\n\n</td></tr></tbody>\n</table>The following example shows how to get prediction settings of an active solution version.\n\n```\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\ngs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getPredictionSettings()), null, 2));\n```\n\nOutput:\n\n```\n{\n  \"solutionSettings\": {\n    \"precision\": \"61.69\",\n    \"coverage\": \"66.75\",\n    \"recall\": \"57.54\"\n  },\n  \"classSettings\": {\n    \"Approvals\": {\n      \"precision\": \"100\",\n      \"coverage\": \"0\",\n      \"recall\": \"0\"\n    },\n    \"Authentication\": {\n      \"precision\": \"38.71\",\n      \"coverage\": \"98.44\",\n      \"recall\": \"56.25\"\n    },\n    \"Automation\": {\n      \"precision\": \"100\",\n      \"coverage\": \"0\",\n      \"recall\": \"0\"\n    }, ...\n```\n\n## ClassificationSolutionVersion - getProperties\\(\\)\n\nGets solution object properties and version number.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_e2m_zwz_4lb\" 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\nContents of the Dataset and [ClassificationSolution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.md) version details. Results vary by object property setup.```\n{\n  \"algorithmConfig\": {\n    \"algorithm\": \"String\",\n    \"targetClassRecall\": \"String\"\n  },\n  \"datasetProperties\": {Object},\n  \"domainName\": \"String\",\n  \"encoder\": {Object},\n  \"groupByFieldName\": \"String\",   \n  \"inputFieldNames\": [Array],\n  \"isActive\": Boolean,\n  \"label\": \"String\",\n  \"name\": \"String\",\n  \"predictedFieldName\": \"String\",\n  \"processingLanguage\": \"String\",\n  \"scope\": \"String\",\n  \"stopwords\": [Array],\n  \"stopwords\": [Array],\n  \"trainingFrequency\": \"String\",\n  \"versionNumber\": \"Number\"\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.algorithmConfig\n\n</td><td>\n\nMethod for encoding the solution. Data type: Object\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.algorithmConfig.algorithm\n\n</td><td>\n\nName of the encoding algorithm for training this solution. Possible values:\n\n-   **xgboost**: XGBoost encoding to optimize the training.\n-   **logisticRegression**: Method using the logistic regression model for categorical targets such as nominal or ordinal.\n\nData type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.algorithmConfig.targetClassRecall\n\n</td><td>\n\nClass 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\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.datasetProperties\n\n</td><td>\n\nLists the properties of the [DatasetDefinition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/DatasetDefinitionAPI.md) object associated with the solution.\n\n Data type: Object\n\n ```\n{\n  \"encodedQuery\": \"String\",\n  \"fieldDetails\": [Array],\n  \"fieldNames\": [Array],\n  \"tableName\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.datasetProperties.tableName\n\n</td><td>\n\nName of the table for the dataset. For example, `\"tableName\" : \"Incident\"`. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.datasetProperties.fieldNames\n\n</td><td>\n\nList of field names from the specified table as strings. For example, `\"fieldNames\" : [\"short_description\", \"priority\"]`. Data type: Array\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.datasetProperties.fieldNames.fieldDetails\n\n</td><td>\n\nList of JavaScript objects that specify field properties. Data type: Array of Objects\n\n```\n[\n  {\n    \"name\": \"String\",\n    \"type\": \"String\"\n  }\n]\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.datasetProperties.fieldNames.fieldDetails.&lt;object&gt;.name\n\n</td><td>\n\nName of the field defining the type of information to restrict this dataset to. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.datasetProperties.fieldDetails.&lt;object&gt;.type\n\n</td><td>\n\nMachine-learning field type. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.datasetProperties.fieldDetails.encodedQuery\n\n</td><td>\n\nEncoded query string in the standard platform format. See [Encoded query strings](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).Data type: String.\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.domainName\n\n</td><td>\n\nDomain name associated with this dataset. See [Domain separation and Predictive Intelligence](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/domain-separation-predictive-intelligence.md).Type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.encoder\n\n</td><td>\n\nEncoder object assigned to this solution. See [Encoder - Encoder\\(Object config\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/EncoderAPI.md).Data type: Object\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.groupByFieldName\n\n</td><td>\n\nField name by which the system groups records to build classification solutions. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.inputFieldNames\n\n</td><td>\n\nList of input field names as strings. The model uses these fields used to make predictions. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.isActive\n\n</td><td>\n\nFlag that indicates whether this version is active.Valid values:\n\n-   true: Version is active.\n-   false: Version is not active.\n\n Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.label\n\n</td><td>\n\nIdentifies the prediction task. ```\n{\n  \"label\": \"my first prediction\"\n}\n```\n\nData type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.name\n\n</td><td>\n\nSystem-assigned name. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.predictedFieldName\n\n</td><td>\n\nIdentifies a field to be trained for predictability. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.processingLanguage\n\n</td><td>\n\nProcessing language in two-letter ISO 639-1 language code format. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.scope\n\n</td><td>\n\nObject scope. Currently the only valid value is `global`.Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.stopwords\n\n</td><td>\n\nOptional. Preset list of strings that the system automatically generates based on the **language** property setting. For details, see [Create a custom stopwords list](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/create-custom-stopwords-list.md). Data type: Array\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.trainingFrequency\n\n</td><td>\n\nThe frequency to retrain the model. Possible values:\n\n-   every\\_30\\_days\n-   every\\_60\\_days\n-   every\\_90\\_days\n-   every\\_120\\_days\n-   every\\_180\\_days\n-   run\\_once\n\nDefault: run\\_once\n\nData type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.versionNumber\n\n</td><td>\n\nVersion number of the ClassificationSolution object.Data type: String\n\n</td></tr></tbody>\n</table>The following example gets properties of the active object version in the store.\n\n```\n// Get properties\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\ngs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getProperties()), null, 2));\n```\n\nOutput:\n\n```\n*** Script: {\n  \"datasetProperties\": {\n    \"encodedQuery\": \"activeANYTHING^EQ\",\n    \"fieldNames\": [\n      \"short_description\",\n      \"category\"\n    ],\n    \"tableName\": \"incident\"\n  },\n  \"domainName\": \"global\",\n  \"inputFieldNames\": [\n    \"short_description\"\n  ],\n  \"isActive\": \"true\",\n  \"label\": \"Incident Categorization_Trainer\",\n  \"name\": \"ml_incident_categorization\",\n  \"predictedFieldName\": \"category\",\n  \"processingLanguage\": \"en\",\n  \"stopwords\": [\n    \"Default English Stopwords\"\n  ],\n  \"versionNumber\": \"1\"\n}\n```\n\n## ClassificationSolutionVersion - getStatus\\(Boolean includeDetails\\)\n\nGets training completion status.\n\n<table id=\"table_xfh_vbw_plb\" 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\nincludeDetails\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to return status **details**.Valid values:\n\n-   true: Return additional details.\n-   false: Don't return additional details.\n\nDefault: False\n\n</td></tr></tbody>\n</table><table id=\"table_yfh_vbw_plb\" 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\nJavaScript object containing training status information for a [ClassificationSolution](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionAPI.md) object.```\n{\n  \"state\": \"String\",\n  \"percentComplete\": \"Number as a String\",\n  \"hasJobEnded\": \"Boolean value as a String\",\n  \"details\": {Object}\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.state\n\n</td><td>\n\nTraining 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:\n\n-   `fetching_files_for_training`\n-   `preparing_data`\n-   `retry`\n-   `solution_cancelled` \\(terminal\\)\n-   `solution_complete`\\(terminal\\)\n-   `solution_error` \\(terminal\\)\n-   `solution_incomplete`\n-   `training_request_received`\n-   `training_request_timed_out` \\(terminal\\)\n-   `training_solution`\n-   `uploading_solution`\n-   `waiting_for_training`\n\nData type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.hasJobEnded\n\n</td><td>\n\nFlag that indicates whether training is complete.Valid values:\n\n-   true: Training is complete.\n-   false: Training is incomplete.\n\nData type: Boolean value as a String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.percentComplete\n\n</td><td>\n\nTraining 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\n\nRange: 0 thru 100\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.details\n\n</td><td>\n\nObject containing a list of additional training details.Data type: Object\n\n</td></tr></tbody>\n</table>The following example shows a successful result with training complete.\n\n```\n// Get status\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\ngs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getStatus(true), null, 2)));\n```\n\nOutput:\n\n```\n{\n \"state\":\"solution_complete\",\n \"percentComplete\":\"100\",\n \"hasJobEnded\":\"true\",\n \"details\":{\"stepLabel\":\"Solution Complete\"} // This information is only returned if getStatus(true);\n}\n```\n\nThe following example shows an unsuccessful result with training complete.\n\n```\n// Get status\nvar solutionName = 'ml_x_snc_global_global_classification_solution';\nvar mlSolution = sn_ml.ClassificationSolutionStore.get(solutionName);\nvar trainingStatus = mlSolution.getLatestVersion().getStatus();\n\ngs.print(JSON.stringify(JSON.parse(trainingStatus), null, 2));\n```\n\nOutput:\n\n```\n{\n \"state\":\"solution_error\",\n \"percentComplete\":\"100\",\n \"hasJobEnded\":\"true\"\n}\n```\n\n## ClassificationSolutionVersion - getTrainingStatistics\\(\\)\n\nGets all the training statistics for a given solution.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_wph_2dw_plb\" 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\nJavaScript 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://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/predictive-intelligence.md).```\n{\n  \"includedClasses\": {Object},\n  \"excludedClasses\": {Object}\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.includedClasses\n\n</td><td>\n\nObject containing precision, coverage, recall, and distribution values of each class in the trained model.Data type: Object\n\n```\n\n  \"includedClasses\": {\n    \"<class name>\": {\n      \"distribution\": \"String\",\n      \"statistics\": [Array]\n    },\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.includedClasses.&lt;class name&gt;.distribution\n\n</td><td>\n\nValue of the outcome probability distribution for this class.Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.includedClasses.&lt;class name&gt;.statistics\n\n</td><td>\n\nList of objects providing training statistics data. For more information, see [Configuring target metrics](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/configuring-target-metrics-trained-classification-solution.md).Data type: Array of Objects\n\n```\n[\n  {\n    \"coverage\": \"String\",\n    \"precision\": \"String\",\n    \"recall\": \"String\",\n    \"selected\": \"String\"\n  }\n]\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.includedClasses.&lt;class name&gt;.statistics.coverage\n\n</td><td>\n\nEstimated solution coverage metric for this class.Data type: String \\(numerical value\\)\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.includedClasses.&lt;class name&gt;.statistics.precision\n\n</td><td>\n\nEstimated solution precision metric for this class.Data type: String \\(numerical value\\)\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.includedClasses.&lt;class name&gt;.statistics.recall\n\n</td><td>\n\nEstimated solution recall metric for this class.Data type: String \\(numerical value\\)\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.includedClasses.&lt;class name&gt;.statistics.selected\n\n</td><td>\n\nFlag that indicates whether this class contains records included in solution training.Valid values:\n\n-   true: This class contains records selected for training the solution.\n-   false: This class is excluded from training.\n\nData type: String \\(Boolean value\\)\n\nDefault: false\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.excludedClasses\n\n</td><td>\n\nDistribution and row count of all the classes excluded from training.Data type: Object\n\n```\n\n  \"excludedClasses\": {\n    \"<class name>\": {\n      \"distribution\": \"0.11\",\n      \"rowCount\": \"9\"\n    }\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.excludedClasses.&lt;class name&gt;.distribution\n\n</td><td>\n\nValue of the outcome probability distribution for this class.Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.excludedClasses.&lt;class name&gt;.rowCount\n\n</td><td>\n\nNumber of rows excluded from training.Data type: String \\(numerical value\\)\n\n</td></tr></tbody>\n</table>The following example shows how to get training statistics from the active solution.\n\n```\n// Get training stats\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\ngs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getTrainingStatistics()), null, 2));\n```\n\nOutput:\n\n```\n{\n  \"includedClasses\": {\n    \"Approvals\": {\n      \"distribution\": \"0.43\",\n      \"statistics\": [\n        {\n          \"precision\": \"100\",\n          \"coverage\": \"0\",\n          \"recall\": \"0\",\n          \"selected\": \"true\"\n        }\n      ]\n    }, \n    \"Authentication\": {\n      \"distribution\": \"4.3\",\n      \"statistics\": [\n        {\n          \"precision\": \"39.33\",\n          \"coverage\": \"95.31\",\n          \"recall\": \"54.69\",\n          \"selected\": \"false\"\n        },\n        {\n          \"precision\": \"100\",\n          \"coverage\": \"0\",\n          \"recall\": \"0\",\n          \"selected\": \"false\"\n        },\n     ...\n    }\n    ...\n  \"excludedClasses\": {\n    \"ACE\": {\n      \"distribution\": \"0.11\",\n      \"rowCount\": \"9\"\n    },\n    \"AHA\": {\n      \"distribution\": \"0.01\",\n      \"rowCount\": \"1\"\n    }, \n    ...\n}\n```\n\n## ClassificationSolutionVersion - getVersionNumber\\(\\)\n\nGets the version number of a solution object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Version number.|\n\nThe following example shows how to get a version number.\n\n```\n// Get version number\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\ngs.print(\"Version number: \"+JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getVersionNumber()), null, 2));\n```\n\nOutput:\n\n```\nVersion number: 1\n```\n\n## ClassificationSolutionVersion - predict\\(Object input, Object options\\)\n\nGets the input data for a prediction.\n\n<table id=\"table_wwz_pbw_plb\" 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 values for filtering prediction results.```\n{\n  \"apply_threshold\": Boolean,\n  \"top_n\": Number\n}\n```\n\n</td></tr><tr><td>\n\noptions.apply\\_threshold\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to check the threshold value for the solution and apply it to the result set.Valid values:\n\n-   true: Return results in which confidence is greater than threshold.\n-   false: Return all results.\n\nDefault: True\n\n</td></tr><tr><td>\n\noptions.top\\_n\n\n</td><td>\n\nNumber\n\n</td><td>\n\nIf provided, returns the top results, up to the specified number of predictions.\n\n</td></tr></tbody>\n</table><table id=\"table_xwz_pbw_plb\" 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. ```\n{\n    <identifier>: [Array]\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;identifier&gt;\n\n</td><td>\n\nList of objects with details for each prediction result.Data type: Array of Objects\n\n```\n<identifier>: [\n  {\n    \"confidence\": Number,\n    \"predictedSysId\": \"String\",\n    \"predictedValue\": \"String\", \n    \"threshold\": Number\n  }\n]\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;identifier&gt;.&lt;object&gt;.confidence\n\n</td><td>\n\nValue of the confidence associated with the prediction. For example, 53.84. Data type: Number\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;identifier&gt;.&lt;object&gt;.predictedSysId\n\n</td><td>\n\nThe sys\\_id of the predicted value. Results can be from any table on which information is being predicted. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;identifier&gt;.&lt;object&gt;.predictedValue\n\n</td><td>\n\nValue representing the prediction result. Data type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.&lt;identifier&gt;.&lt;object&gt;.threshold\n\n</td><td>\n\nValue of the configured threshold associated with the prediction. Data type: Number\n\n</td></tr></tbody>\n</table>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.\n\n```\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\n// single GlideRecord input\nvar input = new GlideRecord(\"incident\");\ninput.get(\"<sys_id>\");\n\n// configure optional parameters\nvar options = {};\noptions.top_n = 3;\noptions.apply_threshold = false;\n\nvar results = mlSolution.getVersion(1).predict(input, options);\n// pretty print JSON results\ngs.print(JSON.stringify(JSON.parse(results), null, 2));\n```\n\nOutput:\n\n```\n{\n  \"<sys_id/gr>\": [\n    {\n      \"confidence\": 62.10782320780268,\n      \"threshold\": 20.36,\n      \"predictedValue\": \"Clone Issues\",\n      \"predictedSysId\": \"\"\n    },\n    {\n      \"confidence\": 6.945237375770391,\n      \"threshold\": 16.63,\n      \"predictedValue\": \"Instance Administration\",\n      \"predictedSysId\": \"\"\n    },\n    {\n      \"confidence\": 5.321061076300759,\n      \"threshold\": 23.7,\n      \"predictedValue\": \"Administration\",\n      \"predictedSysId\": \"\"\n    }\n  ]\n}\n```\n\nThe 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.\n\n```\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization');\n\n// key-value pairs input\nvar input = [{\"short_description\":\"my email is not working\"}, {short_description:\"need help with password\"}];\n\n// configure optional parameters\nvar options = {};\noptions.top_n = 3;\noptions.apply_threshold = false;\nvar results = mlSolution.predict(input, options);\n\n// pretty print JSON results\ngs.print(JSON.stringify(JSON.parse(results), null, 2));\n```\n\nOutput:\n\n```\n{\n  \"1\": [\n    {\n      \"confidence\": 37.5023032262591,\n      \"threshold\": 10.72,\n      \"predictedValue\": \"Authentication\",\n      \"predictedSysId\": \"\"\n    },\n    {\n      \"confidence\": 24.439964862166583,\n      \"threshold\": 23.7,\n      \"predictedValue\": \"Administration\",\n      \"predictedSysId\": \"\"\n    },\n    {\n      \"confidence\": 11.736320486031047,\n      \"threshold\": 100,\n      \"predictedValue\": \"Security\",\n      \"predictedSysId\": \"\"\n    }\n  ],\n  \"2\": [\n    {\n      \"confidence\": 99,\n      \"threshold\": 17.77,\n      \"predictedValue\": \"Email\",\n      \"predictedSysId\": \"\"\n    },\n    {\n      \"confidence\": 3.182137005157543,\n      \"threshold\": 10.72,\n      \"predictedValue\": \"Authentication\",\n      \"predictedSysId\": \"\"\n    },\n    {\n      \"confidence\": 2.8773826570713514,\n      \"threshold\": -1,\n      \"predictedValue\": \"Email (I/f)\",\n      \"predictedSysId\": \"\"\n    }\n  ]\n}\n```\n\n## ClassificationSolutionVersion - setPredictionSettings\\(Object options\\)\n\nSets precision, coverage, or recall values at solution level or class level.\n\n<table id=\"table_b45_tdw_plb\" 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\nMetric configuration values. For information about these features, see [Configuring target metrics](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/intelligent-experiences/configuring-target-metrics-trained-classification-solution.md).```\n{  \t \n   \"metricName\" : \"String\",\n   \"metricValue\" : \"String\",\n   \"className\" : \"String\"\n}\n```\n\n</td></tr><tr><td>\n\noptions.metricName\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the metric to set.Valid values:\n\n-   **coverage**\n-   **precision**\n-   **recall**\n\n</td></tr><tr><td>\n\noptions.metricValue\n\n</td><td>\n\nString\n\n</td><td>\n\nNumeric value to assign to the metric.\n\n</td></tr><tr><td>\n\noptions.className\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Name of the class to restrict results to. Use the [getTrainingStatistics\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/ClassificationSolutionVersionAPI.md) method to retrieve a complete list of classes for a solution.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to set a precision metric to 89.5 for a class named `Clone Issues`.\n\n```\nvar mlSolution = sn_ml.ClassificationSolutionStore.get('ml_x_snc_global_global_classification');\nvar input = {\"metricName\" : \"precision\", \"metricValue\" : \"89.5\", \"className\" : \"Clone Issues\"};\n\nmlSolution.getActiveVersion().setTrainingStatistics(input);\n```\n\n"}}