-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindFastUShapelet.py
33 lines (26 loc) · 956 Bytes
/
FindFastUShapelet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
import numpy as np
from SortUshapelets import *
from GetActualGap import *
def FindFastUShapelet(data, classLabels, dataFileName, sLen):
_, bestShapelets, _ = SortUshapelets(data, sLen)
tsNumber, dataWidth = data.shape
sPosSize = dataWidth - sLen + 1
sNum = tsNumber*sPosSize
maxGapCurrent = 0
bestShIndex = 0
computationStop = 1
if (sNum > 100):
onePercentData = np.round(sNum*0.01)
riNew = np.zeros((bestShapelets.shape[0], 1))
i = 0
clsNum = len(set(classLabels))
for i in range(int(onePercentData)):
gap, ri, _ = GetActualGap(sLen, bestShapelets, i, data, classLabels, clsNum)
bestShapelets[i, 2] = gap
riNew[i] = ri
if (gap > maxGapCurrent):
bestShIndex = i
maxGapCurrent = gap
computationStop = i
return bestShIndex, bestShapelets, sLen, clsNum, _, _, _, _