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
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));
Gets estimated precision, estimated coverage, estimated recall values from the ML Solutions [ml_solution] table and records from the Class Confidence [ml_class] table.
Name
Type
Description
None
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.
{
"<class name>": {Object}
}
<Object>.<class name>
Training statistics data from the Class Confidence \[ml\_class\] table. For more information, see Configuring target metrics.Data type: Object
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.
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() object associated with the solution. Data type: Object ``` { "encodedQuery": "String", "fieldDetails": [Array], "fieldNames": [Array], "tableName": "String" }
</td></tr><tr><td>
<Object>.datasetProperties.tableName
</td><td>
Name of the table for the dataset. For example, `"tableName" : "Incident"`. Data type: String
</td></tr><tr><td>
<Object>.datasetProperties.fieldNames
</td><td>
List of field names from the specified table as strings. For example, `"fieldNames" : ["short_description", "priority"]`. Data type: Array
</td></tr><tr><td>
<Object>.datasetProperties.fieldNames.fieldDetails
</td><td>
List of JavaScript objects that specify field properties. Data type: Array of Objects
[ { "name": "String", "type": "String" } ]
</td></tr><tr><td>
<Object>.datasetProperties.fieldNames.fieldDetails.<object>.name
</td><td>
Name of the field defining the type of information to restrict this dataset to. Data type: String
</td></tr><tr><td>
<Object>.datasetProperties.fieldDetails.<object>.type
</td><td>
Machine-learning field type. Data type: String
</td></tr><tr><td>
<Object>.datasetProperties.fieldDetails.encodedQuery
</td><td>
Encoded query string in the standard platform format. See <a href="../../../platform-user-interface/c_EncodedQueryStrings/">Encoded query strings</a>.Data type: String.
</td></tr><tr><td>
<Object>.domainName
</td><td>
Domain name associated with this dataset. See <a href="../../../intelligent-experiences/predictive-intelligence/domain-separation-predictive-intelligence/">Domain separation and Predictive Intelligence</a>.Type: String
</td></tr><tr><td>
<Object>.encoder
</td><td>
Encoder object assigned to this solution. See <a href="../EncoderAPI/">Encoder - Encoder(Object config)</a>.Data type: Object
</td></tr><tr><td>
<Object>.groupByFieldName
</td><td>
Field name by which the system groups records to build classification solutions. Data type: String
</td></tr><tr><td>
<Object>.inputFieldNames
</td><td>
List of input field names as strings. The model uses these fields used to make predictions. Data type: String
</td></tr><tr><td>
<Object>.isActive
</td><td>
Flag that indicates whether this version is active.Valid values:
- true: Version is active.
- false: Version is not active.
Data type: String
</td></tr><tr><td>
<Object>.label
</td><td>
Identifies the prediction task.
{ "label": "my first prediction" }
Data type: String
</td></tr><tr><td>
<Object>.name
</td><td>
System-assigned name. Data type: String
</td></tr><tr><td>
<Object>.predictedFieldName
</td><td>
Identifies a field to be trained for predictability. Data type: String
</td></tr><tr><td>
<Object>.processingLanguage
</td><td>
Processing language in two-letter ISO 639-1 language code format. Data type: String
</td></tr><tr><td>
<Object>.scope
</td><td>
Object scope. Currently the only valid value is `global`.Data type: String
</td></tr><tr><td>
<Object>.stopwords
</td><td>Optional. Preset list of strings that the system automatically generates based on the <strong>language</strong> property setting. For details, see <a href="../../../intelligent-experiences/predictive-intelligence/create-custom-stopwords-list/">Create a custom stopwords list</a>. Data type: Array</td></tr><tr><td>
<Object>.trainingFrequency
</td><td>
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
Default: run\_once
Data type: String
</td></tr><tr><td>
<Object>.versionNumber
</td><td>
Version number of the ClassificationSolution object.Data type: String
</td></tr></tbody>
</table>
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));
## ClassificationSolutionVersion - getStatus\(Boolean includeDetails\)
Gets training completion status.
<table id="table_xfh_vbw_plb" class="parameters"><thead><tr><th>
Name
</th><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
includeDetails
</td><td>
Boolean
</td><td><p>Flag that indicates whether to return status <strong>details</strong>.Valid values:</p>
<ul>
<li>true: Return additional details.</li>
<li>false: Don't return additional details.</li>
</ul>
<p>Default: False</p></td></tr></tbody>
</table>
<table id="table_yfh_vbw_plb" class="returns"><thead><tr><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
Object
</td><td>
JavaScript object containing training status information for a <a href="../ClassificationSolutionAPI/">ClassificationSolution</a> object.
{ "state": "String", "percentComplete": "Number as a String", "hasJobEnded": "Boolean value as a String", "details": {Object} }
</td></tr><tr><td>
<Object>.state
</td><td><p>Training completion state. If the training job reaches a terminal state, the job does not leave that state. If the state is terminal, the <strong>hasJobEnded</strong> property is set to <code>true</code>.Possible values:</p>
<ul>
<li><code>fetching_files_for_training</code></li>
<li><code>preparing_data</code></li>
<li><code>retry</code></li>
<li><code>solution_cancelled</code> (terminal)</li>
<li><code>solution_complete</code>(terminal)</li>
<li><code>solution_error</code> (terminal)</li>
<li><code>solution_incomplete</code></li>
<li><code>training_request_received</code></li>
<li><code>training_request_timed_out</code> (terminal)</li>
<li><code>training_solution</code></li>
<li><code>uploading_solution</code></li>
<li><code>waiting_for_training</code></li>
</ul>
<p>Data type: String</p></td></tr><tr><td>
<Object>.hasJobEnded
</td><td>
Flag that indicates whether training is complete.Valid values:
- true: Training is complete.
- false: Training is incomplete.
Data type: Boolean value as a String
</td></tr><tr><td>
<Object>.percentComplete
</td><td>
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
</td></tr><tr><td>
<Object>.details
</td><td>
Object containing a list of additional training details.Data type: Object
</td></tr></tbody>
</table>
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));
## ClassificationSolutionVersion - getTrainingStatistics\(\)
Gets all the training statistics for a given solution.
|Name|Type|Description|
|----|----|-----------|
|None| | |
<table id="table_wph_2dw_plb" class="returns"><thead><tr><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
Object
</td><td>
JavaScript object with statistics for each class included in training and values for each class that was excluded from training. For details, see <a href="../../../intelligent-experiences/predictive-intelligence/predictive-intelligence/">Predictive model components</a>.
</td></tr><tr><td>
<Object>.includedClasses
</td><td>
Object containing precision, coverage, recall, and distribution values of each class in the trained model.Data type: Object
</td></tr><tr><td>
<Object>.includedClasses.<class name>.distribution
</td><td>
Value of the outcome probability distribution for this class.Data type: String
</td></tr><tr><td>
<Object>.includedClasses.<class name>.statistics
</td><td>
List of objects providing training statistics data. For more information, see <a href="../../../intelligent-experiences/predictive-intelligence/configuring-target-metrics-trained-classification-solution/">Configuring target metrics</a>.Data type: Array of Objects
</td></tr><tr><td>
<Object>.includedClasses.<class name>.statistics.coverage
</td><td>
Estimated solution coverage metric for this class.Data type: String \(numerical value\)
</td></tr><tr><td>
<Object>.includedClasses.<class name>.statistics.precision
</td><td>
Estimated solution precision metric for this class.Data type: String \(numerical value\)
</td></tr><tr><td>
<Object>.includedClasses.<class name>.statistics.recall
</td><td>
Estimated solution recall metric for this class.Data type: String \(numerical value\)
</td></tr><tr><td>
<Object>.includedClasses.<class name>.statistics.selected
</td><td>
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.
Data type: String \(Boolean value\)
Default: false
</td></tr><tr><td>
<Object>.excludedClasses
</td><td>
Distribution and row count of all the classes excluded from training.Data type: Object
</td></tr><tr><td>
<Object>.excludedClasses.<class name>.distribution
</td><td>
Value of the outcome probability distribution for this class.Data type: String
</td></tr><tr><td>
<Object>.excludedClasses.<class name>.rowCount
</td><td>
Number of rows excluded from training.Data type: String \(numerical value\)
</td></tr></tbody>
</table>
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));
## ClassificationSolutionVersion - getVersionNumber\(\)
Gets the version number of a solution object.
|Name|Type|Description|
|----|----|-----------|
|None| | |
|Type|Description|
|----|-----------|
|String|Version number.|
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\)
Gets the input data for a prediction.
<table id="table_wwz_pbw_plb" class="parameters"><thead><tr><th>
Name
</th><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
input
</td><td>
Object
</td><td>
<a href="../c_GlideRecordAPI/">GlideRecord</a> or array of JSON objects containing field names and values as key-value pairs.
</td></tr><tr><td>
options
</td><td>
Object
</td><td>
Optional values for filtering prediction results.
{ "apply_threshold": Boolean, "top_n": Number }
</td></tr><tr><td>
options.apply\_threshold
</td><td>
Boolean
</td><td>
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.
Default: True
</td></tr><tr><td>
options.top\_n
</td><td>
Number
</td><td>
If provided, returns the top results, up to the specified number of predictions.
</td></tr></tbody>
</table>
<table id="table_xwz_pbw_plb" class="returns"><thead><tr><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
Object
</td><td>
JSON object containing the prediction results sorted by sys\_id or record\_number.
{ : [Array] }
</td></tr><tr><td>
<Object>.<identifier>
</td><td>
List of objects with details for each prediction result.Data type: Array of Objects
</td></tr><tr><td>
<Object>.<identifier>.<object>.confidence
</td><td>
Value of the confidence associated with the prediction. For example, 53.84. Data type: Number
</td></tr><tr><td>
<Object>.<identifier>.<object>.predictedSysId
</td><td>
The sys\_id of the predicted value. Results can be from any table on which information is being predicted. Data type: String
</td></tr><tr><td>
<Object>.<identifier>.<object>.predictedValue
</td><td>
Value representing the prediction result. Data type: String
</td></tr><tr><td>
<Object>.<identifier>.<object>.threshold
</td><td>
Value of the configured threshold associated with the prediction. Data type: Number
</td></tr></tbody>
</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.
var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_incident_categorization'); // single GlideRecord input var input = new GlideRecord("incident"); input.get(""); // 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));
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));
## ClassificationSolutionVersion - setPredictionSettings\(Object options\)
Sets precision, coverage, or recall values at solution level or class level.
<table id="table_b45_tdw_plb" class="parameters"><thead><tr><th>
Name
</th><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
options
</td><td>
Object
</td><td>
Metric configuration values. For information about these features, see <a href="../../../intelligent-experiences/predictive-intelligence/configuring-target-metrics-trained-classification-solution/">Configuring target metrics</a>.
</td></tr><tr><td>
options.metricName
</td><td>
String
</td><td><p>Name of the metric to set.Valid values:</p>
<ul>
<li><strong>coverage</strong></li>
<li><strong>precision</strong></li>
<li><strong>recall</strong></li>
</ul></td></tr><tr><td>
options.metricValue
</td><td>
String
</td><td>
Numeric value to assign to the metric.
</td></tr><tr><td>
options.className
</td><td>
String
</td><td>
Optional. Name of the class to restrict results to. Use the <a href="./">getTrainingStatistics()</a> method to retrieve a complete list of classes for a solution.
</td></tr></tbody>
</table>
|Type|Description|
|----|-----------|
|None| |
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); ```