{ "cells": [ { "cell_type": "markdown", "id": "966177ec-5366-409e-9b9f-66566d329a1b", "metadata": {}, "source": [ "# Metric Correlation Plot\n", "\n", "The metric correlation plot is used to compare how various input parameters\n", "effect a selected output metric across a number of experiments. Users can\n", "dynamically choose between available metrics to anchor the visualization on\n", "and rearrange and highlight the plot as desired.\n", "\n", "The plot itself is a Plotly parallel coordinates plot. More information can\n", "be found in [the Plotly documentation](https://plotly.com/python/parallel-coordinates-plot/)." ] }, { "cell_type": "code", "execution_count": 1, "id": "b0b35758-483e-463a-b955-13a3f8ab5129", "metadata": {}, "outputs": [], "source": [ "import random\n", "\n", "from rubicon_ml import Rubicon\n", "from rubicon_ml.viz import MetricCorrelationPlot" ] }, { "cell_type": "markdown", "id": "fd871177-8049-44fa-ac2d-f7c592fecc23", "metadata": {}, "source": [ "First, we'll create a few experiments and log some parameters and metrics to them." ] }, { "cell_type": "code", "execution_count": 2, "id": "0a4bcd49-999f-48ff-9dea-955f1ea1881d", "metadata": {}, "outputs": [], "source": [ "rubicon = Rubicon(persistence=\"memory\", auto_git_enabled=True)\n", "project = rubicon.get_or_create_project(\"metric correlation plot\")\n", "\n", "for i in range(0, 100):\n", " experiment = project.log_experiment()\n", "\n", " experiment.log_parameter(\n", " name=\"is_standardized\",\n", " value=random.choice([True, False]),\n", " )\n", " experiment.log_parameter(name=\"n_estimators\", value=random.randrange(2, 10, 2))\n", " experiment.log_parameter(\n", " name=\"sample\",\n", " value=random.choice([\"A\", \"B\", \"C\", \"D\", \"E\"]),\n", " )\n", "\n", " experiment.log_metric(name=\"accuracy\", value=random.random())\n", " experiment.log_metric(name=\"confidence\", value=random.random())" ] }, { "cell_type": "markdown", "id": "1210c856-736b-4819-b424-7f1cec6baaf1", "metadata": {}, "source": [ "Now, we can instantiate the `MetricCorrelationPlot` object with the experiments we just\n", "logged and 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": "0c1bbd4e-7783-467b-8831-3a3dbfa932c7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Dash is running on http://127.0.0.1:8050/\n" ] } ], "source": [ "MetricCorrelationPlot(\n", " experiments=project.experiments(),\n", " selected_metric=\"accuracy\",\n", ").show()" ] }, { "cell_type": "markdown", "id": "1f6b2019-47c2-48d5-ae38-397b7b107784", "metadata": {}, "source": [ "![metric-correlation-plot](metric-correlation-plot.png \"metric correlation plot\")" ] } ], "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 }