Skip to content

datasets

datasets ¤

Synthetic timeseries generators for trying out ts-shape.

These helpers produce DataFrames in the standard ts-shape schema (systime, uuid, value_*, is_delta) so any detector, transform, or statistic can be exercised without real data or loaders::

import ts_shape
df = ts_shape.make_timeseries(["sensor:temp"], n_outliers=4)
ts_shape.OutlierDetectionEvents(df, value_column="value_double") \
    .detect_outliers_zscore()

make_timeseries ¤

make_timeseries(
    uuids: Sequence[str] = ("sensor:signal",),
    *,
    n_points: int = 1000,
    freq: str = "30s",
    start: str = "2025-01-01 00:00:00",
    baseline: float = 100.0,
    noise: float = 1.0,
    drift: float = 0.0,
    n_outliers: int = 0,
    value_column: str = "value_double",
    seed: int | None = 42
) -> pd.DataFrame

Generate a standard-schema synthetic timeseries DataFrame.

Parameters:

Name Type Description Default
uuids Sequence[str]

Signal identifiers; one block of n_points rows per uuid.

('sensor:signal',)
n_points int

Number of samples generated per uuid.

1000
freq str

Pandas offset alias for the sampling interval (e.g. "30s").

'30s'
start str

Timestamp of the first sample.

'2025-01-01 00:00:00'
baseline float

Mean level of the generated signal.

100.0
noise float

Standard deviation of the Gaussian noise added to the signal.

1.0
drift float

Total linear drift applied across the series (tool-wear style).

0.0
n_outliers int

Number of large spike outliers injected per uuid.

0
value_column str

Which value column to populate -- one of value_double, value_integer or value_bool.

'value_double'
seed int | None

Seed for reproducibility; pass None for fresh randomness.

42

Returns:

Type Description
DataFrame

DataFrame with columns systime, uuid, value_bool,

DataFrame

value_integer, value_double, value_string and is_delta.

Raises:

Type Description
ValueError

If value_column is not a supported value column, or n_points is not positive.

make_id_signal ¤

make_id_signal(
    uuid: str = "object:id",
    values: Sequence[str] = ("A", "B", "C"),
    *,
    hold: int = 10,
    freq: str = "30s",
    start: str = "2025-01-01 00:00:00",
    value_column: str = "value_string",
    source_uuid: str | None = None
) -> pd.DataFrame

Generate a categorical identifier signal in the standard schema.

Each value in values is held for hold consecutive samples, so the signal looks like a real batch / serial / coil / recipe id stream that changes over time. Feed it to :mod:ts_shape.eventlog.objects to extract object instances.

Parameters:

Name Type Description Default
uuid str

Signal identifier.

'object:id'
values Sequence[str]

Ordered id values; each held for hold samples.

('A', 'B', 'C')
hold int

Samples each value persists before the next one starts.

10
freq str

Pandas offset alias for the sampling interval.

'30s'
start str

Timestamp of the first sample.

'2025-01-01 00:00:00'
value_column str

Which column carries the id (value_string or value_integer).

'value_string'
source_uuid str | None

Optional source_uuid to stamp on every row.

None

Returns:

Type Description
DataFrame

DataFrame with the standard ts-shape columns, value_column filled.