-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (23 loc) · 827 Bytes
/
Copy pathmain.py
File metadata and controls
28 lines (23 loc) · 827 Bytes
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
from ReadData import *
from Model import *
import matplotlib.pyplot as plt
from sklearn.preprocessing import minmax_scale
def train():
trainX, trainY, testX, testY = readData()
# Train ==========================
input_dim = 12
model = getModel(input_dim)
model.fit(trainX, trainY, nb_epoch=4000, batch_size=6000, verbose=1, shuffle=True, validation_split=0.2)
predict = model.predict(testX)
testY = minmax_scale(testY, (1213, 1287))
testY = np.rint(testY)
predict = minmax_scale(predict, (1213, 1287))
predict = np.rint(predict)
rmse = np.sqrt((np.asarray((np.subtract(predict, testY))) ** 2).mean())
print 'data len: %d rmse=%f' %(len(testY), rmse)
plt.figure()
plt.plot(testY, 'r')
plt.plot(predict, 'b')
plt.show()
if __name__ == "__main__":
train()