class_docstr: Configuration class for an MSES forecasting model.
class_docstr_tok: ["Configuration","class","for","an","MSES","forecasting","model","."]
docstr: Letting ``w`` be the recency weight, ``B`` the maximum backstep, ``x_t`` the last seen data point,
  and ``l_s,t`` the series of losses for scale ``s``. 
  
  .. math:: 
      \begin{align*}
      \hat{x}_{t+h} & = \sum_{b=0}^B p_{b} \cdot (x_{t-b} + v_{b+h,t} + a_{b+h,t}) \\
      \space \\
      \text{where} \space\space & v_{b+h,t} = \text{EMA}_w(\Delta_{b+h} x_t)   \\
      & a_{b+h,t} = \text{EMA}_w(\Delta_{b+h}^2 x_t) \\
      \text{and} \space\space & p_b = \sigma(z)_b \space\space \\
      \text{if} & \space\space  z_b = (b+h)^\phi \cdot \text{EMA}_w(l_{b+h,t}) \cdot \text{RWSE}_w(l_{b+h,t})\\
      \end{align*}
  
  :param max_backstep: Max backstep to use in forecasting. If we train with x(0),...,x(t),
      Then, the b-th model MSES uses will forecast x(t+h) by anchoring at x(t-b) and 
      predicting xhat(t+h) = x(t-b) + delta_hat(b+h).
  :param recency_weight: The recency weight parameter to use when estimating delta_hat.
  :param accel_weight: The weight to scale the acceleration by when computing delta_hat.
      Specifically, delta_hat(b+h) = velocity(b+h) + accel_weight * acceleration(b+h).
  :param optimize_acc: If True, the acceleration correction will only be used at scales
      ranging from 1,...(max_backstep+max_forecast_steps)/2.
  :param eta: The parameter used to control the rate at which recency_weight gets
      tuned when online updates are made to the model and losses can be computed.
  :param rho: The parameter that determines what fraction of the overall error is due to
      velcity error, while the rest is due to the complement. The error at any scale 
      will be determined as ``rho * velocity_error + (1-rho) * loss_error``.
  :param phi: The parameter used to exponentially inflate the magnitude of loss error at
      different scales. Loss error for scale ``s`` will be increased by a factor of ``phi ** s``.  
  :param inflation: The inflation exponent to use when computing the distribution
      p(b|h) over the models when forecasting at horizon h according to standard
      errors of the estimated velocities over the models; inflation=1 is equivalent
      to using the softmax function.
code: def __init__(
      self,
      max_forecast_steps: int,
      max_backstep: int = None,
      recency_weight: float = 0.5,
      accel_weight: float = 1.0,
      optimize_acc: bool = True,
      eta: float = 0.0,
      rho: float = 0.0,
      phi: float = 2.0,
      inflation: float = 1.0,
      **kwargs,
  ):
      r"""
          Letting ``w`` be the recency weight, ``B`` the maximum backstep, ``x_t`` the last seen data point,
          and ``l_s,t`` the series of losses for scale ``s``. 
  
          .. math:: 
              \begin{align*}
              \hat{x}_{t+h} & = \sum_{b=0}^B p_{b} \cdot (x_{t-b} + v_{b+h,t} + a_{b+h,t}) \\
              \space \\
              \text{where} \space\space & v_{b+h,t} = \text{EMA}_w(\Delta_{b+h} x_t)   \\
              & a_{b+h,t} = \text{EMA}_w(\Delta_{b+h}^2 x_t) \\
              \text{and} \space\space & p_b = \sigma(z)_b \space\space \\
              \text{if} & \space\space  z_b = (b+h)^\phi \cdot \text{EMA}_w(l_{b+h,t}) \cdot \text{RWSE}_w(l_{b+h,t})\\
              \end{align*}
  
          :param max_backstep: Max backstep to use in forecasting. If we train with x(0),...,x(t),
              Then, the b-th model MSES uses will forecast x(t+h) by anchoring at x(t-b) and 
              predicting xhat(t+h) = x(t-b) + delta_hat(b+h).
          :param recency_weight: The recency weight parameter to use when estimating delta_hat.
          :param accel_weight: The weight to scale the acceleration by when computing delta_hat.
              Specifically, delta_hat(b+h) = velocity(b+h) + accel_weight * acceleration(b+h).
          :param optimize_acc: If True, the acceleration correction will only be used at scales
              ranging from 1,...(max_backstep+max_forecast_steps)/2.
          :param eta: The parameter used to control the rate at which recency_weight gets
              tuned when online updates are made to the model and losses can be computed.
          :param rho: The parameter that determines what fraction of the overall error is due to
              velcity error, while the rest is due to the complement. The error at any scale 
              will be determined as ``rho * velocity_error + (1-rho) * loss_error``.
          :param phi: The parameter used to exponentially inflate the magnitude of loss error at
              different scales. Loss error for scale ``s`` will be increased by a factor of ``phi ** s``.  
          :param inflation: The inflation exponent to use when computing the distribution
              p(b|h) over the models when forecasting at horizon h according to standard
              errors of the estimated velocities over the models; inflation=1 is equivalent
              to using the softmax function.
          """
      super().__init__(max_forecast_steps=max_forecast_steps, **kwargs)
      assert 0.0 <= rho <= 1.0
      assert 1.0 <= phi
      self.max_backstep = (
          max_forecast_steps if max_backstep is None else max_backstep
      )
      self.recency_weight = recency_weight
      self.accel_weight = accel_weight
      self.optimize_acc = optimize_acc
      self.eta = eta
      self.rho = rho
      self.phi = phi
      self.inflation = inflation
  
imports: import logging
  from math import floor
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import pandas
  from merlion.utils.time_series import TimeSeries, UnivariateTimeSeries, assert_equal_timedeltas
  from merlion.utils.istat import ExponentialMovingAverage, RecencyWeightedVariance
  from merlion.utils.resample import to_pd_datetime, to_timestamp
  from merlion.transform.moving_average import LagTransform
  from merlion.transform.resample import TemporalResample
  from merlion.models.forecast.base import ForecasterBase, ForecasterConfig
label_desc: Use image node_id 1 to create a new MSESConfig object from inherited base classes: ForecasterConfig with example: obj = MSESConfig(max_forecast_steps, max_backstep, recency_weight, accel_weight, optimize_acc, eta, rho, phi, inflation)