{ "cells": [ { "cell_type": "markdown", "id": "046e029c", "metadata": {}, "source": [ "# Logging Plots as PNGs" ] }, { "cell_type": "markdown", "id": "24c9f6dc", "metadata": {}, "source": [ "`rubicon_ml` makes it easy to log `Plotly` plots and images with `artifacts`. In this example we'll walk through creating a plot using `plotly.express` and saving it as an `artifact`.\n", "\n", "Before getting started, we'll have to install some dependencies for this example." ] }, { "cell_type": "code", "execution_count": 1, "id": "f4ed1f85-e2f9-45ae-9b23-c4e06731fc7f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: Pillow in /Users/nvd215/mambaforge/envs/rubicon-ml-dev/lib/python3.10/site-packages (9.2.0)\n" ] } ], "source": [ "! pip install kaleido Pillow" ] }, { "cell_type": "markdown", "id": "68ed6c66", "metadata": {}, "source": [ "## Set up\n", "First lets set up our `rubicon_ml` project." ] }, { "cell_type": "code", "execution_count": 2, "id": "22a40144", "metadata": {}, "outputs": [], "source": [ "import os\n", "\n", "from rubicon_ml import Rubicon\n", "\n", "\n", "rubicon = Rubicon(persistence=\"memory\")\n", "project = rubicon.get_or_create_project(\"Artifact Plots\")" ] }, { "cell_type": "markdown", "id": "8b07aa77", "metadata": {}, "source": [ "Next, create plotting data. This example leverages `plotly` and `plotly.express` for data and plot generation." ] }, { "cell_type": "code", "execution_count": 3, "id": "4ccb7530", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | direction | \n", "strength | \n", "frequency | \n", "
---|---|---|---|
0 | \n", "N | \n", "0-1 | \n", "0.5 | \n", "
1 | \n", "NNE | \n", "0-1 | \n", "0.6 | \n", "
2 | \n", "NE | \n", "0-1 | \n", "0.5 | \n", "
3 | \n", "ENE | \n", "0-1 | \n", "0.4 | \n", "
4 | \n", "E | \n", "0-1 | \n", "0.4 | \n", "