class_docstr: Create a PyTorch dataset of a tabularized time-series
class_docstr_tok: ["Create","a","PyTorch","dataset","of","a","tabularized","time-series"]
docstr: Filters samples from the dataset based on the forecast frequency.
  Parameters
  ----------
      prediction_frequency : int
          periodic interval in which forecasts should be made.
      Note
      ----
      E.g. if prediction_frequency=7, forecasts are only made on every 7th step (once in a week in case of daily
      resolution).
docstr_tok: ["Filters","samples","from","the","dataset","based","on","the","forecast","frequency",".","Parameters","--","--","--","--","--","prediction_frequency",":","int","periodic","interval","in","which","forecasts","should","be","made",".","Note","--","--","E.g",".","if","prediction_frequency=7",",","forecasts","are","only","made","on","every","7th","step","(","once","in","a","week","in","case","of","daily","resolution",")","."]
code: def filter_samples_after_init(
      self,
      prediction_frequency=None,
  ):
      """Filters samples from the dataset based on the forecast frequency.
      Parameters
      ----------
          prediction_frequency : int
              periodic interval in which forecasts should be made.
          Note
          ----
          E.g. if prediction_frequency=7, forecasts are only made on every 7th step (once in a week in case of daily
          resolution).
      """
      if prediction_frequency is None or prediction_frequency == 1:
          return
      # Only the first target timestamp is of interest for filtering
      timestamps = pd.to_datetime(
          [sample["timestamps"][0] for sample in self.samples]
      )
      masks = []
      for key, value in prediction_frequency.items():
          if key == "daily-hour":
              mask = (
                  timestamps.hour == value + 1
              )  # because prediction starts one step after origin
          elif key == "weekly-day":
              mask = timestamps.dayofweek == value + 1
          elif key == "monthly-day":
              mask = timestamps.day == value + 1
          elif key == "yearly-month":
              mask = timestamps.month == value + 1
          elif key == "hourly-minute":
              mask = timestamps.minute == value + 1
          else:
              raise ValueError(f"Invalid prediction frequency: {key}")
          masks.append(mask)
      mask = np.ones((len(timestamps),), dtype=bool)
      for m in masks:
          mask = mask & m
      self.samples = [
          self.samples[i] for i in range(len(self.samples)) if mask[i]
      ]
  
      # Exact timestamps are not needed anymore
      self.inputs.pop("timestamps")
      for sample in self.samples:
          sample.pop("timestamps")
      self.length = len(self.samples)
  
imports: import logging
  from collections import OrderedDict, defaultdict
  from datetime import datetime
  from typing import Optional
  import numpy
  import pandas
  import torch
  from torch.utils.data.dataset import Dataset
  from neuralprophet import configure, utils
  from neuralprophet.df_utils import get_max_num_lags
  from neuralprophet.hdays_utils import get_country_holidays
label_desc: Use image node_id 5 for calling the TimeDataset obj's underlying member method code with example usage: obj.filter_samples_after_init(prediction_frequency) without return types