but then found out that Wandb doesn’t support plotting a list by default. I want to create a line plot where the y-axis is the first element of the metric array, and the x-axis is the step.
I’ve read the Custom Charts section of the document. I think I should use Vega to access the first element of the array. Here are the steps that I’ve taken:
For the custom chart, I’ve set the data source as “history” and selected the “metric” key.
query {
runSets
(runSets: "${runSets}" ) {
id
name
history
(keys: ["metric" ] )
}
}
In the Vega script, I tried to flatten the array, using this part of the documentation
This gives me a warning that “type” and “fields” arguments are not allowed, which means I should include this flattening block somewhere else (not in the transform section).
I’m afraid I don’t know where, and how I can achieve this.
Is this even possible?
If not, I think in my notebook I should write a script that accesses the wandb.run log data, and transform the data for each run. if so, any tips for that solution are also appreciated.
I’ve also read similar posts in the community, but their use cases were different.
[cross-posted in Stackoverflow, but since I’m a new user, I can’t put its link here (2 URL limit))
I’ve used this code snippet to add the plot for the previous runs. I thought it might help somebody. but still, if there’s a way to do this with Vega, it would be so much better. as this alternate method requires the following code snippet to be run every time we want to see the updated plots.
import matplotlib.pyplot as plt
import wandb
runs = api.runs('workspace/project_name')
for i in range(len(runs))[:1]:
run_history = runs[i].scan_history(keys=["metric"])
values = [row['metric'] for row in run_history]
plt.plot(values)
plt.ylabel("metric")
wandb.init(
project="project_name",
id=run_history.run.id,
resume=True
)
wandb.log({"metric_plot": plt})
Here is a workspace where I logged 100 steps of wandb.log({"metric": [random.randint(0,100), 5, 6]}) in one run and graphed the x-axis as step and the y-axis as the first item in the list.
Here are the steps to creating the Table:
Press Add Panel → Weave
For the query, write in runs.history.concat. This will make a table of log history.
Go to the bottom right of the panel and select Columns and make sure that only _step and metric is chosen
Press the Gear in the top right of the Panel. This should open up your settings. For the X Dim, write in row["_step"] and for the Y Dim write in row["metric"][0]. This will make a scatterplot. In order to change this to a line plot, change the Mark into a line.