<jupyter_start><jupyter_text>Multivariate<jupyter_code>import numpy as np
import tensorflow as tf
from numpy import array
from numpy import hstack
from tensorflow.keras.preprocessing.sequence import TimeseriesGenerator
# multivariate one step problem

# define dataset
in_seq1 = array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
in_seq2 = array([15, 25, 35, 45, 55, 65, 75, 85, 95, 105])

# reshape series
in_seq1 = in_seq1.reshape((len(in_seq1), 1))
in_seq2 = in_seq2.reshape((len(in_seq2), 1))

#print(in_seq1)
#print(in_seq2)

# horizontally stack columns
dataset = hstack((in_seq1, in_seq2))
print(dataset)


# define generator
time_steps = 1   # bc of two variants the each step has 2*time_steps values
generator = TimeseriesGenerator(dataset, dataset, length = time_steps, batch_size = 1)
# number of samples
print('\nSamples: %d\n' % len(generator))
# print each sample
for i in range(len(generator)):
	x, y = generator[i]
	print('%s => %s' % (x, y))
# define generator
time_steps = 2   # bc of two variants the each step has 2*time_steps values
generator = TimeseriesGenerator(dataset, dataset, length = time_steps, batch_size = 1)
# number of samples
print('\nSamples: %d\n' % len(generator))
# print each sample
for i in range(len(generator)):
	x, y = generator[i]
	print('%s => %s' % (x, y))<jupyter_output>Samples: 8

[[[10 15]
  [20 25]]] => [[30 35]]
[[[20 25]
  [30 35]]] => [[40 45]]
[[[30 35]
  [40 45]]] => [[50 55]]
[[[40 45]
  [50 55]]] => [[60 65]]
[[[50 55]
  [60 65]]] => [[70 75]]
[[[60 65]
  [70 75]]] => [[80 85]]
[[[70 75]
  [80 85]]] => [[90 95]]
[[[80 85]
  [90 95]]] => [[100 105]]
{'fraction_non_alphanumeric': 0.17391304347826086, 'fraction_numerical': 0.1, 'mean_word_length': 4.815884476534296, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '340656', 'license': 'MIT', 'n_tokens_mistral': 744, 'n_tokens_neox': 608, 'n_words': 196, 'path': '4. Time Series/AZ/Data Sampling/01_sample_window-02.ipynb', 'repo_name': 'AmirRazaMBA/TensorFlow-Certification', 'size': '1610'}