docstr: Tests that `RandomForest` regression model reproduces same behaviour as
  `examples/15-static-covariates.ipynb` notebook; see this notebook for
  futher details. Notebook is also hosted online at:
  https://unit8co.github.io/darts/examples/15-static-covariates.html
code: def test_static_cov_accuracy(self):
      """
      Tests that `RandomForest` regression model reproduces same behaviour as
      `examples/15-static-covariates.ipynb` notebook; see this notebook for
      futher details. Notebook is also hosted online at:
      https://unit8co.github.io/darts/examples/15-static-covariates.html
      """
  
      # given
      period = 20
      sine_series = tg.sine_timeseries(
          length=4 * period,
          value_frequency=1 / period,
          column_name="smooth",
          freq="h",
      )
  
      sine_vals = sine_series.values()
      linear_vals = np.expand_dims(np.linspace(1, -1, num=19), -1)
  
      sine_vals[21:40] = linear_vals
      sine_vals[61:80] = linear_vals
      irregular_series = TimeSeries.from_times_and_values(
          values=sine_vals,
          times=sine_series.time_index,
          columns=["irregular"],
      )
  
      # no static covs
      train_series_no_cov = [sine_series, irregular_series]
  
      # categorical static covs
      sine_series_st_cat = sine_series.with_static_covariates(
          pd.DataFrame(data={"curve_type": [0]})
      )
      irregular_series_st_cat = irregular_series.with_static_covariates(
          pd.DataFrame(data={"curve_type": [1]})
      )
      train_series_static_cov = [
          sine_series_st_cat,
          irregular_series_st_cat,
      ]
  
      # when
      fitting_series = [series[:60] for series in train_series_no_cov]
      model_no_static_cov = RandomForest(
          lags=period // 2, bootstrap=False
      )
      model_no_static_cov.fit(fitting_series)
      pred_no_static_cov = model_no_static_cov.predict(
          n=period, series=fitting_series
      )
  
      fitting_series = [
          series[:60] for series in train_series_static_cov
      ]
      model_static_cov = RandomForest(lags=period // 2, bootstrap=False)
      model_static_cov.fit(fitting_series)
      pred_static_cov = model_static_cov.predict(
          n=period, series=fitting_series
      )
      # then
      for series, ps_no_st, ps_st_cat in zip(
          train_series_static_cov, pred_no_static_cov, pred_static_cov
      ):
          rmses = [rmse(series, ps) for ps in [ps_no_st, ps_st_cat]]
          assert rmses[1] < rmses[0]
  
      # given series of different sizes in input
      train_series_no_cov = [sine_series[period:], irregular_series]
      train_series_static_cov = [
          sine_series_st_cat[period:],
          irregular_series_st_cat,
      ]
  
      fitting_series = [
          train_series_no_cov[0][: (60 - period)],
          train_series_no_cov[1][:60],
      ]
      model_no_static_cov = RandomForest(
          lags=period // 2, bootstrap=False
      )
      model_no_static_cov.fit(fitting_series)
      pred_no_static_cov = model_no_static_cov.predict(
          n=period, series=fitting_series
      )
      # multiple series with different components names ("smooth" and "irregular"),
      # will take first target name
      expected_features_in = [
          f"smooth_target_lag{str(-i)}"
          for i in range(period // 2, 0, -1)
      ]
      assert (
          model_no_static_cov.lagged_feature_names
          == expected_features_in
      )
      assert len(model_no_static_cov.model.feature_importances_) == len(
          expected_features_in
      )
  
      fitting_series = [
          train_series_static_cov[0][: (60 - period)],
          train_series_static_cov[1][:60],
      ]
      model_static_cov = RandomForest(lags=period // 2, bootstrap=False)
      model_static_cov.fit(fitting_series)
  
      # multiple univariates series with different names with same static cov, will take name of first series
      expected_features_in = [
          f"smooth_target_lag{str(-i)}"
          for i in range(period // 2, 0, -1)
      ] + ["curve_type_statcov_target_smooth"]
  
      assert (
          model_static_cov.lagged_feature_names == expected_features_in
      )
      assert len(model_static_cov.model.feature_importances_) == len(
          expected_features_in
      )
  
      pred_static_cov = model_static_cov.predict(
          n=period, series=fitting_series
      )
  
      # then
      for series, ps_no_st, ps_st_cat in zip(
          train_series_static_cov, pred_no_static_cov, pred_static_cov
      ):
          rmses = [rmse(series, ps) for ps in [ps_no_st, ps_st_cat]]
          assert rmses[1] < rmses[0]
  
imports: import copy
  import functools
  import itertools
  import math
  from unittest.mock import patch
  import numpy
  import pandas
  import pytest
  from sklearn.ensemble import HistGradientBoostingRegressor, RandomForestRegressor
  from sklearn.linear_model import LinearRegression
  import darts
  from darts import TimeSeries
  from darts.dataprocessing.encoders import FutureCyclicEncoder, PastDatetimeAttributeEncoder
  from darts.logging import get_logger
  from darts.metrics import mae, rmse
  from darts.models import CatBoostModel, LightGBMModel, LinearRegressionModel, NotImportedModule, RandomForest, RegressionModel, XGBModel
  from darts.utils import timeseries_generation
  from darts.utils.multioutput import MultiOutputRegressor
label_desc: Use image node_id 6 for calling the TestRegressionModels obj's underlying member method code with example usage: obj.test_static_cov_accuracy() without return types