如何使用tsfresh python包从时间序列数据中提取特征?

问题描述 投票:0回答:1

我有一个列表列表,其中每个列表代表一个时间序列:

tsli=[[43,65,23,765,233,455,7,32,57,78,4,32],[34,32,565,87,23,86,32,56,32,57,78,32],[87,43,12,46,32,46,13,23,6,90,67,8],[1,2,3,3,4,5,6,7,8,9,0,9],[12,34,56,76,34,12,45,67,34,21,12,22]]

我想使用代码使用tsfresh包从此数据集中提取特征:

import tsfresh
tf=tsfresh.extract_features(tsli)

[当我运行它时,我收到值错误,它是:

> ValueError: You have to set the column_id which contains the ids of the different time series
But i don't know how to deal with this and how to define column id for this problem.

编辑1:正如建议的那样,我尝试将数据集转换为数据,然后尝试:

import tsfresh
df=pd.DataFrame(tsli)
tf=tsfresh.extract_features(df)

但值错误相同

> ValueError: You have to set the column_id which contains the ids of the different time series

任何资源或参考都将有所帮助。

谢谢

python python-3.x time-series feature-extraction tsfresh
1个回答
0
投票

首先,您必须将list转换为dataframe,其中每个时间序列都有唯一的ID,例如

df = pd.DataFrame()
for i, ts in enumerate(tsli):
    data = [[x, i] for x in ts]
    df = df.append(data, ignore_index=True)
df.columns = ['value', 'id']

enter image description here ... enter image description here

现在您可以在创建的列上将tsfresh与column_id参数一起使用:

tf=tsfresh.extract_features(df, column_id='id')


>> Feature Extraction: 100%|██████████| 5/5 [00:00<00:00, 36.83it/s]

另一个例子:tsfresh Quick Start

© www.soinside.com 2019 - 2024. All rights reserved.