| Algorithm 1. Auto-Labeling Data for CTL |
| Input: Original Time series data,>0, which represents the proportion threshold parameter of the trend definition |
| Output: The label vector |
| Initialization of related variables: |
| FP=x1, which represents the first price obtained by the algorithm; xH =x1, used to mark the highest price; HT=t1, used to mark the time when the highest price occurs; xL =x1, used to mark the lowest price; LT=t1, used to mark the time when the lowest price occurs; Cid=0, used to mark the current direction of labeling; FP_N =0, the index of the highest or lowest point obtained initially. |
|
fori = 1:N if (xi > FP + x1*) Set [xH, HT, FP_N, Cid ] = [ xi, ti, i,1] and end for if (xi < FP- x1*) Set [xL, LT, FP_N, Cid ] = [ xi, ti, i, −1] and end for end for i for i = FP_N+1:N if (Cid > 0) if (xi > xH) Set [xH, HT] = [ xi, ti ] if (xi < xH - xH* and LT <= HT) for j = 1:N if (tj > LT and tj <= HT) Set yj = 1 end for j Set [xL, LT, Cid] = [ xi, ti, −1] if (Cid < 0) if (xi < xL) Set [xL, LT] = [ xi, ti ] if (xi > xL + xL * and HT <= LT) for j = 1:N if (tj > HT and tj < = LT) Set yj = −1 end for j Set[xH, HT, Cid] = [ xi, ti, 1] end for i |