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 (univariate models with non seasonal SARIMAX)
docstr_tok: ["test","to","check","functionality","of","the","auto_ts","function","(","univariate","models","with","non","seasonal","SARIMAX",")"]
code: def test_auto_ts_univar_ns_sarimax(self):
      """
      test to check functionality of the auto_ts function (univariate models with non seasonal SARIMAX)
      """
  
      print("\n\n" + "*" * 50)
      print("Performing Unit Test: 'test_auto_ts_univar_ns_SARIMAX'")
      print("*" * 50 + "\n\n")
  
      # import numpy as np  # type: ignore
      # from auto_ts import auto_timeseries as ATS
      automl_model = ATS(
          score_type="rmse",
          forecast_period=self.forecast_period,
          time_interval="Month",
          non_seasonal_pdq=None,
          seasonality=False,
          seasonal_period=12,
          model_type="best",
          verbose=0,
      )
      automl_model.fit(
          traindata=self.train_univar,
          ts_column=self.ts_column,
          target=self.target,
          cv=None  # ,
          # sep=self.sep
      )
      _ = automl_model.predict(forecast_period=self.forecast_period)
  
      ml_dict = automl_model.get_ml_dict()
  
      leaderboard_gold = pd.DataFrame(
          {
              # 'name': ['Prophet', 'auto_SARIMAX', 'ARIMA', 'VAR', 'ML'],
              "name": ["Prophet", "auto_SARIMAX", "VAR", "ML"],
              "rmse": [
                  self.rmse_gold_prophet_univar_cv_fold2,
                  self.rmse_gold_auto_sarimax_univar,
                  # self.rmse_gold_arima_uni_multivar,
                  math.inf,
                  math.inf,
              ],
          }
      )
      assert_frame_equal(
          automl_model.get_leaderboard()
          .reset_index(drop=True)
          .round(6),
          leaderboard_gold,
      )
  
      self.assertEqual(
          automl_model.get_best_model_name(),
          "Prophet",
          "Best model name does not match expected value.",
      )
      self.assertTrue(
          isinstance(automl_model.get_best_model(), Prophet),
          "Best model does not match expected value.",
      )
  
      ## 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:
          # Simple forecast with forecast window = one used in training
          # Using default (best model)
          test_predictions = automl_model.predict(
              forecast_period=self.forecast_period
          )
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_univar_external_test_cv,
          )
  
          # Simple forecast with forecast window != one used in training
          # Using default (best model)
          test_predictions = automl_model.predict(forecast_period=10)
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_univar_external_test_10_cv,
          )
  
          # Simple forecast with forecast window = one used in training
          # Using named model
          test_predictions = automl_model.predict(
              forecast_period=self.forecast_period, model="Prophet"
          )
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_univar_external_test_cv,
          )
  
          # Simple forecast with forecast window != one used in training
          # Using named model
          test_predictions = automl_model.predict(
              forecast_period=10, model="Prophet"
          )
          assert_series_equal(
              test_predictions["yhat"].round(6),
              self.forecast_gold_prophet_univar_external_test_10_cv,
          )
  
          # Complex forecasts (returns confidence intervals, etc.)
          _ = automl_model.predict(
              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(
      #         forecast_period=self.forecast_period,
      #         model="ARIMA"
      #     )
      #     assert_series_equal(test_predictions['mean'].astype(np.float).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(
      #         forecast_period=10,
      #         model="ARIMA"
      #     )
      #     assert_series_equal(test_predictions['mean'].astype(np.float).round(6), self.forecast_gold_arima_uni_multivar_series_10)
  
      #     # Complex forecasts (returns confidence intervals, etc.)
      #     _ = automl_model.predict(
      #         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
      #     #     )
      #     # )
  
      # # TODO: Change to auto_SARIMAX later
      # 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,
      #         model="SARIMAX"
      #     )
      #     assert_series_equal(test_predictions.round(6), self.forecast_gold_sarimax_univar_external_test)
  
      #     # Simple forecast with forecast window != one used in training
      #     # Using named model
      #     test_predictions = automl_model.predict(
      #         forecast_period=10,
      #         model="SARIMAX"
      #     )
      #     assert_series_equal(test_predictions.round(6), self.forecast_gold_sarimax_univar_external_test_10)
  
      #     # Complex forecasts (returns confidence intervals, etc.)
      #     test_predictions = automl_model.predict(
      #         forecast_period=self.forecast_period,
      #         model="SARIMAX",
      #         simple=False
      #     )
      #     self.assertIsNone(
      #         np.testing.assert_array_equal(
      #             test_predictions.columns.values, self.expected_pred_col_names
      #         )
      #     )
  
      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, model="ML"
          )
          assert_series_equal(
              test_predictions["mean"].round(6),
              self.forecast_gold_ml_univar_series,
          )
  
          # Simple forecast with forecast window != one used in training
          # Using named model
          test_predictions = automl_model.predict(
              forecast_period=6, model="ML"
          )
          assert_series_equal(
              test_predictions["mean"].round(6),
              self.forecast_gold_ml_univar_series_10,
          )
  
          # Complex forecasts (returns confidence intervals, etc.)
          test_predictions = automl_model.predict(
              forecast_period=self.forecast_period,
              model="ML",
              simple=False,
          )
          self.assertIsNone(
              np.testing.assert_array_equal(
                  test_predictions.columns.values,
                  self.expected_pred_col_names,
              )
          )
  
      #########################################
      #### Checking getter for Model Build ####
      #########################################
      self.assertIsNone(
          automl_model.get_model_build("ML"),
          "Expected Univar ML model to be None but did not get None.",
      )
  
      ##################################
      #### 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_univar_internal_val_cv_fold2  # Unbiased
              self.forecast_gold_prophet_univar_internal_val_cv_fold1,  # Biased
          ),
          "(Univar 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_univar_cv_fold2,  # Unbiased
          round(ml_dict.get("Prophet").get("rmse")[0], 8),
          self.rmse_gold_prophet_univar_cv_fold1,  # Biased
          "(Univar 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
      #     ),
      #     "(Univar 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,
      #     "(Univar 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), 8),
      #         self.forecast_gold_sarimax_univar_internal_val
      #     ),
      #     "(Univar Test) SARIMAX Forecast does not match up with expected values."
      # )
  
      # self.assertEqual(
      #     round(ml_dict.get('SARIMAX').get('rmse')[0],8), self.rmse_gold_sarimax_univar,
      #     "(Univar Test) SARIMAX RMSE does not match up with expected values.")
  
      #############################
      #### Checking ML Results ####
      #############################
  
      self.assertEqual(
          ml_dict.get("ML").get("forecast"),
          self.forecast_gold_ml_univar,
          "(Univar Test) ML Forecast does not match up with expected values.",
      )
  
      self.assertEqual(
          round(ml_dict.get("ML").get("rmse"), 8),
          self.rmse_gold_ml_univar,
          "(Univar 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 3 for calling the TestAutoTS obj's underlying member method code with example usage: obj.test_auto_ts_univar_ns_sarimax() without return types