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

如何使用tsfresh python包从时间序列数据中提取特征?,python,time-series,feature-extraction,tsfresh,Python,Time Series,Feature Extraction,Tsfresh,我有一个列表,其中每个列表代表一个时间序列: 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 tsf

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

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
任何资源或参考资料都会有所帮助


谢谢

首先,您必须将
列表
转换为
数据帧
,其中每个时间序列都有一个唯一的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']

现在,您可以对创建的列使用tsfresh和
列\u id
参数:

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


>> Feature Extraction: 100%|██████████| 5/5 [00:00<00:00, 36.83it/s]
tf=tsfresh.extract_特征(df,column_id='id')

>>特征提取:100%|██████████| 5/5[00:00Tsfresh似乎使用数据帧作为数据格式,而不是列表。因此,即使我将其转换为df,那么如何为此设置列id?我有一个困惑,为什么我们有从0到59的索引,它是否将所有时间序列作为单个时间序列?感谢您的解决方案。欢迎:-)是的,tsfresh需要将所有时间序列都转换为“叠加为单个时间序列”,并由id(因此为列)分隔。这是因为如果您想进行多变量时间序列分析,您仍然可以使用矩阵/2D数据帧。您可以忽略索引。顺便说一句,谢谢,这非常有帮助:)