class_docstr: Class to test the AutoML flow
      
class_docstr_tok: ["Class","to","test","the","AutoML","flow"]
docstr: test to check functionality of the auto_ts function (multivariate with non seasonal SARIMAX)
docstr_tok: ["test","to","check","functionality","of","the","auto_ts","function","(","multivariate","with","non","seasonal","SARIMAX",")"]
code: def test_auto_ts_multivar_ns_sarimax(self):
      """
      test to check functionality of the auto_ts function (multivariate with non seasonal SARIMAX)
      """
  
      print("\n\n" + "*" * 50)
      print("Performing Unit Test: 'test_auto_ts_multivar_ns_SARIMAX'")
      print("*" * 50 + "\n\n")
  
      # import numpy as np  # type: ignore
      # from auto_ts import auto_timeseries as ATS
      # seasonal_period argument does not make a difference since seasonality has been set to False.
      automl_model = ATS(
          score_type="rmse",
          forecast_period=self.forecast_period,
          time_interval="Month",
          # non_seasonal_pdq=None, seasonality=False, seasonal_period=12,
          # non_seasonal_pdq=None, seasonality=False, seasonal_period=3,
          non_seasonal_pdq=None,
          seasonality=False,
          model_type="best",
          verbose=0,
      )
      automl_model.fit(
          traindata=self.train_multivar,
          ts_column=self.ts_column,
          target=self.target,
          cv=None  # ,
          # sep=self.sep
      )
      _ = automl_model.predict(
          testdata=self.test_multivar[[self.ts_column] + self.preds],
          forecast_period=self.forecast_period,
      )
  
      ml_dict = automl_model.get_ml_dict()
  
      leaderboard_gold = pd.DataFrame(
          {
              # 'name':['ML', 'Prophet', 'VAR', 'auto_SARIMAX', 'ARIMA'],
              "name": ["ML", "Prophet", "VAR", "auto_SARIMAX"],
              "rmse": [
                  self.rmse_gold_ml_multivar,
                  # self.rmse_gold_prophet_multivar_cv_fold2  # Unbiased
                  # FIXME: Biased as 2 validation periods even when CV is not mentioned
                  (
                      self.rmse_gold_prophet_multivar_cv_fold2
                      + self.rmse_gold_prophet_multivar_cv_fold1
                  )
                  / 2,
                  self.rmse_gold_var_multivar,
                  self.rmse_gold_auto_sarimax_multivar,
                  # self.rmse_gold_arima_uni_multivar
              ],
          }
      )
      assert_frame_equal(
          automl_model.get_leaderboard()
          .reset_index(drop=True)
          .round(6),
          leaderboard_gold,
      )
  
      self.assertEqual(
          # automl_model.get_best_model_name(), "Prophet",  # Unbiased
          automl_model.get_best_model_name(),
          "ML",  # Biased
          "Best model name does not match expected value.",
      )
  
      self.assertTrue(
          # isinstance(automl_model.get_best_model(), Prophet),  # Unbiased
          isinstance(
              automl_model.get_best_model(), BaseEstimator
          ),  # Biased
          "Best model does not match expected value.",
      )
  
      # TODO: Replace with Auto_ARIMA
      # self.assertTrue(
      #     isinstance(automl_model.get_model('SARIMAX'), SARIMAXResultsWrapper),
      #     "SARIMAX model does not match the expected type."
      # )
  
      ## Find a way to import these modules (BuildProphet & BuildSarimax) and then you can enable this.
      # self.assertTrue(
      #     isinstance(automl_model.get_best_model_build(), BuildProphet),
      #     "Best model build does not match expected value."
      # )
  
      # self.assertTrue(
      #     isinstance(automl_model.get_model_build('SARIMAX'), BuildSarimax),
      #     "SARIMAX model build does not match the expected type."
      # )
  
      # if automl_model.get_best_model_build() is not None:  # Unbiased
      if (
          automl_model.get_model_build("Prophet") is not None
      ):  # Biased (best model is no longer Prophet)
          # Simple forecast with forecast window = one used in training
          # Using default (best model)
          test_predictions = automl_model.predict(
              testdata=self.test_multivar[
                  [self.ts_column] + self.preds
              ],
              forecast_period=self.forecast_period,
              model="Prophet",  # Need to explicitly mention for Biased condirion since Prophet is no longer the best model
          )
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_multivar_external_test_cv,
          )
  
          # Simple forecast with forecast window != one used in training
          # Using default (best model)
          test_predictions = automl_model.predict(
              testdata=self.test_multivar[
                  [self.ts_column] + self.preds
              ],
              forecast_period=10,
              model="Prophet",  # Need to explicitly mention for Biased condirion since Prophet is no longer the best model
          )
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_multivar_external_test_10_cv,
          )
  
          # Simple forecast with forecast window = one used in training
          # Using named model
          test_predictions = automl_model.predict(
              testdata=self.test_multivar[
                  [self.ts_column] + self.preds
              ],
              forecast_period=self.forecast_period,
              model="Prophet",
          )
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_multivar_external_test_cv,
          )
  
          # Simple forecast with forecast window != one used in training
          # Using named model
          test_predictions = automl_model.predict(
              testdata=self.test_multivar[
                  [self.ts_column] + self.preds
              ],
              forecast_period=10,
              model="Prophet",
          )
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_multivar_external_test_10_cv,
          )
  
          # Complex forecasts (returns confidence intervals, etc.)
          _ = automl_model.predict(
              testdata=self.test_multivar[
                  [self.ts_column] + self.preds
              ],
              forecast_period=self.forecast_period,
              model="Prophet",
              simple=False,
          )
          # self.assertIsNone(
          #     np.testing.assert_array_equal(
          #         test_predictions.columns.values, self.expected_pred_col_names_prophet
          #     )
          # )
  
      # if automl_model.get_model_build('ARIMA') is not None:
      #     # Simple forecast with forecast window = one used in training
      #     # Using named model
      #     test_predictions = automl_model.predict(
      #         testdata=self.test_multivar[[self.ts_column] + self.preds], # Not needed for ARIMA
      #         forecast_period=self.forecast_period,
      #         model="ARIMA"
      #     )
      #     assert_series_equal(test_predictions['mean'].astype(np.double).round(6), self.forecast_gold_arima_uni_multivar_series)
  
      #     # Simple forecast with forecast window != one used in training
      #     # Using named model
      #     test_predictions = automl_model.predict(
      #         testdata=self.test_multivar[[self.ts_column] + self.preds], # Not needed for ARIMA
      #         forecast_period=10,
      #         model="ARIMA"
      #     )
      #     assert_series_equal(test_predictions['mean'].astype(np.double).round(6), self.forecast_gold_arima_uni_multivar_series_10)
  
      #     # Complex forecasts (returns confidence intervals, etc.)
      #     _ = automl_model.predict(
      #         testdata=self.test_multivar[[self.ts_column] + self.preds], # Not needed for ARIMA
      #         forecast_period=self.forecast_period,
      #         model="ARIMA",
      #         simple=False
      #     )
      #     # self.assertIsNone(
      #     #     np.testing.assert_array_equal(
      #     #         test_predictions.columns.values, self.expected_pred_col_names
      #     #     )
      #     # )
  
      # if automl_model.get_model_build('SARIMAX') is not None:
      #     # Simple forecast with forecast window = one used in training
      #     # Using named model
      #     test_predictions = automl_model.predict(
      #         forecast_period=self.forecast_period,
      #         testdata=self.test_multivar[[self.ts_column] + self.preds],
      #         model="SARIMAX"
      #     )
  
      #     assert_series_equal(test_predictions.round(6), self.forecast_gold_sarimax_multivar_external_test)
  
      #     # Simple forecast with forecast window != one used in training
      #     # Using named model
      #     test_predictions = automl_model.predict(
      #         forecast_period=6,
      #         testdata=self.test_multivar.iloc[0:6][[self.ts_column] + self.preds],
      #         model="SARIMAX"
      #     )
      #     assert_series_equal(test_predictions.round(6), self.forecast_gold_sarimax_multivar_external_test_10)
  
      #     # Complex forecasts (returns confidence intervals, etc.)
      #     test_predictions = automl_model.predict(
      #         forecast_period=self.forecast_period,
      #         testdata=self.test_multivar[[self.ts_column] + self.preds],
      #         model="SARIMAX",
      #         simple=False
      #     )
      #     self.assertIsNone(
      #         np.testing.assert_array_equal(
      #             test_predictions.columns.values, self.expected_pred_col_names
      #         )
      #     )
  
      #     # Checking missing exogenous variables
      #     with self.assertRaises(ValueError):
      #         _ = automl_model.predict(
      #             forecast_period=self.forecast_period,
      #             model="SARIMAX"
      #         )
  
      #     # Checking missing columns from exogenous variables
      #     with self.assertRaises(ValueError):
      #         test_multivar_temp = self.test_multivar.copy(deep=True)
      #         test_multivar_temp.rename(columns={'Marketing Expense': 'Incorrect Column'}, inplace=True)
      #         _ = automl_model.predict(
      #                 forecast_period=self.forecast_period,
      #                 testdata=test_multivar_temp,
      #                 model="SARIMAX"
      #             )
  
      #     test_predictions = automl_model.predict(
      #         forecast_period=10,
      #         testdata=self.test_multivar[[self.ts_column] + self.preds],
      #         model="SARIMAX"
      #     )
      #     assert_series_equal(test_predictions.round(6), self.forecast_gold_sarimax_multivar_external_test)
  
      if automl_model.get_model_build("ML") is not None:
          # Simple forecast with forecast window = one used in training
          # Using named model
          test_predictions = automl_model.predict(
              forecast_period=self.forecast_period,
              testdata=self.test_multivar[
                  [self.ts_column] + self.preds
              ],
              model="ML",
          )
          assert_series_equal(
              test_predictions["mean"].round(6),
              self.forecast_gold_ml_multivar_external_test,
          )
  
          # Simple forecast with forecast window != one used in training
          # Using named model
          test_predictions = automl_model.predict(
              forecast_period=6,
              testdata=self.test_multivar.iloc[0:6][
                  [self.ts_column] + self.preds
              ],
              model="ML",
          )
          assert_series_equal(
              test_predictions["mean"].round(6),
              self.forecast_gold_ml_multivar_external_test_10,
          )
  
          # Complex forecasts (returns confidence intervals, etc.)
          test_predictions = automl_model.predict(
              forecast_period=self.forecast_period,
              testdata=self.test_multivar[
                  [self.ts_column] + self.preds
              ],
              model="ML",
              simple=False,
          )
          self.assertIsNone(
              np.testing.assert_array_equal(
                  test_predictions.columns.values,
                  self.expected_pred_col_names,
              )
          )
  
      ##################################
      #### Checking Prophet Results ####
      ##################################
      self.assertIsNone(
          np.testing.assert_array_equal(
              np.round(
                  ml_dict.get("Prophet").get("forecast")[0]["yhat"], 6
              ),
              # self.forecast_gold_prophet_multivar_internal_val_cv_fold2  # Unbiased
              self.forecast_gold_prophet_multivar_internal_val_cv_fold1,  # Biased
          ),
          "(Multivar Test) Prophet Forecast does not match up with expected values.",
      )
  
      self.assertEqual(
          # round(ml_dict.get('Prophet').get('rmse')[0], 8), self.rmse_gold_prophet_multivar_cv_fold2,  # Unbiased
          round(ml_dict.get("Prophet").get("rmse")[0], 8),
          self.rmse_gold_prophet_multivar_cv_fold1,  # Biased
          "(Multivar Test) Prophet RMSE does not match up with expected values.",
      )
  
      # ################################
      # #### Checking ARIMA Results ####
      # ################################
  
      # # https://stackoverflow.com/questions/19387608/attributeerror-rint-when-using-numpy-round
      # self.assertIsNone(
      #     np.testing.assert_array_equal(
      #         np.round(ml_dict.get('ARIMA').get('forecast')['mean'].values.astype(np.double), 8),
      #         self.forecast_gold_arima_uni_multivar
      #     ),
      #     "(Multivar Test) ARIMA Forecast does not match up with expected values."
      # )
  
      # self.assertEqual(
      #     round(ml_dict.get('ARIMA').get('rmse'), 8), self.rmse_gold_arima_uni_multivar,
      #     "(Multivar Test) ARIMA RMSE does not match up with expected values.")
  
      # ##################################
      # #### Checking SARIMAX Results ####
      # ##################################
      # self.assertIsNone(
      #     np.testing.assert_array_equal(
      #         np.round(ml_dict.get('SARIMAX').get('forecast')[0]['mean'].values.astype(np.double), 6),
      #         self.forecast_gold_sarimax_multivar_internal_val
      #     ),
      #     "(Multivar Test) SARIMAX Forecast does not match up with expected values."
      # )
  
      # self.assertEqual(
      #     round(ml_dict.get('SARIMAX').get('rmse')[0], 6), self.rmse_gold_sarimax_multivar,
      #     "(Multivar Test) SARIMAX RMSE does not match up with expected values.")
  
      #############################
      #### Checking ML Results ####
      #############################
  
      self.assertListEqual(
          ml_dict.get("ML").get("forecast"),
          self.forecast_gold_ml_multivar_internal_val,
          "(Multivar Test) ML Forecast does not match up with expected values.",
      )
  
      self.assertEqual(
          round(ml_dict.get("ML").get("rmse")[0], 6),
          self.rmse_gold_ml_multivar,
          "(Multivar Test) ML RMSE does not match up with expected values.",
      )
  
imports: import sys
  import os
  import unittest
  import math
  import numpy
  import pandas
  from pandas.testing import assert_series_equal
  from pandas.testing import assert_frame_equal
  from prophet.forecaster import Prophet
  from statsmodels.tsa.statespace.sarimax import SARIMAXResultsWrapper
  from sklearn.base import BaseEstimator
  from auto_ts import auto_timeseries
label_desc: Use image node_id 2 for calling the TestAutoTS obj's underlying member method code with example usage: obj.test_auto_ts_multivar_ns_sarimax() without return types