From 95a98e5e0244c9a548e3e0b91af30da74ad2938d Mon Sep 17 00:00:00 2001 From: ovalle15 Date: Thu, 29 Feb 2024 17:26:56 -0500 Subject: [PATCH] few fixes --- .../custom_metrics_basics.ipynb | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb b/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb index ea7312f6a..842668062 100644 --- a/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb +++ b/examples/model_experiments/model_diagnostics/custom_metrics_basics.ipynb @@ -75,6 +75,8 @@ "metadata": {}, "source": [ "import labelbox.types as lb_types\n", + "import labelbox as lb\n", + "import uuid\n", "import json" ], "cell_type": "code", @@ -121,11 +123,11 @@ { "metadata": {}, "source": [ - "data_row_metric = ScalarMetric(metric_name=\"iou\", value=0.5)\n", + "data_row_metric = ScalarMetric(metric_name=\"iou_custom\", value=0.5)\n", "\n", - "feature_metric = ScalarMetric(metric_name=\"iou\", feature_name=\"cat\", value=0.5)\n", + "feature_metric = ScalarMetric(metric_name=\"iou_custom\", feature_name=\"cat\", value=0.5)\n", "\n", - "subclass_metric = ScalarMetric(metric_name=\"iou\",\n", + "subclass_metric = ScalarMetric(metric_name=\"iou_custom\",\n", " feature_name=\"cat\",\n", " subclass_name=\"organge\",\n", " value=0.5)" @@ -192,7 +194,7 @@ " 0.9: [1, 0, 1, 0]\n", " })\n", "\n", - "scalar_metric_with_confidence = ScalarMetric(metric_name=\"iou\",\n", + "scalar_metric_with_confidence = ScalarMetric(metric_name=\"iou_custom\",\n", " value={\n", " 0.1: 0.2,\n", " 0.3: 0.25,\n", @@ -300,18 +302,7 @@ "print(feature_confusion_matrix_metric(ground_truths, predictions))" ], "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[ScalarMetric(value=0.64, feature_name='cat', subclass_name=None, extra={}, metric_name='iou', aggregation=)]\n", - "[ScalarMetric(value=0.64, feature_name=None, subclass_name=None, extra={}, metric_name='iou', aggregation=)]\n", - "[ConfusionMatrixMetric(value=(1, 0, 0, 0), feature_name=None, subclass_name=None, extra={}, metric_name='50pct_iou', aggregation=)]\n", - "[ConfusionMatrixMetric(value=(1, 0, 0, 0), feature_name='cat', subclass_name=None, extra={}, metric_name='50pct_iou', aggregation=)]\n" - ] - } - ], + "outputs": [], "execution_count": null }, { @@ -322,20 +313,13 @@ "print(feature_confusion_matrix_metric(ground_truths, predictions, iou=0.9))" ], "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[ConfusionMatrixMetric(value=(0, 1, 0, 1), feature_name='cat', subclass_name=None, extra={}, metric_name='90pct_iou', aggregation=)]\n" - ] - } - ], + "outputs": [], "execution_count": null }, { "metadata": {}, "source": [ + "\n", "# subclasses are included by default\n", "predictions = [\n", " lb_types.ObjectAnnotation(\n", @@ -375,16 +359,7 @@ "print(\"Excluding Subclasses:\", iou_metrics[0].value)" ], "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Subclasses: (0, 1, 0, 1)\n", - "Excluding Subclasses: (1, 0, 0, 0)\n" - ] - } - ], + "outputs": [], "execution_count": null }, { @@ -404,9 +379,10 @@ "metadata": {}, "source": [ "# Continuing with the last example:\n", + "global_key = \"\"\n", "metrics = [*conf_matrix_metrics, *iou_metrics]\n", "labels = [\n", - " lb_types.Label(data=lb_types.ImageData(uid=\"cktiom8osh4210ytmevuk7lfh\"), annotations=metrics)\n", + " lb_types.Label(data=lb_types.ImageData(global_key=global_key), annotations=metrics)\n", "]\n", "# We can upload these metric with other annotations\n", "#model_run.add_predictions(f'diagnostics-import-{uuid.uuid4()}', labels)"