Skip to main content
. 2020 Mar 6;20(5):1457. doi: 10.3390/s20051457
Algorithm 4: Recognize Activity
Input:  Ar{a1,a2…an}, a set of activity
         at, test sample
         w1,w2, weight of ratio
         n, select the number of training instances with the highest similarity
Output:label, label of at
1. TimegetTime(Ar)//get bt and et
2. AllRatio←Ø
3. kSelectK(Ar)//SelectK is used to select the optimal k
4. clfKMeans(n_clusters=k)//clustering
5. clf.fit(Time)//fitting the data
6. mclf.predict({at.bt,at.et})//find the cluster where the test sample is located
7. for each a in Ar:
8.    if cluster(a) == m:
9.       ratiogetRatio(a,at,w1,w2)//calculate ratio
10.       AllRatio←◡ratio
11.    end if
12. end for
13. sort(AllRatio)//sort max to min
14. for i in range(n):
15.    valgetALLRatio(i)//get the first n instances of maximum ratio
16.    topk_y←◡val
17. end for
18. labelvote(topk_y)//vote for label
19. return label