---
sourceDocument: Australia Enable AI
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/intelligent-experiences

 Release :

    - australia

ft:locale :

    - pt-BR

ft:publication_title :

    - Australia Enable AI

ft:clusterId :

    - platai

bundleId :

    - platai

workflow :

    - Platform


---

# Using Group By for classification

# Using Group By for classification {#ariaid-title1}

* Versão de lançamento: Australia
* 
* Atualizado 12 de mar. de 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 min. de leitura

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 {#using-group-by-for-classification__section_pnt_tgh_vlb}

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.  
In this scenario, you could use one of these two approaches:

* 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.
{#using-group-by-for-classification__ul_mwc_p3h_vlb}

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 {#using-group-by-for-classification__section_j4v_j23_bmb}

    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.
**Tópicos relacionados**   

* [DatasetDefinition - Global](https://www.servicenow.com/docs/access?context=DatasetDefinitionAPI&version=australia&pubname=australia-api-reference&ft:locale=en-US)
* [ClassificationSolution - Global](https://www.servicenow.com/docs/access?context=ClassificationSolutionAPI&version=australia&pubname=australia-api-reference&ft:locale=en-US)
* [ClassificationSolutionStore - Global](https://www.servicenow.com/docs/access?context=ClassificationSolutionStoreAPI&version=australia&pubname=australia-api-reference&ft:locale=en-US)
* [ClassificationSolutionVersion - Global](https://www.servicenow.com/docs/access?context=ClassificationSolutionVersionAPI&version=australia&pubname=australia-api-reference&ft:locale=en-US)

