docstr: An implementation of the 4Theta method with configurable `theta` parameter.
  
  See M4 competition `solution <https://github.com/Mcompetitions/M4-methods/blob/master/4Theta%20method.R>`_.
  
  The training time series is de-seasonalized according to `seasonality_period`,
  or an inferred seasonality period.
  
  `season_mode` must be a ``SeasonalityMode`` Enum member.
  `model_mode` must be a ``ModelMode`` Enum member.
  `trend_mode` must be a ``TrendMode`` Enum member.
  
  You can access the different Enums with ``from darts import SeasonalityMode, TrendMode, ModelMode``.
  
  When called with `theta = X`, `model_mode = Model.ADDITIVE` and `trend_mode = Trend.LINEAR`,
  this model is equivalent to calling `Theta(theta=X)`.
  
  Parameters
  ----------
  theta
      Value of the theta parameter. Defaults to 2.
      If theta = 1, then the fourtheta method restricts to a simple exponential smoothing (SES).
      If theta = 0, then the fourtheta method restricts to a simple `trend_mode` regression.
  seasonality_period
      User-defined seasonality period. If not set, will be tentatively inferred from the training series upon
      calling `fit()`.
  model_mode
      Type of model combining the Theta lines. Either ModelMode.ADDITIVE or ModelMode.MULTIPLICATIVE.
      Defaults to `ModelMode.ADDITIVE`.
  season_mode
      Type of seasonality.
      Either SeasonalityMode.MULTIPLICATIVE, SeasonalityMode.ADDITIVE or SeasonalityMode.NONE.
      Defaults to `SeasonalityMode.MULTIPLICATIVE`.
  trend_mode
      Type of trend to fit. Either TrendMode.LINEAR or TrendMode.EXPONENTIAL.
      Defaults to `TrendMode.LINEAR`.
  normalization
      If `True`, the data is normalized so that the mean is 1. Defaults to `True`.
  
  Notes
  -----
  Even though this model is an improvement of :class:`Theta`, it is a naive
  implementation of the algorithm, which can potentially be slower.
  
  Examples
  --------
  >>> from darts.datasets import AirPassengersDataset
  >>> from darts.models import FourTheta
  >>> series = AirPassengersDataset().load()
  >>> model = FourTheta(theta=2)
  >>> model.fit(series)
  >>> pred = model.predict(6)
  >>> pred.values()
  array([[443.3949283 ],
         [434.39769555],
         [495.28886231],
         [481.08962991],
         [481.78610361],
         [546.61463773]])
