code: def test_backtest_regression(self):
      np.random.seed(4)
  
      gaussian_series = gt(mean=2, length=50)
      sine_series = st(length=50)
      features = gaussian_series.stack(sine_series)
      features_multivariate = (
          (gaussian_series + sine_series)
          .stack(gaussian_series)
          .stack(sine_series)
      )
      target = sine_series
  
      features = features.with_columns_renamed(
          features.components, ["Value0", "Value1"]
      )
  
      features_multivariate = (
          features_multivariate.with_columns_renamed(
              features_multivariate.components,
              ["Value0", "Value1", "Value2"],
          )
      )
  
      # univariate feature test
      score = LinearRegressionModel(
          lags=None, lags_future_covariates=[0, -1]
      ).backtest(
          series=target,
          future_covariates=features,
          start=pd.Timestamp("20000201"),
          forecast_horizon=3,
          metric=r2_score,
          last_points_only=True,
      )
      assert score > 0.9
  
      # univariate feature test + train length
      score = LinearRegressionModel(
          lags=None, lags_future_covariates=[0, -1]
      ).backtest(
          series=target,
          future_covariates=features,
          start=pd.Timestamp("20000201"),
          train_length=20,
          forecast_horizon=3,
          metric=r2_score,
          last_points_only=True,
      )
      assert score > 0.9
  
      # Using an int or float value for start
      score = RandomForest(
          lags=12, lags_future_covariates=[0], random_state=0
      ).backtest(
          series=target,
          future_covariates=features,
          start=30,
          forecast_horizon=3,
          metric=r2_score,
      )
      assert score > 0.9
  
      score = RandomForest(
          lags=12, lags_future_covariates=[0], random_state=0
      ).backtest(
          series=target,
          future_covariates=features,
          start=0.5,
          forecast_horizon=3,
          metric=r2_score,
      )
      assert score > 0.9
  
      # Using a too small start value
      with pytest.raises(ValueError):
          RandomForest(lags=12).backtest(
              series=target, start=0, forecast_horizon=3
          )
  
      with pytest.raises(ValueError):
          RandomForest(lags=12).backtest(
              series=target, start=0.01, forecast_horizon=3
          )
  
      # Using RandomForest's start default value
      score = RandomForest(lags=12, random_state=0).backtest(
          series=target, forecast_horizon=3, start=0.5, metric=r2_score
      )
      assert score > 0.95
  
      # multivariate feature test
      score = RandomForest(
          lags=12, lags_future_covariates=[0, -1], random_state=0
      ).backtest(
          series=target,
          future_covariates=features_multivariate,
          start=pd.Timestamp("20000201"),
          forecast_horizon=3,
          metric=r2_score,
      )
      assert score > 0.94
  
      # multivariate feature test with train window 35
      score_35 = RandomForest(
          lags=12, lags_future_covariates=[0, -1], random_state=0
      ).backtest(
          series=target,
          train_length=35,
          future_covariates=features_multivariate,
          start=pd.Timestamp("20000201"),
          forecast_horizon=3,
          metric=r2_score,
      )
      logger.info(
          "Score for multivariate feature test with train window 35 is: ",
          score_35,
      )
      assert score_35 > 0.92
  
      # multivariate feature test with train window 45
      score_45 = RandomForest(
          lags=12, lags_future_covariates=[0, -1], random_state=0
      ).backtest(
          series=target,
          train_length=45,
          future_covariates=features_multivariate,
          start=pd.Timestamp("20000201"),
          forecast_horizon=3,
          metric=r2_score,
      )
      logger.info(
          "Score for multivariate feature test with train window 45 is: ",
          score_45,
      )
      assert score_45 > 0.94
      assert score_45 > score_35
  
      # multivariate with stride
      score = RandomForest(
          lags=12, lags_future_covariates=[0], random_state=0
      ).backtest(
          series=target,
          future_covariates=features_multivariate,
          start=pd.Timestamp("20000201"),
          forecast_horizon=3,
          metric=r2_score,
          last_points_only=True,
          stride=3,
      )
      assert score > 0.9
  
imports: import random
  from itertools import product
  import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.datasets import AirPassengersDataset, MonthlyMilkDataset
  from darts.logging import get_logger
  from darts.metrics import mape, r2_score
  from darts.models import ARIMA, FFT, ExponentialSmoothing, NaiveDrift, NaiveSeasonal, Theta
  from darts.tests.conftest import tfm_kwargs
  from darts.utils.timeseries_generation import gaussian_timeseries
  from darts.utils.timeseries_generation import linear_timeseries
  from darts.utils.timeseries_generation import random_walk_timeseries
  from darts.utils.timeseries_generation import sine_timeseries
label_desc: Use image node_id 3 for calling the TestBacktesting obj's underlying member method code with example usage: obj.test_backtest_regression() without return types