Jensen-holm's picture
we should try to do this with regression on a simple dataset from the internet somewhere because I think it is hard to see how well it is doing with completley random data
4175aca
raw
history blame
826 Bytes
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation, FFMpegWriter
sns.set()
"""
Save plots to the plots folder for when
we would like to show results on our little
flask application
"""
def loss_history_plt(loss_history: list) -> FuncAnimation:
fig, ax = plt.subplots()
def animate(i):
ax.clear()
sns.lineplot(
x=range(i),
y=loss_history[:i],
ax=ax,
)
ax.set_xlabel("Epoch")
ax.set_ylabel("Training Loss")
return FuncAnimation(fig, animate, frames=len(loss_history), interval=100)
def save_plt(plot, filename: str, animated: bool, fps=10):
if not animated:
plot.savefig(filename)
return
writer = FFMpegWriter(fps=fps)
plot.save(filename, writer=writer)