Skip to main content
Version: Next

ts_shape.features.export

Feature matrix export utilities for ts-shape.

Converts long-format timeseries DataFrames into wide feature matrices suitable for machine-learning workflows.

Classes
NameDescription
FeatureMatrixExporterConvert long-format timeseries DataFrames to wide feature matrices.

FeatureMatrixExporter​

classsource

Convert long-format timeseries DataFrames to wide feature matrices.

Pivots a multiplexed DataFrame (one row per timestamp per signal) into a single row per entity (e.g. cycle, segment, batch) with one column per {uuid}__{value_column}__{agg} combination. The result is ready for use with scikit-learn, XGBoost, or any tabular ML framework.

Usage::

from ts_shape.features.export import FeatureMatrixExporter

# Long-format df: columns systime, uuid, value_double
matrix = FeatureMatrixExporter.to_feature_matrix(df, uuid_column='uuid', value_columns=['value_double'])
Functions
NameDescription
to_feature_matrixPivot a long-format DataFrame into a wide feature matrix.

to_feature_matrix​

classmethodsource
to_feature_matrix(
dataframe: pd.DataFrame,
uuid_column: str = "uuid",
value_columns: list[str] | None = None,
agg_funcs: dict[str, str | Callable] | None = None,
group_column: str | None = None,
) -> pd.DataFrame

Pivot a long-format DataFrame into a wide feature matrix.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format DataFrame containing signal data.required
uuid_columnstrColumn whose unique values become column prefixes (e.g. 'uuid').'uuid'
value_columnslist[str] | NoneNumeric columns to aggregate. If None, the numeric value_* columns (value_double, value_integer) are used; flags such as is_delta are not features. A value_* column (other than value_string / value_bool) stored as object that holds numbers counts as numeric; its values are coerced with pd.to_numeric(errors="coerce").None
agg_funcsdict[str, str | Callable] | NoneMapping of name -> callable or pandas agg string. Defaults to mean, std (sample standard deviation, ddof=1), min, max.None
group_columnstr | NoneOptional column to use as the row index of the output matrix (e.g. 'cycle_uuid', 'batch_id'). When None the entire DataFrame is treated as one group and a single-row matrix is returned.None
Returns
TypeDescription
DataFrameWide-format DataFrame. Columns are named
DataFrame{uuid}__{value_column}__{agg}. Row index is group_column
DataFramewhen provided, otherwise 0.
Raises
TypeDescription
ColumnNotFoundErrorIf uuid_column, a value_columns entry or group_column is not in dataframe.
ValueErrorIf no numeric value column is found.