tslumen.profile.smooth module

Data smoothing functions.

tslumen.profile.smooth.lowess(data: pandas.core.series.Series, fracs: Tuple[float, ] = (0.05, 0.1, 0.15), it: int = 3, delta: float = 0.0, missing: str = 'drop')pandas.core.frame.DataFrame[source]

Locally Weighted Scatterplot Smoothing

Parameters
  • data (pd.Series) – Time series.

  • fracs (Tuple[float, ..]) – Fraction of data to use when estimating each y-value.

  • it (int) – number of residual-based reweightings to perform.

  • delta (float) – Distance within which to use linear interpolation instead of weighted regression.

  • missing (str) – Approach to deal with missing values – ‘none’, ‘drop’, or ‘raise’.

Returns

DataFrame with original series (labelled ‘original’) and N smoothed series, as dictated by the parameter fracs, each series labelled as lowess <frac>%.

Return type

pd.DataFrame

tslumen.profile.smooth.rolling_avg(data: pandas.core.series.Series, wins: Optional[Tuple[int, ]] = (), max_win_frac: int = 10)pandas.core.frame.DataFrame[source]

Rolling average.

Parameters
  • data (pd.Series) – Time series.

  • wins (Tuple[int, ..]) – Size of the rolling windows – determined based on frequency if not provided.

  • max_win_frac (int) – Forces window size to be no bigger than data.length/max_win_frac.

Returns

DataFrame with original series (labelled ‘original’) and N smoothed series, as dictated by the parameter wins, each series labelled as rolling <win><freq>.

Return type

pd.DataFrame

tslumen.profile.smooth.supsmu(data: pandas.core.series.Series, alpha: Optional[float] = None, period: Optional[float] = None, primary_spans: Tuple[float, ] = (0.05, 0.2, 0.5), middle_span: float = 0.2, final_span: float = 0.05)pandas.core.frame.DataFrame[source]

SuperSmoother for nonparametric smoothing of scatter plots.

Parameters
  • data (pd.Series) – Time series.

  • alpha (float) – Bass enhancement / smoothing level (0 < alpha < 10).

  • period (float) – Data periodicity.

  • primary_spans (Tuple[float]) – Primary span values used for the smooth (between 0 and 1).

  • middle_span (float) – Middle span value.

  • final_span (float) – Final span value.

Returns

DataFrame with original and smooth series, labelled ‘original’ and ‘supsmu’ respectively.

Return type

pd.DataFrame