ts_shape.features.segment_analysis.time_windowed_features
| Name | Description |
|---|---|
TimeWindowedFeatureTable | Build ML-ready feature tables from segmented timeseries data. |
TimeWindowedFeatureTable
Bases: Base
Build ML-ready feature tables from segmented timeseries data.
Takes the output of SegmentProcessor.apply_ranges and computes statistical metrics per UUID within fixed-size time windows (e.g. every 1 minute).
Methods:
- compute_long: One row per (time_window, uuid, segment). Long format.
- compute: One row per time_window with columns {uuid}__{metric}. Wide format.
| Name | Description |
|---|---|
compute_long | Compute statistical metrics per UUID per time window (long format). |
compute | Compute a wide-format feature table with one row per time window. |
compute_long
compute_long(
dataframe: pd.DataFrame,
window: str = "1min",
time_column: str = "systime",
uuid_column: str = "uuid",
value_column: str = "value_double",
segment_column: str | None = "segment_value",
metrics: list[str] | None = None,
) -> pd.DataFrame
Compute statistical metrics per UUID per time window (long format).
Groups the input data into fixed-size time windows of window and
computes numeric statistics for each (time_window, uuid, segment) group.
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Input DataFrame (typically output of SegmentProcessor.apply_ranges). | required |
window | str | Pandas frequency string for the time window size (e.g. '1min', '30s', '5min'). freq is the deprecated name. | '1min' |
time_column | str | Column containing timestamps. | 'systime' |
uuid_column | str | Column identifying each timeseries signal. | 'uuid' |
value_column | str | Column containing numeric values. | 'value_double' |
segment_column | str | None | Column to sub-group by (e.g. 'segment_value'). Set to None to ignore segments entirely. | 'segment_value' |
metrics | list[str] | None | Subset of metric names to compute. None uses all 19. | None |
Windows are the bins of pd.Grouper(freq=window) (for sub-daily
frequencies they start at midnight of the first day; on tz-aware data
they are wall-clock windows in the data's zone). A window that spans a
segment change gives one row per segment. Groups with fewer than 2
non-missing values are left out.
| Type | Description |
|---|---|
DataFrame | DataFrame with columns time_window, uuid, segment_value?, |
[DataFrame | sample_count, metric_1, ..., start, end, duration_seconds], one row |
DataFrame | per (window, uuid, segment) sorted in that order. time_window |
DataFrame | is the pandas bin label; start, end) is the window itself. |
[DataFrame | For left-labeled windows ('1min', 'D', 'MS' ...) start equals |
DataFrame | time_window; right-labeled ones ('W', 'ME', 'QE', 'YE' ...) |
DataFrame | are labeled by their last day, so e.g. the 'ME' window labeled |
DataFrame | 2024-01-31 has start 2024-01-01 and end 2024-02-01. |
DataFrame | Empty (with these columns) when no group has 2 values. |
compute
compute(
dataframe: pd.DataFrame,
window: str = "1min",
time_column: str = "systime",
uuid_column: str = "uuid",
value_column: str = "value_double",
segment_column: str | None = "segment_value",
metrics: list[str] | None = None,
column_separator: str = "__",
) -> pd.DataFrame
Compute a wide-format feature table with one row per time window.
Each column is named {uuid}{separator}{metric} (e.g.
temperature__mean). Windows where a UUID has insufficient data
are filled with NaN. Every window between the first and the last
sample appears, also one where no UUID has 2 values (all NaN; with
a segment_column its segment is NaN too).
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Input DataFrame (typically output of SegmentProcessor.apply_ranges). | required |
window | str | Pandas frequency string for the time window size. freq is the deprecated name. | '1min' |
time_column | str | Column containing timestamps. | 'systime' |
uuid_column | str | Column identifying each timeseries signal. | 'uuid' |
value_column | str | Column containing numeric values. | 'value_double' |
segment_column | str | None | Column to sub-group by. Set to None to ignore segments. | 'segment_value' |
metrics | list[str] | None | Subset of metric names to compute. None uses all 19. | None |
column_separator | str | Separator between uuid and metric in wide column names. | '__' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns [time_window, segment_value?, {uuid}__{metric}, ...], sorted by time_window; time_window is the pandas bin label (see :meth:compute_long). Empty input gives an empty frame; input with no group of 2 values gives one row per window and only the index columns. |