Skip to content

Instantly share code, notes, and snippets.

@arjay55
Created August 22, 2019 08:25
Show Gist options
  • Save arjay55/f313c770a7c6c2b4f1e6b520ec88dd6c to your computer and use it in GitHub Desktop.
Save arjay55/f313c770a7c6c2b4f1e6b520ec88dd6c to your computer and use it in GitHub Desktop.
Creation of train/test datasets.
def form_dataset(normalized_data, est_period, **kwargs):
percent_validation = kwargs.pop('percent_validation', 0.8)
rel_norm=normalized_data
# end_index=(int(((rel_norm.shape[0]-est_period)*0.9)//batch_size))*batch_size-2
# batch size to be changed to 1
# end_index_test=(
# (rel_norm.shape[0] - 1 - end_index) // batch_size) * batch_size + end_index -1
end_index = int((rel_norm.shape[0]-est_period-1)*percent_validation)+19
tser_rel_train = tf.keras.preprocessing.sequence.TimeseriesGenerator(rel_norm, rel_norm,
length=est_period,
sampling_rate=1,
end_index=end_index)
tser_rel_test = tf.keras.preprocessing.sequence.TimeseriesGenerator(rel_norm, rel_norm,
length=est_period,
sampling_rate=1,
batch_size=1,
start_index=end_index-19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment