docstr: Even though the suggestion is to feed regularly sampled series into predictors, this test can still help us
  catch undesired behavior when the recommendation is not followed.
docstr_tok: ["Even","though","the","suggestion","is","to","feed","regularly","sampled","series","into","predictors",",","this","test","can","still","help","us","catch","undesired","behavior","when","the","recommendation","is","not","followed","."]
code: def test_7_irregular_series(self):
      """
      Even though the suggestion is to feed regularly sampled series into predictors, this test can still help us
      catch undesired behavior when the recommendation is not followed.
      """  # noqa
  
      # synth square wave
      tsteps = 100
      target = "Value"
      horizon = 20
      # added random noise for irregular sampling
      np.random.seed(0)
      t = np.linspace(
          0, 100, tsteps, endpoint=False
      ) + np.random.uniform(size=(tsteps,), low=-0.005, high=0.005)
      ts = [
          i + f
          for i, f in enumerate(
              signal.sawtooth(2 * np.pi * 5 * t, width=0.5)
          )
      ]
      df = pd.DataFrame(columns=["Time", target])
      df["Time"] = t
      df[target] = ts
      df[f"{target}_2x"] = [2 * elt for elt in ts]
  
      train = df[: int(len(df) * 0.8)]
      test = df[int(len(df) * 0.8) :]
  
      pdef = ProblemDefinition.from_dict(
          {
              "target": target,
              "time_aim": 200,
              "timeseries_settings": {
                  "order_by": "Time",
                  "window": 5,
                  "horizon": horizon,
                  "historical_columns": [f"{target}_2x"],
              },
          }
      )
  
      json_ai = json_ai_from_problem(df, problem_definition=pdef)
      code = code_from_json_ai(json_ai)
      predictor = predictor_from_code(code)
  
      train_and_check_time_aim(
          predictor, train
      )  # Test with a longer time aim
  
      test["__mdb_forecast_offset"] = 1
      predictor.predict(test)
  
imports: import random
  from datetime import datetime
  from datetime import timedelta
  import unittest
  import numpy
  import pandas
  from typing import List
  from scipy import signal
  from sklearn.metrics import r2_score
  from lightwood.api.types import ProblemDefinition
  from tests.utils.timing import train_and_check_time_aim
  from sktime.forecasting.base import ForecastingHorizon
  from sktime.forecasting.statsforecast import StatsForecastAutoARIMA
  from dataprep_ml.splitters import stratify
  from lightwood.api.high_level import json_ai_from_problem, code_from_json_ai, predictor_from_code, predictor_from_problem, predictor_from_json_ai
  from lightwood.mixer.sktime import SkTime
label_desc: Use image node_id 11 for calling the TestTimeseries obj's underlying member method code with example usage: obj.test_7_irregular_series() without return types