Skip to content

Commit

Permalink
Added data exception checker
Browse files Browse the repository at this point in the history
  • Loading branch information
MewX committed Aug 2, 2017
1 parent 7904694 commit 9de9c26
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions MachineLearning/TensorFlow/lltm_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import matplotlib.pyplot as plt

# definitions
FILE_NAME = "newdata0725_variable_interval.csv"
FILE_NAME = "newdata.csv"
# FILE_NAME = "test.csv"
TIME_INTERVAL = 10 # records per second

Expand All @@ -21,7 +21,7 @@

LEARNING_RATE = 0.003
STANDARD_DEVIATION = 0.1
TRAINING_EPOCHS = 1000
TRAINING_EPOCHS = 10
BATCH_SIZE = 50 # 100
DISPLAY_STEP = 20
RANDOM_STATE = 100
Expand All @@ -47,6 +47,12 @@ def find_second_beg(data_set, start_second):
return start_idx


def outputSpecialData(arr, val):
for i in range(len(arr)):
if arr[i] > val or arr[i] < -val:
print("" + i + arr[i])


# fetch data from csv file
# data format:
# [0]: time
Expand All @@ -62,7 +68,7 @@ def find_second_beg(data_set, start_second):
raw_linear_heave = np.array(raw_data[:, 2])
raw_real_heave = np.array(raw_data[:, 3])
raw_nonlinear_heave = np.subtract(raw_real_heave, raw_linear_heave)
print(raw_nonlinear_heave[0])
# outputSpecialData(raw_nonlinear_heave, 1)

print(raw_data[find_second_beg(raw_data, 101)])
print(raw_data[find_second_beg(raw_data, 120)])
Expand All @@ -76,6 +82,7 @@ def find_second_beg(data_set, start_second):
training_target[i] = [raw_nonlinear_heave[training_data_idx_start + i]]
training_input = np.array(training_input)
training_target = np.array(training_target)
# outputSpecialData(training_target, 1)
print(training_input.shape)
print(training_target.shape)

Expand All @@ -87,9 +94,11 @@ def find_second_beg(data_set, start_second):
testing_target[i] = [raw_nonlinear_heave[testing_data_idx_start + i]]
testing_input = np.array(testing_input)
testing_target = np.array(testing_target)
# outputSpecialData(testing_target, 1)
print(testing_input.shape)
print(testing_target.shape)


# NRMSE
def nrmse(real, predict):
up = tf.sqrt(tf.reduce_sum(tf.square(real - predict)))
Expand Down Expand Up @@ -218,6 +227,7 @@ def mlp(_x, _weights, _biases):
# Testing
test_acc = sess.run(pred, feed_dict={X: testing_input, y: testing_target, dropout_keep_prob: 1.})
# print("Test accuracy: %.6f" % test_acc)
outputSpecialData(testing_target, 1)
print(repr(np.column_stack((test_acc, testing_target))))
# for i in np.column_stack((test_acc, testing_target)):
# print(repr(i))
Expand Down

0 comments on commit 9de9c26

Please sign in to comment.