Timeseries Tutorial

Hello im new here. I was doing tensorflows timeseries tutorial, which can be found here:חיזוי סדרות זמן  |  TensorFlow Core. I was wondering why in the plot method we use example dataset for prediction when it is made by train data?

does this code use train data if example data is not set?
@property
def train(self):
return self.make_dataset(self.train_df)

@property
def val(self):
return self.make_dataset(self.val_df)

@property
def test(self):
return self.make_dataset(self.test_df)

@property
def example(self):
“”“Get and cache an example batch of inputs, labels for plotting.”“”
result = getattr(self, ‘_example’, None)
if result is None:
# No example batch was found, so get one from the .train dataset
result = next(iter(self.train))
# And cache it for next time
self._example = result
return result

WindowGenerator.train = train
WindowGenerator.val = val
WindowGenerator.test = test
WindowGenerator.example = example

in the plot method the inputs are taken from example dataset:def plot(self, model=None, plot_col=‘T (degC)’, max_subplots=3):
inputs, labels = self.example
plt.figure(figsize=(12, 8))
plot_col_index = self.column_indices[plot_col]
max_n = min(max_subplots, len(inputs))
for n in range(max_n):
plt.subplot(max_n, 1, n+1)
plt.ylabel(f’{plot_col} [normed]‘)
plt.plot(self.input_indices, inputs[n, :, plot_col_index],
label=‘Inputs’, marker=’.', zorder=-10)

if self.label_columns:
  label_col_index = self.label_columns_indices.get(plot_col, None)
else:
  label_col_index = plot_col_index

if label_col_index is None:
  continue

plt.scatter(self.label_indices, labels[n, :, label_col_index],
            edgecolors='k', label='Labels', c='#2ca02c', s=64)
if model is not None:
  predictions = model(inputs)
  plt.scatter(self.label_indices, predictions[n, :, label_col_index],
              marker='X', edgecolors='k', label='Predictions',
              c='#ff7f0e', s=64)

if n == 0:
  plt.legend()

plt.xlabel(‘Time [h]’)

WindowGenerator.plot = plot

Hi @Johan, The example dataset is used to show that the split_window function also handles the label_columns so it can be used for both the single output and multi-output examples. Thank You.