text: # ###########################################################################
  #
  #  CLOUDERA APPLIED MACHINE LEARNING PROTOTYPE (AMP)
  #  (C) Cloudera, Inc. 2020
  #  All rights reserved.
  #
  #  Applicable Open Source License: Apache 2.0
  #
  #  NOTE: Cloudera open source products are modular software products
  #  made up of hundreds of individual components, each of which was
  #  individually copyrighted.  Each Cloudera open source product is a
  #  collective work under U.S. Copyright Law. Your license to use the
  #  collective work is as provided in your written agreement with
  #  Cloudera.  Used apart from the collective work, this file is
  #  licensed for your use pursuant to the open source license
  #  identified above.
  #
  #  This code is provided to you pursuant a written agreement with
  #  (i) Cloudera, Inc. or (ii) a third-party authorized to distribute
  #  this code. If you do not have a written agreement with Cloudera nor
  #  with an authorized and properly licensed third party, you do not
  #  have any rights to access nor to use this code.
  #
  #  Absent a written agreement with Cloudera, Inc. (“Cloudera”) to the
  #  contrary, A) CLOUDERA PROVIDES THIS CODE TO YOU WITHOUT WARRANTIES OF ANY
  #  KIND; (B) CLOUDERA DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED
  #  WARRANTIES WITH RESPECT TO THIS CODE, INCLUDING BUT NOT LIMITED TO
  #  IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND
  #  FITNESS FOR A PARTICULAR PURPOSE; (C) CLOUDERA IS NOT LIABLE TO YOU,
  #  AND WILL NOT DEFEND, INDEMNIFY, NOR HOLD YOU HARMLESS FOR ANY CLAIMS
  #  ARISING FROM OR RELATED TO THE CODE; AND (D)WITH RESPECT TO YOUR EXERCISE
  #  OF ANY RIGHTS GRANTED TO YOU FOR THE CODE, CLOUDERA IS NOT LIABLE FOR ANY
  #  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
  #  CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, DAMAGES
  #  RELATED TO LOST REVENUE, LOST PROFITS, LOSS OF INCOME, LOSS OF
  #  BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF
  #  DATA.
  #
  # ###########################################################################
  
  import os
  
  import numpy as np
  
  from sts.data.loader import load_california_electricity_demand
  from sts.models.prophet import (
      add_season_weekday_indicators,
      seasonal_daily_prophet_model
  )
  
  
  # Load the training data (through 2018)
  
  df = load_california_electricity_demand(train_only=True)
  
  
  # ## Prophet (with more complicated seasonality)
  # FB Prophet model, splitting intra-day seasonalities into four subgroups:
  # - summer weekday
  # - summer weekend
  # - winter weekday
  # - winter weekend
  
  model = seasonal_daily_prophet_model(df)
  
  future = model.make_future_dataframe(periods=8760, freq='H')
  seasonal_future = add_season_weekday_indicators(future)
  
  forecast = model.predict(seasonal_future)
  
  
  # ## Write
  # Write the forecast values to csv
  DIR = 'data/forecasts/'
  
  if not os.path.exists(DIR):
      os.makedirs(DIR)
  
  forecast[['ds', 'yhat']].to_csv(DIR + 'prophet_complex.csv', index=False)
  