Skip to main content

A package for transforming time series features

Project description

ts_features_sculptor

A package for feature engineering on time series data.

Installation

pip install ts_features_sculptor

Example

A simple example of feature engineering creation:

import numpy as np
import pandas as pd
from sklearn.pipeline import Pipeline
from ts_features_sculptor import (
    ToDateTime,
    SortByTime,
    Tte,
    TimedRollingAggregator
)

data = {
    'time': [
        '2025-10-01 06:00:00',
        '2025-02-01 12:00:00',
        '2025-02-11 18:00:00',
        '2025-01-10 06:00:00'
    ],
    'value': [
        10., 11., 12., 11.
    ]
}
df = pd.DataFrame(data)

pippeline = Pipeline([
    ('to_datetime', ToDateTime(time_col="time")),
    ('sort_by_time', SortByTime(time_col="time")),
    ('tte', Tte(time_col="time")),
    ('time_rolling_aggregator', TimedRollingAggregator(
        time_col = "time",
        feature_col = "tte",
        window_days = 30,
        agg_funcs = ['mean', 'count'],
        fillna = np.nan
    ))
])

result_df = pippeline.transform(df)

print(result_df.to_string(index=False))
               time  value    tte  tte_time_rolling_mean_30  tte_time_rolling_count_30
2025-01-10 06:00:00   11.0  22.25                       NaN                        NaN
2025-02-01 12:00:00   11.0  10.25                     22.25                        1.0
2025-02-11 18:00:00   12.0 231.50                     10.25                        1.0
2025-10-01 06:00:00   10.0    NaN                       NaN                        NaN

Transformers

  • ToDateTime - Converts string time values to datetime format
  • SortByTime - Sorts data by timestamp.
  • TimeValidator - Validates the correctness of timestamps.
  • Tte - Computes time to event in days.
  • Lag - Creates lag features (time-shifted values).
  • RowRollingAggregator - Aggregates data using a fixed-row rolling window.
  • TimedRollingAggregator -Aggregates data using a time-based rolling window (in days).
  • DaysOfLife - Calculates the number of days since the start of observations (from the earliest date).
  • DateTimeDecomposer - Decomposes timestamps into components (year, month, day, day of week, hour, etc.).
  • Expanding - Computes expanding aggregates (cumulative statistics).
  • Expression - Applies custom expressions to data using numpy functions.

Generators

  • TemporalGenerator - Base abstract class for time series generators.
  • FlexibleCyclicalGenerator - Generates weakly cyclical signals with high intra-cycle variability.
  • StructuredCyclicalGenerator - Generates signals with strict cyclicity and low stochasticity.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ts_features_sculptor-1.0.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ts_features_sculptor-1.0.1-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file ts_features_sculptor-1.0.1.tar.gz.

File metadata

  • Download URL: ts_features_sculptor-1.0.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for ts_features_sculptor-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ec3a4e7aabd9d31cef20323a859cd917e04f46d1f82bb1fe9e610990cc1bbe52
MD5 faf6076209a53cc92ae349d8040711af
BLAKE2b-256 728b774793869716a80fd9c2ba24f7f57bf0abd385fc6310d8172627b3253a60

See more details on using hashes here.

File details

Details for the file ts_features_sculptor-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ts_features_sculptor-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 431385298455e8f04452d4805d93a427a74f2c1ac8c445a028b99ef274de34dd
MD5 b4ed922431db91292bdfbabdb47a34b0
BLAKE2b-256 d5c09622557fb46a5f082d5a5d578d50437a4b4fef2a14ffd481b60f57ec9833

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page