0

After training a model, I want to plot the accuracy, validation accuracy, etc. In Seaborn, this is what I tried to do:

df_model_history = pd.DataFrame( np.array([ history.history['accuracy'], history.history['val_accuracy'] ]).T, columns=['Accuracy', 'Validation Accuracy'] ) df_model_history.index.name = 'Epochs' 

That creates a data frame that looks like this:

Epochs Accuracy Validation Accuracy
0 0.769296 0.766673
1 0.858553 0.894064
2 0.915641 0.901508
3 0.936782 0.892285

And when I want to plot, I do this:

sns.set(rc={'figure.figsize':(11.7,8.27)}) sns.lineplot( x='Epochs', y='Accuracy', data=df_model_history ) 

However, this only plots a single variable in the figure, but I wanted both 'accuracy' and 'val_accuracy' in the same figure. Also, compared to Matplotlib, I have a lot more steps in Seaborn to plot the same output, so I was wondering if I'm doing it incorrectly.

2
  • .melt 'accuracy' and 'validation accuracy', and then set hue='name of new label column' Commented May 5, 2022 at 15:05
  • dfm = df.melt(id_vars='Epochs') and sns.lineplot(data=dfm, x='Epochs', y='value', hue='variable') Commented May 5, 2022 at 15:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.