SimilaritySolutionStore - Global
Enables storing and retrieving solutions.
The SimilaritySolutionStore
API requires the Predictive Intelligence plugin (com.glide.platform_ml) and is provided
within the sn_ml namespace.
SimilaritySolutionStore - add(Object mlSolution)
Adds a new solution object to the store and returns a unique name.
| Name | Type | Description |
|---|---|---|
| mlSolution | SimilaritySolution | SimilaritySolution() object to add to the store. |
| Type | Description |
|---|---|
| String | System-generated solution name. |
The following example shows how to add a solution to the store. Use to run the training job after adding it to the store.
// Create a dataset
var myData = new sn_ml.DatasetDefinition({
'tableName' : 'incident',
'fieldNames' : ['assignment_group', 'short_description', 'description'],
'encodedQuery' : 'activeANYTHING'
});
// Create a solution
var mySolution = new sn_ml.SimilaritySolution({
'label': "my solution definition",
'dataset' : myData,
'predictedFieldName' : 'assignment_group',
'inputFieldNames':['short_description']
});
// Add the solution to the store to later be able to retrieve it.
var my_unique_name = sn_ml.SimilaritySolutionStore.add(mySolution);
SimilaritySolutionStore - deleteObject(String name)
Removes a specified solution object from the store.
| Name | Type | Description |
|---|---|---|
| name | String | Name of the SimilaritySolution() object to be deleted. |
| Type | Description |
|---|---|
| None |
The following example shows how to delete a solution from the store.
sn_ml.SimilaritySolutionStore.deleteObject("ml_sn_global_global_solution");
SimilaritySolutionStore - get(String name)
Gets a solution object from the store.
| Name | Type | Description |
|---|---|---|
| name | String | Name of a solution in the store. |
| Type | Description |
|---|---|
| Object | SimilaritySolution object. Returns an error if the object does not exist. |
The following example shows how to get a solution object from the store using the get() method and view its training status using the SimilaritySolution - getActiveVersion() and SimilaritySolutionVersion - getStatus() methods.
// Get status
var mlSolution = sn_ml.SimilaritySolutionStore.get('ml_x_snc_global_similarity_solution');
gs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getStatus(), null, 2)));
Output:
{
"state":"solution_complete",
"percentComplete":"100",
"hasJobEnded":"true"
}
SimilaritySolutionStore - getAllNames(Object options)
Gets the names of all solution definition records in the store.
| Name | Type | Description |
|---|---|---|
| options | Object | Options for restricting results within the specified
properties. |
| options.label | String | Optional. Label of your solution object. |
| options.domainName | String | Optional. Name of the domain for your solution object. Refer to Domain separation and Predictive Intelligence. |
| options.scope | String | Optional. Name of an application scope for your solution object. |
| Type | Description |
|---|---|
| Array | List of strings representing solution object names in the store. |
In the following example, the getAllNames() method returns a list of all names in the store.
gs.print(JSON.stringify(JSON.parse(sn_ml.SimilaritySolutionStore.getAllNames()), null, 2));
Output:
[
"ml_x_snc_global_global_my_solution_definition_3",
"ml_incident_assignment",
"ml_x_snc_global_global_my_solution_definition",
"ml_x_snc_global_global_my_solution_definition_2",
"ml_sn_global_global_incident_service"
]
In the following example, the getAllNames() method returns only names associated with values set in the options parameter.
var options = {
'label' : 'my solution definition',
'domainName' : 'global',
'scope' : 'global'
};
var solNames = sn_ml.SimilaritySolutionStore.getAllNames(options);
gs.print(JSON.stringify(JSON.parse(solNames), null, 2));
Output:
[
"ml_x_snc_global_global_my_solution_definition"
]
SimilaritySolutionStore - update(String name, Object mlSolution)
Replaces an existing object in the store with the object passed as a parameter. The object name provided must be empty or match.
| Name | Type | Description |
|---|---|---|
| name | String | Name of the solution to update. |
| mlSolution | SimilaritySolution | SimilaritySolution() object properties to update. |
| Type | Description |
|---|---|
| None |
The following example shows how to update a solution object in the store.
var solutionUpdate = new sn_ml.SimilaritySolution({
'label': 'my solution definition',
'dataset' : myData,
'predictedFieldName' : 'assignment_group',
'inputFieldNames': ['short_description']
});
sn_ml.SimilaritySolutionStore.update('ml_sn_global_global_incident_service', solutionUpdate);