Skip to content

innovate.seasonal_decomposition

All current Python definitions

View source · Source file SHA-256: 522871fe0b61b840b5f85b8f278beb2b79c7afd68645265ae3a68983d56d74e4

def seasonal_decomposition(
data: pl.Series,
*,
period: int,
trend_span: int | None = None,
robust: bool = False,
historical: bool = False,
inner_iterations: int = 5,
outer_iterations: int | None = None,
seasonal_span: int | None = None,
low_pass_span: int | None = None,
seasonal_degree: int = 1,
seasonal_jump: int = 1,
trend_degree: int = 1,
trend_jump: int = 1,
low_pass_degree: int = 1,
low_pass_jump: int = 1,
) -> pl.DataFrame: ...

Separate an evenly spaced numeric series into trend, season and residual.

Samples are converted to JSON and processed by the native seasonal smoother. The caller must establish even spacing: a Series provides no timestamps to check. The result is a decomposition, not a forecast or uncertainty estimate.

  • data: Finite numeric Polars Series without nulls, ordered in time.
  • period: Samples per seasonal cycle, at least two; the series must contain at least three complete cycles.
  • trend_span: Trend smoothing window. Required unless historical=True; historical mode derives an odd window from period and seasonal span when this is None. Native window-length restrictions apply.
  • robust: Whether to use robust reweighting; defaults to False.
  • historical: Whether to use historical STL local-fitting and reweighting rules; defaults to False.
  • inner_iterations: Inner smoothing passes, from 1 through 100; defaults to 5.
  • outer_iterations: Robust reweighting passes, from 0 through 100. None selects 5 when robust and 0 otherwise; positive values require robust mode.
  • seasonal_span: Optional odd seasonal smoothing span of at least 3. Defaults to 7 in historical mode or at most 7 samples per phase otherwise.
  • low_pass_span: Optional odd low-pass span of at least 3; the native default is the smallest odd number strictly greater than period.
  • seasonal_degree: Seasonal local polynomial degree, 0 or 1; defaults to 1.
  • seasonal_jump: Positive spacing between fitted seasonal points; defaults to 1.
  • trend_degree: Trend local polynomial degree, 0 or 1; defaults to 1.
  • trend_jump: Positive spacing between fitted trend points; defaults to 1.
  • low_pass_degree: Low-pass polynomial degree, 0 or 1; defaults to 1.
  • low_pass_jump: Positive spacing between fitted low-pass points; defaults to 1.

DataFrame with aligned trend, seasonal and residual columns, one row per sample in the original order.

  • NativeError: If sample counts, spans, iteration controls or numerical computations violate the native seasonal-decomposition contract.
  • ValueError: If serialization encounters non-finite values.
  • TypeError: If input values or options cannot be serialized as JSON.
  • polars.exceptions.PolarsError: If native results cannot form a DataFrame.