Skip to main content

Toolkit for flexible processing & feature extraction on time-series data

Project description

tsflex

PyPI Latest Release support-version codecov Code quality License: MIT Downloads Documentation Testing

tsflex is a toolkit for flexible time-series processing & feature extraction, making few assumptions about input data.

Useful links

Installation

If you are using pip, just execute the following command:

pip install tsflex

Why tsflex? ✨

  • flexible;
    • handles multi-variate time-series
    • versatile function support
      => integrates natively with many packages for processing (e.g., scipy.signal) & feature extraction (e.g., numpy, scipy.stats)
    • feature-extraction handles multiple strides & window sizes
  • efficient view-based operations
    => extremely low memory peak & fast execution times (see benchmarks)
  • maintains the time-index of the data
  • makes little to no assumptions about the time-series data

Usage

tsflex is built to be intuitive, so we encourage you to copy-paste this code and toy with some parameters!

Feature extraction

import pandas as pd; import scipy.stats as ssig; import numpy as np
from tsflex.features import FeatureDescriptor, FeatureCollection, NumpyFuncWrapper

# 1. -------- Get your time-indexed data --------
# Data contains 1 column; ["TMP"]
url = "https://github.com/predict-idlab/tsflex/raw/main/examples/data/empatica/tmp.parquet"
data = pd.read_parquet(url).set_index("timestamp")

# 2 -------- Construct your feature collection --------
fc = FeatureCollection(
    feature_descriptors=[
        FeatureDescriptor(
            function=NumpyFuncWrapper(func=ssig.skew, output_names="skew"),
            series_name="TMP", 
            window="5min",  # Use 5 minutes 
            stride="2.5min",  # With steps of 2.5 minutes
        )
    ]
)
# -- 2.1. Add features to your feature collection
fc.add(FeatureDescriptor(np.min, "TMP", '2.5min', '2.5min'))

# 3 -------- Calculate features --------
fc.calculate(data=data)

More examples

For processing look here
Other examples can be found here

Future work 🔨

  • scikit-learn integration for both processing and feature extraction
    note: is actively developed upon sklearn integration branch.
  • support for multi-indexed dataframes
  • random-strided rolling for data-augmention purposes.

Referencing our package

If you use tsflex in a scientific publication, we would highly appreciate citing us as:

@article{vanderdonckt2021tsflex,
    author = {Van Der Donckt, Jonas and Van Der Donckt, Jeroen and Van Hoecke, Sofie},
    title = {tsflex: flexible time series processing \& feature extraction},
    journal = {SoftwareX},
    year = {2021},
    url = {https://github.com/predict-idlab/tsflex},
    publisher={Elsevier}
}

👤 Jonas Van Der Donckt, Jeroen Van Der Donckt, Emiel Deprost

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

tsflex-0.1.1.7.tar.gz (37.8 kB view hashes)

Uploaded Source

Built Distribution

tsflex-0.1.1.7-py3-none-any.whl (49.1 kB view hashes)

Uploaded Python 3

Supported by

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