Applications - Model Performance
  • 14 Nov 2024
  • 4 Minutes to read
  • Dark
    Light

Applications - Model Performance

  • Dark
    Light

Article summary

The Application Model Performance endpoint returns the current best model's predictions on the validation data set, in addition to truth data based on user consensus subject-media associations.

Application Model Performance Request Body

Argument

Example

Definition

subject_uid

string

"cat_123"

(required) Output Subject ID; filters truth data for the given subject_uid.

consensus

string

"True"

(optional)    True - Returns results for positive consensus subject-media associations.    False - Returns results for negative consensus subject-media associations.    Defaults to null, i.e. returns all consensus subject media.

abridged_media

boolean

False

(optional)    True - returns abridged media objects consisting solely of media_id.   False - returns full Cogniac media objects.    Defaults to False.

probability_lower

float

0.25

(optional) Lower probability bound of records to return.    Defaults to 0.

probability_upper

float

0.75

(optional) Upper probability bound of records to return.    Defaults to 1.

sort

string

"loss"

(optional) One of 'assertion' or 'loss' to sort results by assertion probability or app_data error, respectively.    Defaults to 'assertion'.

reverse

boolean

True

(optional)  True - return records in descending order.    False - return records in ascending order.    Defaults to False.

limit
integer

25

(optional)  Result limit per page.    Defaults to 100.

Application Model Performance Response

The Retrieve Application Model Peformance endpoint returns a list of model performance objects.

Fields

Example

Definition

media

object

See Cogniac media object

A Cogniac media object.

model_id

string

"Hpo-h-1ec0-to5dGrTAN9QeV6djep-CN_mtsv0_2000.tgz"

The ID of the current best model.

truth_data

array

See  subject-media association objects

A list of subject-media association objects.

predictions

map

See application subject-media assertion objects

A list of application subject-media assertion objects .

app_data_accuracy

float

0.87

Accuracy of assertion app_data versus the truth data.

loss

float

0.13

Error of assertion versus truth data.

GET /1/applications/{application_id}/modelPerformance
Host: https://api.cogniac.io

Example: Retrieve Application Model Performance

#output subject_uid is a required argument to be send in the body of the request
curl -X GET https://api.cogniac.io/1/applications/abcdefghkl/modelPerformance?limit=10 \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
-d '{
 "subject_uid": "plcopy_0ys"
}' \
| json_pp
import requests
import json

url_prefix = 'https://api.cogniac.io'
api_version = "1"
app_id = 'wbyicycm'
token = ''  # add your token here
headers = {'Authorization': f'Bearer {token}',
           'Content-Type': 'application/json'}

#output subject_uid is a required argument to be send in the body of the request
app_data = {
"subject_uid": "plcopy_0ys"
}

url = f'{url_prefix}/{api_version}/applications/{app_id}/modelPerformance?limit=10'
response = requests.get(url, json=app_data, headers=headers)

if response.status_code == 200:
    formatted_json = json.dumps(response.json(), indent=2)
    print(formatted_json)
else:
    print(f"Error: {response.status_code}")
    print(response.content)
{
   "data" : [
      {
         "app_data_accuracy" : 0,
         "focus" : null,
         "loss" : 0,
         "media" : {
            "author" : null,
            "author_profile_url" : null,
            "bits_per_pixel" : 8,
            "created_at" : 1683317870.88554,
            "domain_unit" : "75427d6a6171a161f2f31433647e62aa",
            "duration" : null,
            "external_media_id" : null,
            "filename" : "58.png",
            "fps" : null,
            "frame" : null,
            "frame_durations" : [],
            "frame_preview_map" : {},
            "image_height" : 2050,
            "image_width" : 2432,
            "license" : null,
            "md5" : "75427d6a6171a161f2f31433647e62ab",
            "media_format" : "PNG",
            "media_id" : "TA2MQAZ5KAPCABXB1YPLCZT0VD",
            "media_src" : "web_app",
            "media_timestamp" : 1683312377.315,
            "media_url" : "https://api.cogniac.io/1/media/download/TA2MQAZ5KAPCABXB1YPLCZT0VDXS/TA2MQAZ5KAPCABXB1YPLCZT0VD",
            "meta_tags" : null,
            "network_camera_id" : null,
            "num_channels" : 3,
            "num_frames" : null,
            "original_landing_url" : null,
            "original_url" : null,
            "parent_media_id" : null,
            "parent_media_ids" : [],
            "preview_url" : null,
            "resize_urls" : {
               "1334" : "https://api.cogniac.io/1/media/download/TA2MQAZ5KAPCABXB1YPLCZT0VDXS/TA2MQAZ5KAPCABXB1YPLCZT0VD_max_1334",
               "454" : "https://api.cogniac.io/1/media/download/TA2MQAZ5KAPCABXB1YPLCZT0VDXS/TA2MQAZ5KAPCABXB1YPLCZT0VD_max_454"
            },
            "sequence_ix" : null,
            "set_assignment" : "validation",
            "size" : 5076938,
            "source_url" : null,
            "status" : "success",
            "tenant_id" : "abcdefg",
            "time_base" : null,
            "title" : null,
            "trigger_id" : null,
            "uploaded_by_user" : "test@cogniac.co",
            "video" : false,
            "video_context" : null
         },
         "model_id" : "TECO-17-ACCU-95-864_864-XJA-230828.tgz",
         "predictions" : [
            {
               "app_data" : null,
               "app_data_type" : null,
               "created_at" : 1693261717.96712,
               "focus" : null,
               "media_id" : "TA2MQAZ5KAPCABXB1YPLCZT0VD",
               "subject_uid" : "plcopy_0ys",
               "uncal_prob" : 0
            }
         ],
         "truth_data" : [
            {
               "app_data" : null,
               "app_data_type" : null,
               "consensus" : "False",
               "focus" : null,
               "media_id" : "TA2MQAZ5KAPCABXB1YPLCZT0VD",
               "probability" : 0.00100134942981011,
               "subject_uid" : "plcopy_0ys",
               "updated_at" : 1683325229.44036
           }
       ]
     },
     ...
  }
]


Was this article helpful?