docstr_tok: ["An","implementation","of","the","4Theta","method","with","configurable","`","theta","`","parameter",".","See","M4","competition","`","solution","<","https",":","\/\/github.com\/Mcompetitions\/M4-methods\/blob\/master\/4Theta","%","20method.R",">","`","_",".","The","training","time","series","is","de-seasonalized","according","to","`","seasonality_period","`",",","or","an","inferred","seasonality","period",".","`","season_mode","`","must","be","a","``","SeasonalityMode","``","Enum","member",".","`","model_mode","`","must","be","a","``","ModelMode","``","Enum","member",".","`","trend_mode","`","must","be","a","``","TrendMode","``","Enum","member",".","You","can","access","the","different","Enums","with","``","from","darts","import","SeasonalityMode",",","TrendMode",",","ModelMode","``",".","When","called","with","`","theta","=","X","`",",","`","model_mode","=","Model.ADDITIVE","`","and","`","trend_mode","=","Trend.LINEAR","`",",","this","model","is","equivalent","to","calling","`","Theta","(","theta=X",")","`",".","Parameters","--","--","--","--","--","theta","Value","of","the","theta","parameter",".","Defaults","to","2",".","If","theta","=","1",",","then","the","fourtheta","method","restricts","to","a","simple","exponential","smoothing","(","SES",")",".","If","theta","=","0",",","then","the","fourtheta","method","restricts","to","a","simple","`","trend_mode","`","regression",".","seasonality_period","User-defined","seasonality","period",".","If","not","set",",","will","be","tentatively","inferred","from","the","training","series","upon","calling","`","fit","(",")","`",".","model_mode","Type","of","model","combining","the","Theta","lines",".","Either","ModelMode.ADDITIVE","or","ModelMode.MULTIPLICATIVE",".","Defaults","to","`","ModelMode.ADDITIVE","`",".","season_mode","Type","of","seasonality",".","Either","SeasonalityMode.MULTIPLICATIVE",",","SeasonalityMode.ADDITIVE","or","SeasonalityMode.NONE",".","Defaults","to","`","SeasonalityMode.MULTIPLICATIVE","`",".","trend_mode","Type","of","trend","to","fit",".","Either","TrendMode.LINEAR","or","TrendMode.EXPONENTIAL",".","Defaults","to","`","TrendMode.LINEAR","`",".","normalization","If","`","True","`",",","the","data","is","normalized","so","that","the","mean","is","1",".","Defaults","to","`","True","`",".","Notes","--","--","-","Even","though","this","model","is","an","improvement","of",":","class",":","`","Theta","`",",","it","is","a","naive","implementation","of","the","algorithm",",","which","can","potentially","be","slower",".","Examples","--","--","--","--",">",">",">","from","darts.datasets","import","AirPassengersDataset",">",">",">","from","darts.models","import","FourTheta",">",">",">","series","=","AirPassengersDataset","(",")",".load","(",")",">",">",">","model","=","FourTheta","(","theta=2",")",">",">",">","model.fit","(","series",")",">",">",">","pred","=","model.predict","(","6",")",">",">",">","pred.values","(",")","array","(","[","[","443.3949283","]",",","[","434.39769555","]",",","[","495.28886231","]",",","[","481.08962991","]",",","[","481.78610361","]",",","[","546.61463773","]","]",")"]
code: def __init__(
      self,
      theta: int = 2,
      seasonality_period: Optional[int] = None,
      season_mode: SeasonalityMode = SeasonalityMode.MULTIPLICATIVE,
      model_mode: ModelMode = ModelMode.ADDITIVE,
      trend_mode: TrendMode = TrendMode.LINEAR,
      normalization: bool = True,
  ):
      """
      An implementation of the 4Theta method with configurable `theta` parameter.
  
      See M4 competition `solution <https://github.com/Mcompetitions/M4-methods/blob/master/4Theta%20method.R>`_.
  
      The training time series is de-seasonalized according to `seasonality_period`,
      or an inferred seasonality period.
  
      `season_mode` must be a ``SeasonalityMode`` Enum member.
      `model_mode` must be a ``ModelMode`` Enum member.
      `trend_mode` must be a ``TrendMode`` Enum member.
  
      You can access the different Enums with ``from darts import SeasonalityMode, TrendMode, ModelMode``.
  
      When called with `theta = X`, `model_mode = Model.ADDITIVE` and `trend_mode = Trend.LINEAR`,
      this model is equivalent to calling `Theta(theta=X)`.
  
      Parameters
      ----------
      theta
          Value of the theta parameter. Defaults to 2.
          If theta = 1, then the fourtheta method restricts to a simple exponential smoothing (SES).
          If theta = 0, then the fourtheta method restricts to a simple `trend_mode` regression.
      seasonality_period
          User-defined seasonality period. If not set, will be tentatively inferred from the training series upon
          calling `fit()`.
      model_mode
          Type of model combining the Theta lines. Either ModelMode.ADDITIVE or ModelMode.MULTIPLICATIVE.
          Defaults to `ModelMode.ADDITIVE`.
      season_mode
          Type of seasonality.
          Either SeasonalityMode.MULTIPLICATIVE, SeasonalityMode.ADDITIVE or SeasonalityMode.NONE.
          Defaults to `SeasonalityMode.MULTIPLICATIVE`.
      trend_mode
          Type of trend to fit. Either TrendMode.LINEAR or TrendMode.EXPONENTIAL.
          Defaults to `TrendMode.LINEAR`.
      normalization
          If `True`, the data is normalized so that the mean is 1. Defaults to `True`.
  
      Notes
      -----
      Even though this model is an improvement of :class:`Theta`, it is a naive
      implementation of the algorithm, which can potentially be slower.
  
      Examples
      --------
      >>> from darts.datasets import AirPassengersDataset
      >>> from darts.models import FourTheta
      >>> series = AirPassengersDataset().load()
      >>> model = FourTheta(theta=2)
      >>> model.fit(series)
      >>> pred = model.predict(6)
      >>> pred.values()
      array([[443.3949283 ],
             [434.39769555],
             [495.28886231],
             [481.08962991],
             [481.78610361],
             [546.61463773]])
      """
  
      super().__init__()
  
      self.model = None
      self.drift = None
      self.mean = 1
      self.length = 0
      self.theta = theta
      self.is_seasonal = False
      self.seasonality = None
      self.seasonality_period = seasonality_period
      self.season_period = None
      self.model_mode = model_mode
      self.season_mode = season_mode
      self.trend_mode = trend_mode
      self.wses = 0 if self.theta == 0 else (1 / theta)
      self.wdrift = 1 - self.wses
      self.fitted_values = None
      self.normalization = normalization
  
      raise_if_not(
          isinstance(model_mode, ModelMode),
          f"Unknown value for model_mode: {model_mode}.",
          logger,
      )
      raise_if_not(
          isinstance(trend_mode, TrendMode),
          f"Unknown value for trend_mode: {trend_mode}.",
          logger,
      )
      raise_if_not(
          isinstance(season_mode, SeasonalityMode),
          f"Unknown value for season_mode: {season_mode}.",
          logger,
      )
  
imports: import math
  from typing import List, Optional
  import numpy
  import statsmodels.tsa.holtwinters
  from darts.logging import get_logger, raise_if_not, raise_log
  from darts.models.forecasting.forecasting_model import LocalForecastingModel
  from darts.timeseries import TimeSeries
  from darts.utils.statistics import check_seasonality, extract_trend_and_seasonality, remove_from_series
  from darts.utils.utils import ModelMode, SeasonalityMode, TrendMode
label_desc: Use image node_id 1 to create a new FourTheta object from inherited base classes: LocalForecastingModel with example: obj = FourTheta(theta, seasonality_period, season_mode, model_mode, trend_mode, normalization)