binder

Demo of the PlateauFinder transformer#

What does the PlateauFinder do?

  • It searches for time series segments of a given minimum length with a constant given value (i.e. plateaus) and returns their starting points (on the time series index) and lengths,

  • The value to search for can also be set to np.nan or np.inf to find missing values,

  • The minimum length of segments to consider can also be specified; if set to 1, returns as starting points all locations of the given value.

[1]:
import numpy as np
import pandas as pd

from sktime.transformations.panel.summarize import PlateauFinder
[2]:
# generate toy data
X = pd.DataFrame(
    pd.Series(
        [
            pd.Series([np.nan, np.nan, 3, 3, np.nan, 2, 2, 3]),
            pd.Series([0, np.nan, np.nan, np.nan, np.nan, np.nan, 2, np.nan]),
            pd.Series([2, np.nan, np.nan, np.nan, 2, np.nan, 3, 1]),
            pd.Series([1, np.nan, np.nan, 3, np.nan, np.nan, 2, 0]),
        ]
    )
)
X.head()
[2]:
0
0 0 NaN 1 NaN 2 3.0 3 3.0 4 NaN 5...
1 0 0.0 1 NaN 2 NaN 3 NaN 4 NaN 5...
2 0 2.0 1 NaN 2 NaN 3 NaN 4 2.0 5...
3 0 1.0 1 NaN 2 NaN 3 3.0 4 NaN 5...
[3]:
#  find plateaus
t = PlateauFinder()
Xt = t.fit_transform(X)
Xt
[3]:
0_nan_starts 0_nan_lengths
0 [0] [2]
1 [1] [5]
2 [1] [3]
3 [1, 4] [2, 2]

Generated using nbsphinx. The Jupyter notebook can be found here.