Get machine learning models

Gets a list of machine learning models that match the search criteria.

Required Permissions

Requires the MEMBER role or higher.

HTTP Request

GET /api/sonar/machine-learning/models
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
     https://HOSTNAME/api/sonar/machine-learning/models
Request Parameters
KeyRequiredTypeDescriptionNotes
offsetNo32-bit integerNumber of records to skipDefault: 0
limitNo32-bit integerMaximum number of records to loadDefault: unlimited
keywordsNoStringSearch keywordSearches model name, description

Success Response

{
  "total_count": 1,
  "models": [
    {
      "guid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "type": "random_forest",
      "type_name": "Random Forest",
      "user_guid": "11111111-2222-3333-4444-555555555555",
      "user_name": "admin",
      "name": "Anomalous Traffic Classifier",
      "description": "Network traffic anomaly detection model",
      "dataset_guid": "99999999-8888-7777-6666-555555555555",
      "dataset_name": "Traffic Learning Dataset",
      "fields": [
        {
          "name": "src_ip",
          "type": "string"
        },
        {
          "name": "label",
          "type": "string",
          "target": true,
          "values": ["normal", "anomaly"],
          "cardinality": 2,
          "importance": 0.83
        }
      ],
      "parameters": {
        "max_depth": "5",
        "n_estimators": "100"
      },
      "trained": true,
      "train_progress": 100.0,
      "schema": null,
      "accuracy": 0.95,
      "precision": 0.93,
      "recall": 0.91,
      "f1": 0.92,
      "confusion": [[120, 5], [8, 110]],
      "created": 1718668225000,
      "updated": 1718668225000
    }
  ]
}
  • total_count (32-bit integer): Total number of records that match the search criteria
  • models (Array): Machine learning model list
    • guid (String): Model identifier
    • type (String): Model type code
    • type_name (String): Localized model type name
    • user_guid (String): Identifier of the account that created the model
    • user_name (String): Name of the account that created the model
    • name (String): Model name
    • description (String): Model description
    • dataset_guid (String, nullable): Learning dataset identifier
    • dataset_name (String): Learning dataset name
    • fields (Array): Model field list
      • name (String): Field name
      • type (String): Field data type
      • target (Boolean, optional): Whether this is the target field. Present only when true
      • values (String array, optional): List of category values. Present only when set
      • cardinality (32-bit integer, optional): Number of category values. Present only when values is set
      • importance (64-bit float, optional): Field importance. Present only when greater than 0
    • parameters (Map): Hyperparameter key/value
    • trained (Boolean): Whether training is completed
    • train_progress (64-bit float): Training progress percentage
    • schema (Map, nullable): Model schema
    • accuracy (64-bit float): Accuracy
    • precision (64-bit float): Precision
    • recall (64-bit float): Recall
    • f1 (64-bit float): F1 score
    • confusion (Array, nullable): Confusion matrix as an array of 32-bit-integer arrays, where each row is [actual][expected]
    • created (Date): Creation time as epoch milliseconds
    • updated (Date): Last update time as epoch milliseconds

Error Responses

offset or limit value is not an integer

HTTP status code 400

{
  "error_code": "invalid-argument",
  "error_msg": "'offset' parameter should be int type"
}
Permission denied

HTTP status code 500

{
  "error_code": "illegal-state",
  "error_msg": "no-permission"
}