1

I want to make a table that summarizes the result of my grid search. I wrote the code below. To show just different configurations, the table works fine. But I want to add a new column that shows the loss for each configuration too. I don't know how to add a new column with Tabulate module. In my code, l is the list of different configurations (a list of dics) and loss is a list of losses (for each configuration).

data = l
print(tabulate(data, headers="keys", tablefmt="fancy_grid", showindex="always"))

I tried appending loss directly to l and then using l as my data like this:

l.append(total_losses)

but I got this error: 'list' object has no attribute 'keys'

for the moment my table looks like this: enter image description here

Totoro
  • 474
  • 2
  • 6
  • 18

1 Answers1

0

Ok, I solved it myself, like this:

for i in range(len(l)):
    l[i]['MSE loss'] =  loss[i]

In fact, here, l is a list of dictionaries. In each dictionary, there are values for learning_rate, epochs, batch_size, ... With the code above, I add an element to each dictionary on my list!

Now the table looks like this: enter image description here

Totoro
  • 474
  • 2
  • 6
  • 18