【问题标题】:False Nearest Neighbors in PythonPython中的错误最近邻
【发布时间】:2021-12-23 16:10:46
【问题描述】:

我有一个包含多元时间序列数据的 pandas 数据框。一栏代表温度,一栏代表湿度,一栏代表。例如,如下所示的数据框:

       temperature    humidity    wind
0           59           97        8
1           59           89        8
2           58           79        7
3           58           74        7
4           60           74        7
5           62           76        10

然后我想在这个数据帧上应用 takens embedding(时间延迟嵌入) 算法。我使用 Giotto-TDA 包来应用嵌入数据框的拍摄。下面的链接显示了这个包如何在数据上执行 takes 嵌入:
https://giotto-ai.github.io/gtda-docs/latest/modules/generated/time_series/embedding/gtda.time_series.TakensEmbedding.html

Takens Embedding Algorithm 采用 time_delaydimension 两个输入。如果我们有一个单变量时间序列,我们可以对时间序列数据执行启发式函数,以找到用于拍摄嵌入算法的最佳 time_delaydimension。启发式函数在以下链接中可用:
https://giotto-ai.github.io/gtda-docs/latest/modules/generated/time_series/embedding/gtda.time_series.takens_embedding_optimal_parameters.html#gtda.time_series.takens_embedding_optimal_parameters

但是当我们处理多元时间序列数据时,比如我上面的数据框,我们应该使用 false 最近邻 算法来找到 time_delay 的最佳值em>尺寸。但是我没有在 python 中找到任何可用的函数来在我的数据帧上运行错误的最近邻居。我刚刚发现了一个名为 TISEAN 的包,它可以对时间序列数据执行错误的最近邻。 TISEAN 包中 假最近邻 算法的链接是:
https://www.pks.mpg.de/tisean/TISEAN_2.1/docs/chaospaper/node9.html

https://www.pks.mpg.de/tisean//TISEAN_2.1/docs/docs_c/false_nearest.html

但是你可以看到这个包不是用 python 编写的,我认为是用 C 语言编写的。

我想知道如何在 python 中使用 TISEAN 包在我的数据帧上执行 假最近邻?或者除了使用 TISEAN 对我的多元时间序列数据执行 false 最近邻 算法之外,python 中还有其他方法吗?

【问题讨论】:

    标签: python pandas dataframe numpy time-series


    【解决方案1】:

    名为 teaspoon 的库实现了假最近邻算法。它还具有相互信息并采用嵌入定理。这是链接: https://lizliz.github.io/teaspoon/FNN.html

    我也相信有人在 github 上用 python 写了 TISEAN。这是另一个链接: https://github.com/galaunay/pytisean

    如果你想使用曹改进的FNN方法,我在python中使用了R,所以如果你有需要的包你可以使用这个:

    import rpy2.robjects as ro
    from rpy2.robjects.packages import importr
    from rpy2.robjects import numpy2ri
    
    nonlinearTseries = importr("nonlinearTseries")
    data = numpy2ri.numpy2rpy(savgol_price)
    
    cao_emb_dim = nonlinearTseries.estimateEmbeddingDim(
        data,  # time series
        len(data),  # number of points to use, use entire series
        62,  # time delay
        20,  # max no. of dimension
        0.95,  # threshold value
        0.1,  # max relative change
        True,  # do the plot
        "Computing the embedding dimension",  # main
        "dimension (d)",  # x_label
        "E1(d) & E2(d)",  # y_label
        ro.NULL,  # x_lim
        ro.NULL,  # y_lim
        1e-5  # add a small amount of noise to the original series to avoid the
              # appearance of false neighbours due to discretization errors.
              # This also prevents the method to fail with periodic signals, 0 for no noise
    )
    
    embedding_dimension = int(cao_emb_dim[0])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-21
      • 2018-10-10
      • 2016-01-28
      • 1970-01-01
      • 2016-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多