-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelplot.py
40 lines (35 loc) · 1.1 KB
/
Helplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import matplotlib.pyplot as plt
plt.style.use("seaborn-v0_8-whitegrid")
class Helplot:
"""
TensorFlow Model Training History Plot
>>> history = model.fit(train, ...)
>>> plot_hist = Helplot(history)
>>> plot_hist.Relplot
>>> plot_hist.Falplot
"""
def __init__(self, history):
self.history = history
self.accuracy = history.history['accuracy']
self.val_accuracy = history.history['val_accuracy']
self.loop = [*range(1, len(self.accuracy) + 1)]
self.loss = history.history['loss']
self.val_loss = history.history['val_loss']
@property
def Relplot(self):
plt.plot(self.loop, self.accuracy, label='Train Accuracy')
plt.plot(self.loop, self.val_accuracy, label='Val Accuracy')
plt.title("Accuracy Result")
plt.xlabel("Epochs")
plt.ylabel("Accuracy")
plt.xticks(self.loop)
plt.legend()
@property
def Falplot(self):
plt.plot(self.loop, self.loss, label='Train Loss')
plt.plot(self.loop, self.val_loss, label='Val Loss')
plt.title("Loss Result")
plt.xlabel("Epochs")
plt.ylabel("Loss")
plt.xticks(self.loop)
plt.legend()