Spaces:
Sleeping
Sleeping
File size: 10,409 Bytes
ad8da65 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# Endpoint Overview ## Overview The query endpoint expects a body that represents a query with the following keys: * `select` (required) * `from` (optional) * `subquery` (optional) * `filter` (optional) * `group_by` (optional) * `order_by` (optional) ### Property Types There are 2 types of properties that can be returned in the query response: 1. "regular" properties - to select all of these at once time, you can use the `*` string * include all of the model's attributes * `inference_timestamp` * `received_timestamp` * `inference_id` * `partner_inference_id` * `ground_truth_timestamp` (if ground truth is included) * `batch_id` (if batch model) 2. "enriched" properties - you must specify these by name to include them in the response and use the `from` value `enriched`: * `anomaly_score` * `lime_importance` * `shap_importance` ### 'From' Sources There are 3 valid values for the `from` field: 1. `inference` - The latest, raw inference data sent to the platform. This is the default. 2. `enriched` - Every value from the `inference` data, with additional fields for anomaly scores and explanations. This data has some insert latency compared to the raw table. 3. `reference` - The reference data set uploaded for the model. (endpoint_overview_filter_field)= ### Filter Field The `filter` field contains a list of filters to apply to your query. It takes the form: ```json { "filter": [ { "property": "<property_name> [string]", "comparator": "<comparator> [string]", "value": "<value> [any]" }, "..." ] } ``` (endpoint_overview_filter_comparators)= #### Filter Comparators The following filter comparators are available: * `eq` - Filters where the property field equals the value field. * `ne` - Filters where the property field is not equal to the value field. * `lt` - Filters where the property field is less than the value field. Only valid for number values. * `gt` - Filters where the property field is greater than the value field. Only valid for number values. * `lte` - Filters where the property field is less than or equal to the value field. Only valid for number values. * `gte` - Filters where the property field is greater than or equal to the value field. Only valid for number values. * `in` - Filters where the property field is equal to any value in a list of possible values * `like` - Filters where the property field is like the value field. This filter is only valid for property types of unstructured text. * `NotNull` - Filters where the property field is not null. Value field should be empty. * `IsNull` - Filters where the property field is null. Value field should be empty. ### Object Detection Fields Computer Vision models with an Output Type of `Object Detection` have some special fields you can use when querying. Bounding boxes are sent using the following form: `[class_id, confidence, top_left_x, top_left_y, width, height]`. While the fields aren't named when sending data, you can access these nested fields when querying. Using the following model as an example: ``` InputType: Image OutputType: ObjectDetection Attributes: name stage value_type 0 image PIPELINE_INPUT IMAGE 1 label GROUND_TRUTH BOUNDING_BOX 2 objects_detected PREDICTED_VALUE BOUNDING_BOX ``` Example query fetching all bounding box fields ```json { "selects": [ { "property": "inference_id" }, { "property": "objects_detected" } ] } ``` The reponse will have 1 object per bounding box. ```json { "query_result": [ { "inference_id": "1", "objects_detected.class_id": 0, "objects_detected.confidence": 0.6, "objects_detected.top_left_x": 23, "objects_detected.top_left_y": 45, "objects_detected.width": 20, "objects_detected.height": 30 }, { "inference_id": "1", "objects_detected.class_id": 1, "objects_detected.confidence": 0.6, "objects_detected.top_left_x": 23, "objects_detected.top_left_y": 45, "objects_detected.width": 20, "objects_detected.height": 30 }, { "inference_id": 2, "...": "..." } ] } ``` You can also specify only a single nested field: ```json { "selects": [ { "property": "inference_id" }, { "property": "objects_detected.class_id" }, { "property": "objects_detected.confidence" } ] } ``` The reponse will have 1 object per bounding box. ```json { "query_result": [ { "inference_id": "1", "objects_detected.class_id": 0, "objects_detected.confidence": 0.6 }, { "inference_id": "1", "objects_detected.class_id": 1, "objects_detected.confidence": 0.6 }, { "inference_id": 2, "...": "..." } ] } ``` ```{note} When supplying the bounding box specific fields in filters, group bys, or order bys the columns must also be supplied in the select clause in order for the query to succeed. ``` ## Inference Search Examples ### Example 1: Inference ID Select all an inference's non-enriched properties where `inference_id` is equal to `e8cc429c-c4a6-425e-af09-7567fafdb17b` (this is the id that returns when an inference that is sent to Arthur) Query Request Body: ```json { "select": [ { "property": "*" } ], "filter": [ { "property": "inference_id", "comparator": "eq", "value": "e8cc429c-c4a6-425e-af09-7567fafdb17b" } ] } ``` Query Response: ```json { "query_result": [ { "inference_id": "e8cc429c-c4a6-425e-af09-7567fafdb17b", "partner_inference_id": "8734-3423", "attr1": "something" } ] } ``` [back to top](#endpoint-overview) ### Example 2: Partner Inference ID Select all the inference's non-enriched properties where the `partner_inference_id` is equal to `8734-3423` (this is the id that the user specifies to associate with an inference that is sent to Arthur) Query Request Body: ```json { "select": [ { "property": "*" } ], "filter": [ { "property": "partner_inference_id", "comparator": "eq", "value": "8734-3423" } ] } ``` Query Response: ```json { "query_result": [ { "inference_id": "e8cc429c-c4a6-425e-af09-7567fafdb17b", "partner_inference_id": "8734-3423", "attr1": "something" } ] } ``` [back to top](#endpoint-overview) ### Example 3: Timestamp Filters Select all the inference's non-enriched properties and `anomaly_score` where `inference_timestamp` is greater than or equal to `2020-22-07T10:00:00` and less than `2020-22-07T11:00:00` Query Request Body: ```json { "select": [ { "property": "*" }, { "property": "anomaly_score" } ], "from": "enriched", "filter": [ { "property": "inference_timestamp", "comparator": "gte", "value": "2020-07-22T10:00:00Z" }, { "property": "inference_timestamp", "comparator": "lt", "value": "2020-07-22T11:00:00Z" } ] } ``` Query Response: ```json { "query_result": [ { "inference_id": "0001", "attr1": "something", "anomaly_score": 0.34, "inference_timestamp": "2020-07-22T10:01:23Z" }, { "inference_id": "0002", "attr1": "something", "anomaly_score": 0.67, "inference_timestamp": "2020-07-22T10:02:55Z" } ] } ``` [back to top](#endpoint-overview) ### Example 4: Batch ID Filter Select all of the inference's non-enriched properties where `inference_timestamp` is greater than or equal to `2020-22-07T10:00:00` and less than `2020-22-07T11:00:00` and where `batch_id` is equal to `batch1` Query Request Body: ```json { "select": [ { "property": "*" } ], "filter": [ { "property": "inference_timestamp", "comparator": "gte", "value": "2020-07-22T10:00:00Z" }, { "property": "inference_timestamp", "comparator": "lt", "value": "2020-07-22T11:00:00Z" }, { "property": "batch_id", "comparator": "eq", "value": "batch1" } ] } ``` Query Response: ```json { "query_result": [ { "inference_id": "0001", "attr1": "something", "batch_id": "batch1", "inference_timestamp": "2020-07-22T10:01:23Z" }, { "inference_id": "0002", "attr1": "something", "batch_id": "batch1", "inference_timestamp": "2020-07-22T10:02:55Z" } ] } ``` [back to top](#endpoint-overview) ### Example 5: Aliasing and Order By Select the `inference_id`, `state`, `income`, `inference_timestamp`, and `health_score` as `predicted_health_score` where `inference_timestamp` is greater than or equal to `2020-22-07T10:00:00` and less than `2020-22-07T11:00:00` and where `state` is equal to `DC` and `income` is greater than or equal to `50000` and less than `90000` Query Request Body: ```json { "select": [ { "property": "inference_id" }, { "property": "state" }, { "property": "income" }, { "property": "inference_timestamp" }, { "property": "health_score", "alias": "predicted_health_score" } ], "filter": [ { "property": "inference_timestamp", "comparator": "gte", "value": "2020-07-22T10:00:00Z" }, { "property": "inference_timestamp", "comparator": "lt", "value": "2020-07-22T11:00:00Z" }, { "property": "state", "comparator": "eq", "value": "DC" }, { "property": "income", "comparator": "gte", "value": 50000 }, { "property": "income", "comparator": "lt", "value": 90000 } ], "order_by": [ { "property": "income", "direction": "desc" } ] } ``` Query Response: ```json { "query_result": [ { "inference_id": "e8cc429c-c4a6-425e-af09-7567fafdb17b", "state": "DC", "income": 75000, "predicted_health_score": 84.3, "inference_timestamp": "2020-07-22T10:02:55Z" }, { "inference_id": "1b813f11-94b8-4b5d-b26d-bc1cbc99b708", "state": "DC", "income": 52000, "predicted_health_score": 79.6, "inference_timestamp": "2020-07-22T10:31:02Z" } ] } ``` [back to top](#endpoint-overview) |