我有两个时间序列表,看起来像这样。

我计算了binary列来计算特定的分类值,如果这个值=“x”,那么赋值为1,否则赋值为0。我像这样用ggplot绘制了这个图,
p <-ggplot(x1,aes(Time, binary))
p + geom_line()+
xlab("Time in seconds (s)")+
scale_y_continuous(name="x = 1, anything else = 0", breaks=c(0, 1))+
labs(title = "Example of the duration")我得到了我想要的,

我对第二个时间序列做了同样的处理,得到了这张图,

现在是使用dtw function计算距离的时候了。我不确定如何将这个二进制数据存储到进位或矩阵中,以便在这里通过dtw函数传递它,
dtw(
x,
y = NULL,
dist.method = "Euclidean",
step.pattern = symmetric2,
window.type = "none",
keep.internals = FALSE,
distance.only = FALSE,
open.end = FALSE,
open.begin = FALSE,
...
)其中x是查询向量或局部成本矩阵,y是参考向量,或者如果x给定为局部成本矩阵,则为NULL
我做的是这样的,
i<-c(x1$binary)
j<-c(x2$binary)
dtw1 <-dtw(i, j, dist.method="Euclidean", keep.internals = T, step.pattern= symmetric)
plot(dtw1)但这是不正确的。每种方法的图表都不同,如下所示。矩阵成本为空。它只计算每列的0,1的数量。我知道这是不正确的,但我不知道如何获得查询和参考向量来计算dtw。如何将其应用于此二进制数据?

发布于 2020-11-26 02:59:54
我所做的是,我没有将二进制值赋给dtw函数,而是使用了时间。
i<-c(x1$Time)
j<-c(x2$Time)
dtw1 <-dtw(i, j, dist.method="Euclidean", keep.internals = T, step.pattern= asymmetric)
plot(dtw1)https://stackoverflow.com/questions/64994274
复制相似问题