Как изменить пошаговый весовой коэффициент в пакете R DTW

Я хотел бы изменить вес пошагового шаблона по умолчанию функции стоимости, потому что мне нужно стандартизировать свои результаты с некоторыми другими в статье, в которой не используется вес 2 для диагонального расстояния. Я прочитал документ по JSS, но нашел другие пошаговые шаблоны, которые не соответствуют Я действительно ищу, я думаю. Например, представьте, что у нас есть два временных ряда Q, C:

Q = array(c(0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0),dim=c(8,2))
C = array(c(0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0),dim=c(8,2))

Когда я вычисляю расстояние dtw, я получаю выравнивание = dtw(Q,C,keep=TRUE) с расстоянием alginment$, равным 2,41, и матрицей стоимости, где, например, элемент [2,2] равен 2 вместо 1 из-за вес или штраф 2*d[i,j] по диагонали при выборе минимума между:

g[i,j] = min( g[i-1,j-1] + 2 * d[i  ,j  ] ,
              g[i  ,j-1] +     d[i  ,j  ] ,
              g[i-1,j  ] +     d[i  ,j  ] )

person gissemari    schedule 25.09.2016    source источник
comment
Вы должны предоставить минимальный воспроизводимый пример с демонстрационными данными, показывающими функции, которые вы используете, чтобы облегчить вам помощь.   -  person MrFlick    schedule 26.09.2016


Ответы (1)


plot(asymmetricP1)
edit(asymmetricP1)
structure(c(1, 1, 1, 2, 2, 3, 3, 3, 1, 0, 0, 1, 0, 2, 1, 0, 2, 
1, 0, 1, 0, 1, 0, 0, -1, 0.5, 0.5, -1, 1, -1, 1, 1), .Dim = c(8L, 4L), class = "stepPattern", npat = 3, norm = "N")

Посмотрите на график и рассмотрите ветви в порядке справа налево (т.е. ветвь1 = вес 0,5). Все в приведенном ниже сценарии находится в контексте графика (асимметричныйP1) и редактирования (асимметричныйP1)

#first 8 digit sequence (1,1,1,2,2,3,3,3....
#branch1: "1,1,1" <- amount of intervals assigned to specificaly branch1; (end, joint, origin) 
#branch2: "2,2" <- only 2 intervals, this is the middle diagnol line.
#branch3: "3,3,3" <- amount of interals
#note: Don't be confused by the numbers themselves, ie. "4,4,4" <- 3 intervals; "2,2,2" <- 3 intervals

#for the next sequences consider:
#the sequence of each branch is to be read as farthest from origin -> 0,0 
#each interval assignment is accounted for in this order

#next 8 digit sequence: 1, 0, 0, 1, 0, 2, 1, 0,
#branch1: 1,0,0 <- interval position in relation to the query index
#branch2: 1,0 <- interval position in relation to the query index
#branch3: 2,1,0 <- interval position in relation to the query index (again see in plot)

#next 8 digit sequence: 2, 1, 0, 1, 0, 1, 0, 0
#branch1: 2,1,0 <- interval position in relation to the REFERENCE index
#branch2: 1,0 <- interval position in relation to the reference index
#branch3: 1,0,0 <- interval position in relation to the reference index (again see in plot)

#next 8 digit sequence: -1, 0.5, 0.5, -1, 1, -1, 1, 1
#note: "-1" is a signal that indicates weighting values follow
#note: notice that for each -1 that occurs, there is one value less, for example branch 1
# .....which has 3 intervals can only contain 2 weights (0.5 and 0.5)
#branch1: -1,0.5,0.5 <- changing the first 0.5 changes weight of [-1:0] segment (query index)
#branch2: -1,1 <- weight of middle branch
#branch3: -1,1,1 <- changing the second 1 changes weight of[-1,0] segment (query index)

#.Dim=c(8L, 4L): 
#8 represents the number of intervals (1,1,1,2,2,3,3,3)
#4 (from what I understand) is the (length of all the branch sequences mentioned previously)/8

#npat = 3
#3 is the number of patterns you described in the structure. ie(1,1,1,2,2,3,3,3)

Надеюсь это поможет. Удачи!

person Aaron43    schedule 19.05.2017