code: def test_backtester_ktr_and_missing_val(
      make_daily_data, missing_flag
  ):
      train_df, test_df, _ = make_daily_data
      df = pd.concat([train_df, test_df], axis=0, ignore_index=True)
      if missing_flag:
          # create a missing value in testing
          df.loc[df.shape[0] - 3, "response"] = np.nan
          # create a missing value in training
          df.loc[10, "response"] = np.nan
  
      ktr = KTRLite(
          date_col="date",
          response_col="response",
          seasonality=[365.25],
          verbose=False,
      )
  
      bt = BackTester(
          model=ktr,
          df=df,
          n_splits=3,
          incremental_len=100,
          forecast_len=20,
      )
  
      bt.fit_predict()
      predicted_df = bt.get_predicted_df()
      assert set(predicted_df["split_key"].tolist()) == {0, 1, 2}
  
      bt_score_df = bt.score(include_training_metrics=False)
      num_testing_metrics = 6
      expected_shape = (num_testing_metrics, 3)
      assert bt_score_df.shape == expected_shape
  
      testing_metrics_df = bt_score_df[
          ~bt_score_df["is_training_metric"]
      ]
      # rmsse is the only one not working for null values; otherwise, they should have valid values
      if missing_flag:
          metric_vals = testing_metrics_df.loc[
              testing_metrics_df["metric_name"] != "rmsse",
              "metric_values",
          ].values
          assert np.all(~np.isnan(metric_vals))
          missing_metric_val = testing_metrics_df.loc[
              testing_metrics_df["metric_name"] == "rmsse",
              "metric_values",
          ].values
          assert np.all(np.isnan(missing_metric_val))
      else:
          metric_vals = testing_metrics_df["metric_values"].values
          assert np.all(~np.isnan(metric_vals))
  
file_path: orbit/tests/orbit/diagnostics/test_backtest.py
imports: import pytest
  import pandas
  import numpy
  from orbit.diagnostics.backtest import TimeSeriesSplitter, BackTester
  from orbit.diagnostics.metrics import smape, wmape, mae
  from orbit.models import LGT, KTRLite
label_desc: Use image node_id 4 for calling a global function with example usage: test_backtester_ktr_and_missing_val(make_daily_data, missing_flag) without return types