John Run Name dupes
Method: wandb.plot.line()
Log a custom line plot—a list of connected/ordered points (x, y) on a pair of arbitrary axes x and y—natively in a few lines:
data = [[x, y] for (x, y) in zip(x_values, y_values)]
table = wandb.Table(data, columns = ["x", "y"])
wandb.log({"my_custom_plot_id" : wandb.plot.line(table, "x", "y", title="Custom Y vs X Line Plot")
You can use this to log curves on any two dimensions. Note that if you're plotting two lists of values against each other, the number of values in the lists must match exactly (i.e. each point must have an x and a y).
Basic usage example
I finetune a CNN to predict 10 classes of living things: plants, birds, insects, etc. I want to plot the binarized average precision curve (simplifying to a binary correct/incorrect label across all 10 classes). In my validation step, I compute the micro-averaged precision and recall using sklearn and following their example for multi-label settings to yield two arrays of the same length: precision_micro
and recall_micro
(see the end of this report for the full details). The line plot I want to create will show precision_micro
values on the y axis versus the matching recall_micro
values on the x axis.
I can now call:
data = [[x, y] for (x, y) in zip(recall_micro, precision_micro)]
table = wandb.Table(data, columns = ["recall_micro", "precision_micro"])
wandb.log({"my_lineplot_id" : wandb.plot.scatter(table, "recall_micro", "precision_micro", title="Average Precision")})
Steps to follow:
- create a
data
object: collect your points as a 2D list/array, where each row is a point and each column is a dimension. This line plot assumes two dimensions / two columns, but you could pass in more data and customize the plot further if you wish, e.g. use a third dimension to indicate color. - pass
data
to awandb.Table()
object in which you name the columns in order so you can refer to them later - pass the
table
object and the same x and y column names in order towandb.plots.line()
with an optional title, which will create your custom plot under the keymy_lineplot_id
. To visualize multiple runs on the same plot, keep this plot key constant. Note that the table itself will also be logged in the "Media" section of your workspace, undermy_lineplot_id_table
.
Above, you can see the average precision improve (curve trends up and to the right) as the number of training examples and
Customized usage
There are many ways to customize the line plot using the Vega visualization grammar.
Here are some simple ones:
- rename the axis titles for clarity: add
"title" : "Your Title"
to thex
andy
fields underencoding
On any chart, you can pan around and zoom in to see more detail, as well as see more information about a point on hover (and modify this display information as well!).
TODO: fill in per epoch example?
P.S. Computing average precision for multi-class models
You can compute this whenever your code has access to:
- a model's predicted scores (
val_predictions
) on a set of examples - the corresponding ground truth labels (
ground_truth
) for those examples
from sklearn.metrics import precision_recall_curve
from sklearn.preprocessing import label_binarize
# generate binary correctness labels across classes
binary_ground_truth = label_binarize(ground_truth,
classes=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
# compute a PR curve with sklearn like you normally would
precision_micro, recall_micro, _ = precision_recall_curve(binary_ground_truth.ravel(),
val_predictions.ravel())
# now you can log these values to a custom chart!
Method: wandb.plot.line()
Log a custom line plot—a list of connected/ordered points (x, y) on a pair of arbitrary axes x and y—natively in a few lines:
data = [[x, y] for (x, y) in zip(x_values, y_values)]
table = wandb.Table(data, columns = ["x", "y"])
wandb.log({"my_custom_plot_id" : wandb.plot.line(table, "x", "y", title="Custom Y vs X Line Plot")
You can use this to log curves on any two dimensions. Note that if you're plotting two lists of values against each other, the number of values in the lists must match exactly (i.e. each point must have an x and a y).
Basic usage example
I finetune a CNN to predict 10 classes of living things: plants, birds, insects, etc. I want to plot the binarized average precision curve (simplifying to a binary correct/incorrect label across all 10 classes). In my validation step, I compute the micro-averaged precision and recall using sklearn and following their example for multi-label settings to yield two arrays of the same length: precision_micro
and recall_micro
(see the end of this report for the full details). The line plot I want to create will show precision_micro
values on the y axis versus the matching recall_micro
values on the x axis.
I can now call:
data = [[x, y] for (x, y) in zip(recall_micro, precision_micro)]
table = wandb.Table(data, columns = ["recall_micro", "precision_micro"])
wandb.log({"my_lineplot_id" : wandb.plot.scatter(table, "recall_micro", "precision_micro", title="Average Precision")})
Steps to follow:
- create a
data
object: collect your points as a 2D list/array, where each row is a point and each column is a dimension. This line plot assumes two dimensions / two columns, but you could pass in more data and customize the plot further if you wish, e.g. use a third dimension to indicate color. - pass
data
to awandb.Table()
object in which you name the columns in order so you can refer to them later - pass the
table
object and the same x and y column names in order towandb.plots.line()
with an optional title, which will create your custom plot under the keymy_lineplot_id
. To visualize multiple runs on the same plot, keep this plot key constant. Note that the table itself will also be logged in the "Media" section of your workspace, undermy_lineplot_id_table
.