-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
43 lines (37 loc) · 1.23 KB
/
utils.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
41
42
43
import matplotlib.pyplot as plt
column_names = ['serial', 'date', 'age', 'distance', 'stores', 'latitude', 'longitude', 'price']
def plot_loss(history):
h = history.history
x_lim = len(h['loss'])
plt.figure(figsize=(8, 8))
plt.plot(range(x_lim), h['val_loss'], label = 'Validation Loss')
plt.plot(range(x_lim), h['loss'], label = 'Training Loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show()
return
def plot_predictions(preds, y_test):
plt.figure(figsize=(8, 8))
plt.plot(preds, y_test, 'ro')
plt.xlabel('Preds')
plt.ylabel('Labels')
plt.xlim([-0.5, 0.5])
plt.ylim([-0.5, 0.5])
plt.plot([-0.5, 0.5], [-0.5, 0.5], 'b--')
plt.show()
return
def compare_predictions(preds1, preds2, y_test):
plt.figure(figsize=(8, 8))
plt.plot(preds1, y_test, 'ro', label='Untrained Model')
plt.plot(preds2, y_test, 'go', label='Trained Model')
plt.xlabel('Preds')
plt.ylabel('Labels')
y_min = min(min(y_test), min(preds1), min(preds2))
y_max = max(max(y_test), max(preds1), max(preds2))
plt.xlim([y_min, y_max])
plt.ylim([y_min, y_max])
plt.plot([y_min, y_max], [y_min, y_max], 'b--')
plt.legend()
plt.show()
return