docstr: Test which includes adding custom seasonalities and future covariates. The tests compare the output of
  univariate and stochastic forecasting with the validation timeseries and Prophet's base model output.
  
  The underlying curve to forecast is a sine timeseries multiplied with another sine timeseries.
  The curve shape repeats every 2*period timesteps (i.e. for period=24 hours -> seasonal_periods=48).
  We take the second sine wave as a covariate for the model.
  With the added custom seasonality and covariate, the model should have a very accurate forecast.
docstr_tok: ["Test","which","includes","adding","custom","seasonalities","and","future","covariates",".","The","tests","compare","the","output","of","univariate","and","stochastic","forecasting","with","the","validation","timeseries","and","Prophet","'s","base","model","output",".","The","underlying","curve","to","forecast","is","a","sine","timeseries","multiplied","with","another","sine","timeseries",".","The","curve","shape","repeats","every","2","*","period","timesteps","(","i.e",".","for","period=24","hours","-",">","seasonal_periods=48",")",".","We","take","the","second","sine","wave","as","a","covariate","for","the","model",".","With","the","added","custom","seasonality","and","covariate",",","the","model","should","have","a","very","accurate","forecast","."]
code: def helper_test_prophet_model(
      self, period, freq, compare_all_models=False
  ):
      """Test which includes adding custom seasonalities and future covariates. The tests compare the output of
      univariate and stochastic forecasting with the validation timeseries and Prophet's base model output.
  
      The underlying curve to forecast is a sine timeseries multiplied with another sine timeseries.
      The curve shape repeats every 2*period timesteps (i.e. for period=24 hours -> seasonal_periods=48).
      We take the second sine wave as a covariate for the model.
      With the added custom seasonality and covariate, the model should have a very accurate forecast.
      """
      repetitions = 8
      ts_sine1 = tg.sine_timeseries(
          value_frequency=1 / period,
          length=period * repetitions,
          freq=freq,
      )
      ts_sine2 = tg.sine_timeseries(
          value_frequency=1 / (period * 2),
          length=period * repetitions,
          freq=freq,
      )
      ts_sine = ts_sine1 * ts_sine2
      covariate = ts_sine2
  
      split = int(-period * repetitions / 2)
      train, val = ts_sine[:split], ts_sine[split:]
      train_cov, val_cov = covariate[:split], covariate[split:]
  
      supress_auto_seasonality = {
          "daily_seasonality": False,
          "weekly_seasonality": False,
          "yearly_seasonality": False,
      }
      custom_seasonality = {
          "name": "custom",
          "seasonal_periods": int(2 * period),
          "fourier_order": 4,
      }
      model = Prophet(
          add_seasonalities=custom_seasonality,
          seasonality_mode="additive",
          **supress_auto_seasonality,
      )
  
      model.fit(train, future_covariates=train_cov)
  
      # univariate, stochastic and Prophet's base model forecast
      pred_darts = model.predict(
          n=len(val), num_samples=1, future_covariates=val_cov
      )
      compare_preds = [pred_darts]
  
      if compare_all_models:
          pred_darts_stochastic = model.predict(
              n=len(val), num_samples=200, future_covariates=val_cov
          )
          pred_raw_df = model.predict_raw(
              n=len(val), future_covariates=val_cov
          )
          pred_raw = TimeSeries.from_dataframe(
              pred_raw_df[["ds", "yhat"]], time_col="ds"
          )
          compare_preds += [
              pred_darts_stochastic.quantile_timeseries(0.5),
              pred_raw,
          ]
  
      # all predictions should fit the underlying curve very well
      for pred in compare_preds:
          for val_i, pred_i in zip(
              val.univariate_values(), pred.univariate_values()
          ):
              assert abs(val_i - pred_i) < 0.1
  
file_path: darts/darts/tests/models/forecasting/test_prophet.py
imports: from unittest.mock import Mock
  import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.logging import get_logger
  from darts.models import NotImportedModule, Prophet
  from darts.utils import timeseries_generation
label_desc: Use image node_id 8 for calling the TestProphet obj's underlying member method code with example usage: obj.helper_test_prophet_model(period, freq, compare_all_models) without return types