2 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]]
Run Code Online (Sandbox Code Playgroud)
我想使用代码使用 tsfresh 包从该数据集中提取特征:
import tsfresh
tf=tsfresh.extract_features(tsli)
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到值错误,即:
> 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.
Run Code Online (Sandbox Code Playgroud)
编辑1: 正如建议的那样,我尝试将数据集转换为数据,然后尝试:
import tsfresh
df=pd.DataFrame(tsli)
tf=tsfresh.extract_features(df)
Run Code Online (Sandbox Code Playgroud)
但值错误是相同的
> ValueError: You have to set the column_id which contains the ids of the different time series
Run Code Online (Sandbox Code Playgroud)
任何资源或参考都会有所帮助。
谢谢
首先你必须将你的转换list为 a dataframe,其中每个时间序列都有一个唯一的 id,例如
df = pd.DataFrame()\nfor i, ts in enumerate(tsli):\n data = [[x, i] for x in ts]\n df = df.append(data, ignore_index=True)\ndf.columns = [\'value\', \'id\']\nRun Code Online (Sandbox Code Playgroud)\n\n\n\ncolumn_id现在您可以在创建的列上使用 tsfresh 和参数:
tf=tsfresh.extract_features(df, column_id=\'id\')\n\n\n>> Feature Extraction: 100%|\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 5/5 [00:00<00:00, 36.83it/s]\nRun Code Online (Sandbox Code Playgroud)\n\n另一个例子:tsfresh 快速入门
\n| 归档时间: |
|
| 查看次数: |
10299 次 |
| 最近记录: |