Esempio n. 1
0
old_columns = df.columns
df.dropna(inplace=True, axis=1)
print('dropped_columns: \n\t{}'.format(
    list(set(old_columns) - set(df.columns))))

# Convert a Pandas dataframe to the x,y inputs that TensorFlow needs
print('===== to_xy =====')
x, y = common.to_xy(df, 'marker')
print('x.shape: {}, {}'.format(x.shape, type(x)))
print('y.shape: {}, {}'.format(y.shape, type(y)))

# Create time sequences of x, y with time_step
print('===== create sequences =====')
print('step_size = {}'.format(options.step_size))
x_seq = common.to_sequences(x, step_size=options.step_size)
y_seq = y[options.step_size - 1:]
print('x_seq.shape: {}, {}'.format(x_seq.shape, type(x_seq)))
print('y_seq.shape: {}, {}'.format(y_seq.shape, type(y_seq)))

# Create a test/train split.  20% test
print('validation_split = {}%'.format(VALIDATION_SPLIT * 100))
x_train, x_test, y_train, y_test = train_test_split(x_seq,
                                                    y_seq,
                                                    test_size=VALIDATION_SPLIT,
                                                    random_state=42)

# SimpleRNN stuff
print('===== setup SimpleRNN =====')
callback_monitor = 'val_acc'
earlyStopping = EarlyStopping(monitor=callback_monitor,
Esempio n. 2
0
old_columns = df.columns
df.dropna(inplace=True, axis=1)
print('dropped_columns: \n\t{}'.format(
    list(set(old_columns) - set(df.columns))))

# Convert a Pandas dataframe to the x,y inputs that TensorFlow needs
print('===== to_xy =====')
x, y = common.to_xy(df, 'marker')
print('x.shape: {}, {}'.format(x.shape, type(x)))
print('y.shape: {}, {}'.format(y.shape, type(y)))

# Create time sequences of x, y with time_step
print('===== create sequences =====')
print('step_size = {}'.format(options['step_size']))
x_seq, y_seq = common.to_sequences(x, y, step_size=options['step_size'])

# Create a test/train split.  20% test
print('validation_split = {}%'.format(VALIDATION_SPLIT * 100))
x_train, x_test, y_train, y_test = train_test_split(x_seq,
                                                    y_seq,
                                                    test_size=VALIDATION_SPLIT,
                                                    random_state=42)

# GRU stuff
print('===== setup GRU =====')
monitor = EarlyStopping(monitor='val_loss',
                        min_delta=1e-3,
                        patience=5,
                        verbose=1,
                        mode='auto')