code: def test_1_time_series_regression(self):
      np.random.seed(0)
      data = pd.read_csv("tests/data/arrivals.csv")
      data = data[data["Country"] == "US"]
      train_df, test_df = self.split_arrivals(data, grouped=False)
      target = "Traffic"
      order_by = "T"
      window = 5
      for horizon in (1, 2):
          jai = json_ai_from_problem(
              data,
              ProblemDefinition.from_dict(
                  {
                      "target": target,
                      "anomaly_detection": False,
                      "timeseries_settings": {
                          "use_previous_target": False,
                          "allow_incomplete_history": False,
                          "horizon": horizon,
                          "order_by": order_by,
                          "window": window,
                      },
                  }
              ),
          )
          jai.model["args"]["submodels"] = [
              jai.model["args"]["submodels"][0]
          ]
          code = code_from_json_ai(jai)
          pred = predictor_from_code(code)
  
          # add a few invalid datetime values to test cleaning procedures
          for idx in list(
              np.where(np.random.random((len(train_df),)) > 0.98)[0]
          ):
              train_df.at[idx, "T"] = pd.NaT
  
          pred.learn(train_df)
          preds = pred.predict(data.sample(frac=1)[0:10])
          self.assertTrue("original_index" in preds.columns)
          self.check_ts_prediction_df(preds, horizon, [order_by])
  
          # test incomplete history, should not be possible
          self.assertRaises(
              Exception, pred.predict, test_df[: window - 1]
          )
  
          # test inferring mode, check timestamps are further into the future than test dates
          test_df["__mdb_forecast_offset"] = 1
          test_df = test_df.sample(
              frac=1
          )  # shuffle to test internal ordering logic
          preds = pred.predict(test_df)
          self.check_ts_prediction_df(preds, horizon, [order_by])
  
          latest_timestamp = (
              pd.to_datetime(test_df[order_by], utc=True)
              .max()
              .timestamp()
          )
          for idx, row in preds.iterrows():
              row[f"order_{order_by}"] = (
                  [row[f"order_{order_by}"]]
                  if horizon == 1
                  else row[f"order_{order_by}"]
              )
              for timestamp in row[f"order_{order_by}"]:
                  assert timestamp > latest_timestamp
  
          # test null offset mode
          test_df["__mdb_forecast_offset"] = 0
          preds = pred.predict(test_df)
          self.check_ts_prediction_df(preds, horizon, [order_by])
          assert preds.shape[0] == 1
          if horizon == 1:
              last_dt = datetime.utcfromtimestamp(
                  preds[f"order_{order_by}"].values[0]
              )
          else:
              last_dt = datetime.utcfromtimestamp(
                  preds[f"order_{order_by}"].values[0][0]
              )
          formatted = str(last_dt.year) + "-" + str(last_dt.month)
          assert (
              formatted
              == test_df.sort_values(by=order_by).iloc[-1][order_by]
          )
  
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 4 for calling the TestTimeseries obj's underlying member method code with example usage: obj.test_1_time_series_regression() without return types