{ "cells": [ { "cell_type": "markdown", "id": "607a7ec5-4509-4512-94f9-908899963604", "metadata": {}, "source": [ "# Metric Lists Comparison\n", "\n", "The metric lists comparison is used to facilitate element-wise comparisons\n", "between metrics logged as lists. Users can dynamically choose between available\n", "list metrics to visualize.\n", "\n", "The plot itself is a Plotly annotated heatmap. More information can be found\n", "in [the Plotly documentation](https://plotly.com/python/annotated-heatmap/)." ] }, { "cell_type": "code", "execution_count": 1, "id": "8aad3d90-949e-4efa-a648-ac31689bdfb0", "metadata": { "tags": [] }, "outputs": [], "source": [ "import random\n", "\n", "from rubicon_ml import Rubicon\n", "from rubicon_ml.viz import MetricListsComparison" ] }, { "cell_type": "markdown", "id": "5e1026b2-d42b-447b-97e5-221d6d619935", "metadata": {}, "source": [ "First, we'll create a few experiments and log some list metrics to them." ] }, { "cell_type": "code", "execution_count": 2, "id": "51c7e3fc-ac37-4766-be79-21057199aeee", "metadata": {}, "outputs": [], "source": [ "rubicon = Rubicon(persistence=\"memory\", auto_git_enabled=True)\n", "project = rubicon.get_or_create_project(\"list metric comparison\")\n", "\n", "for i in range(0, 10):\n", " experiment = project.log_experiment()\n", " experiment.log_metric(\n", " name=\"coefficients\",\n", " value=[random.random() for _ in range(0, 25)],\n", " )\n", " experiment.log_metric(\n", " name=\"p-values\",\n", " value=[random.random() for _ in range(0, 25)],\n", " )\n", " experiment.log_metric(\n", " name=\"stderr\",\n", " value=[random.random() for _ in range(0, 25)],\n", " )" ] }, { "cell_type": "markdown", "id": "94d2e5b0-5828-4aff-ab59-a4351f7164a1", "metadata": {}, "source": [ "Now, we can instantiate the `MetricListsComparison` object with the experiments we\n", "just logged. Optionally, provide a list of column names as `column_names` to add the\n", "names as a header to each column in the visualization.\n", "\n", "We can view the plot right in the notebook with `show`. The Dash application\n", "itself will be running on http://127.0.0.1:8050/ when running locally. Use the\n", "`serve` command to launch the server directly without rendering the widget in the\n", "current Python interpreter." ] }, { "cell_type": "code", "execution_count": 3, "id": "68c4321a-6e41-4597-98b6-4921dcedd3aa", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Dash is running on http://127.0.0.1:8050/\n" ] } ], "source": [ "MetricListsComparison(\n", " experiments=project.experiments(),\n", " column_names=[\"intercept\"] + [f\"var_{i:03}\" for i in range(1, 25)],\n", ").show()" ] }, { "cell_type": "markdown", "id": "194fa6a5-12d1-48ce-b13d-ef0605970d09", "metadata": {}, "source": [ "![metric-lists-comparisons](metric-lists-comparisons.png \"metric lists comparisons\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }