-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.py
66 lines (48 loc) · 1.34 KB
/
stats.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
fig1 = plt.figure(figsize=(10, 6))
x1 = np.random.randn(1, 20)
y1 = np.random.randn(1, 20)
x2 = np.random.randn(1, 20) + 5
y2 = np.random.randn(1, 20)
x3 = np.random.randn(1, 20)
y3 = np.random.randn(1, 20) + 10
x4 = np.random.randn(1, 20) + 5
y4 = np.random.randn(1, 20) + 10
c1 = plt.plot(x1, y1, 'r.')
c2 = plt.plot(x2, y2, 'b.')
c3 = plt.plot(x3, y3, 'g.')
c4 = plt.plot(x4, y4, 'y.')
plt.show()
fig2 = plt.figure(figsize=(10, 6))
x = np.arange(0, 100, 4)
y = 5 * x + 4
r = (np.random.randn(25, 1) * 7)
y_ = y + r.reshape((25, ))
line = plt.plot(x, y, '-')
dots = plt.plot(x, y_, 'r.')
plt.show()
def dummy_train(t):
return (1-np.exp(-5*x))
def dummy_test(t):
return (np.sin(2*t)/1.2-np.exp(-5-5*t))
x = np.arange(0, 1, 0.01)
fig3 = plt.figure(figsize=(6, 6))
ax = fig3.add_subplot(111)
ax.plot(x, dummy_train(x), 'b', label='Training Accuracy')
ax.plot(x, dummy_test(x), 'g--', label='Testing Accuracy')
leg = ax.legend(frameon=False, loc=4)
ax.set_xlim(0, 1)
ax.set_xticks([])
ax.set_xlabel('Epochs')
ax.set_ylabel('Accuracy')
plt.show()
x = np.random.rand(30)
y = (x * 8) + np.random.rand(30)
mean = [np.mean(y) for i in range(len(x))]
fig = plt.figure(figsize=(10, 6))
sns.regplot(x, y, label='Data')
plt.plot(x, mean, 'k-', label='Mean')
plt.legend()
plt.show()