Skip to content

Commit fe6a15a

Browse files
authored
few fixes to custom basics (#1444)
- updated the iuo in the methods name, since this is a reserved name. - removed hardcoded variables
1 parent 65089f2 commit fe6a15a

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
"metadata": {},
7676
"source": [
7777
"import labelbox.types as lb_types\n",
78+
"import labelbox as lb\n",
79+
"import uuid\n",
7880
"import json"
7981
],
8082
"cell_type": "code",
@@ -121,11 +123,11 @@
121123
{
122124
"metadata": {},
123125
"source": [
124-
"data_row_metric = ScalarMetric(metric_name=\"iou\", value=0.5)\n",
126+
"data_row_metric = ScalarMetric(metric_name=\"iou_custom\", value=0.5)\n",
125127
"\n",
126-
"feature_metric = ScalarMetric(metric_name=\"iou\", feature_name=\"cat\", value=0.5)\n",
128+
"feature_metric = ScalarMetric(metric_name=\"iou_custom\", feature_name=\"cat\", value=0.5)\n",
127129
"\n",
128-
"subclass_metric = ScalarMetric(metric_name=\"iou\",\n",
130+
"subclass_metric = ScalarMetric(metric_name=\"iou_custom\",\n",
129131
" feature_name=\"cat\",\n",
130132
" subclass_name=\"organge\",\n",
131133
" value=0.5)"
@@ -192,7 +194,7 @@
192194
" 0.9: [1, 0, 1, 0]\n",
193195
" })\n",
194196
"\n",
195-
"scalar_metric_with_confidence = ScalarMetric(metric_name=\"iou\",\n",
197+
"scalar_metric_with_confidence = ScalarMetric(metric_name=\"iou_custom\",\n",
196198
" value={\n",
197199
" 0.1: 0.2,\n",
198200
" 0.3: 0.25,\n",
@@ -300,18 +302,7 @@
300302
"print(feature_confusion_matrix_metric(ground_truths, predictions))"
301303
],
302304
"cell_type": "code",
303-
"outputs": [
304-
{
305-
"name": "stdout",
306-
"output_type": "stream",
307-
"text": [
308-
"[ScalarMetric(value=0.64, feature_name='cat', subclass_name=None, extra={}, metric_name='iou', aggregation=<ScalarMetricAggregation.ARITHMETIC_MEAN: 'ARITHMETIC_MEAN'>)]\n",
309-
"[ScalarMetric(value=0.64, feature_name=None, subclass_name=None, extra={}, metric_name='iou', aggregation=<ScalarMetricAggregation.ARITHMETIC_MEAN: 'ARITHMETIC_MEAN'>)]\n",
310-
"[ConfusionMatrixMetric(value=(1, 0, 0, 0), feature_name=None, subclass_name=None, extra={}, metric_name='50pct_iou', aggregation=<ConfusionMatrixAggregation.CONFUSION_MATRIX: 'CONFUSION_MATRIX'>)]\n",
311-
"[ConfusionMatrixMetric(value=(1, 0, 0, 0), feature_name='cat', subclass_name=None, extra={}, metric_name='50pct_iou', aggregation=<ConfusionMatrixAggregation.CONFUSION_MATRIX: 'CONFUSION_MATRIX'>)]\n"
312-
]
313-
}
314-
],
305+
"outputs": [],
315306
"execution_count": null
316307
},
317308
{
@@ -322,20 +313,13 @@
322313
"print(feature_confusion_matrix_metric(ground_truths, predictions, iou=0.9))"
323314
],
324315
"cell_type": "code",
325-
"outputs": [
326-
{
327-
"name": "stdout",
328-
"output_type": "stream",
329-
"text": [
330-
"[ConfusionMatrixMetric(value=(0, 1, 0, 1), feature_name='cat', subclass_name=None, extra={}, metric_name='90pct_iou', aggregation=<ConfusionMatrixAggregation.CONFUSION_MATRIX: 'CONFUSION_MATRIX'>)]\n"
331-
]
332-
}
333-
],
316+
"outputs": [],
334317
"execution_count": null
335318
},
336319
{
337320
"metadata": {},
338321
"source": [
322+
"\n",
339323
"# subclasses are included by default\n",
340324
"predictions = [\n",
341325
" lb_types.ObjectAnnotation(\n",
@@ -375,16 +359,7 @@
375359
"print(\"Excluding Subclasses:\", iou_metrics[0].value)"
376360
],
377361
"cell_type": "code",
378-
"outputs": [
379-
{
380-
"name": "stdout",
381-
"output_type": "stream",
382-
"text": [
383-
"Subclasses: (0, 1, 0, 1)\n",
384-
"Excluding Subclasses: (1, 0, 0, 0)\n"
385-
]
386-
}
387-
],
362+
"outputs": [],
388363
"execution_count": null
389364
},
390365
{
@@ -404,9 +379,10 @@
404379
"metadata": {},
405380
"source": [
406381
"# Continuing with the last example:\n",
382+
"global_key = \"<global_key>\"\n",
407383
"metrics = [*conf_matrix_metrics, *iou_metrics]\n",
408384
"labels = [\n",
409-
" lb_types.Label(data=lb_types.ImageData(uid=\"cktiom8osh4210ytmevuk7lfh\"), annotations=metrics)\n",
385+
" lb_types.Label(data=lb_types.ImageData(global_key=global_key), annotations=metrics)\n",
410386
"]\n",
411387
"# We can upload these metric with other annotations\n",
412388
"#model_run.add_predictions(f'diagnostics-import-{uuid.uuid4()}', labels)"

0 commit comments

Comments
 (0)