Using Group By for classification
Summarize
Summary of Using Group By for Classification
This feature enables ServiceNow customers to utilize APIs for training multiple classification solutions based on the Group By field. This allows for the creation of a single classification solution that encompasses various data areas, such as geographical locations or domains, enhancing the efficiency of classification processes.
Show less
Key Features
- The groupby parameter allows the creation of models for different subsets of data, specifically using categorical columns.
- Only child solutions that meet the minimum records criteria will be generated, ensuring effective model training.
- Prediction calls are routed to the appropriate Group By model based on the Group By value in the prediction input, optimizing classification accuracy.
- Batch predictions are not supported, which emphasizes the need for careful prediction input management.
Key Outcomes
Using the Group By feature, customers can effectively manage classification for multiple regions or domains with a single solution. This is particularly beneficial for organizations with diverse geographical locations or various operational domains, leading to improved classification performance and streamlined processes.
For example, a global company can create a model for US incidents and another for European incidents using two methods: training separate definitions or leveraging the Group By parameter to handle categorization efficiently.
Sample API usage for creating and using classification solutions is provided, illustrating how to define datasets, submit training jobs, and execute predictions seamlessly within the ServiceNow platform.
Use APIs to simultaneously submit multiple classification solutions for training based on the Group By field.
You can use the optional Group By capability to train and maintain one classification solution that covers more than one data area, such as geographical location or domain.
To train a solution using Group By, you must add the groupby parameter while creating a classification solution definition using APIs. The groupby parameter accepts only categorical columns as inputs, where individual models are created on the subset of data belonging to each of the groupby values. Only those child solutions that pass the minimum records criteria set for the capability are created. Here, the prediction calls are routed to the corresponding Group By model based on the Group By value present in the prediction input. Batch predictions are not supported.
A Group By scenario for geographical locations
Let's say your global company uses classification routing for incoming records, with one support center in the US and one in Europe. Here, you want to create a single classification solution that has one model for your United States incidents and another model for your European incidents.
- Create and train two separate ML classification solution definitions, where one is filtered by US incidents only, and one by European incidents only.
- Use the groupby parameter to create Groupby for the country location so that all US definitions create a US model and all European definitions create a European model. Then, based on the incident, the system identifies which model it uses to predict the correct classification category.
The second approach has benefits in that the models you use can even be in different domains, such as healthcare or finance. This approach is especially beneficial if you have several country locations or domains to maintain.
Example usage for training and prediction using Group By via API
var myIncidentData = new sn_ml.DatasetDefinition({
'tableName' : 'incident',
'fieldNames' : ['category','short_description','assignment_group','description','priority'],
'encodedQuery' : 'activeANYTHING'
});
var mySolution = new sn_ml.ClassificationSolution({
'label': 'solution label',
'dataset' : myIncidentData,
'groupByFieldName' : 'assignment_group',
'predictedFieldName': 'category',
'inputFieldNames': ['short_description','description','priority']
});
//Add solution definition
var solution_gr = sn_ml.ClassificationSolutionStore.add(mySolution)
//Get existing solution
var my_unique_name = sn_ml.ClassificationSolutionStore.get('solution name');
// submit training job
var solutionVersion = my_unique_name.submitTrainingJob();
// Run prediction
var input = new GlideRecord("incident");
input.get("sys_id");
// configure optional parameters
var options = {};
options.apply_threshold = false;
var mlSolution = sn_ml.ClassificationSolutionStore.get('solution name');
//Prediction using glide record
var results = mlSolution.getActiveVersion().predict(input, options);
//Prediction using map
var results = mlSolution.getActiveVersion().predict([{ 'short_description': input.short_description,
'assignment_group': input.assignment_group }], options);For more context regarding this example and the general usage of Machine Learning APIs, see the links in the Related Content section on this page.