## 2 Methodology
### Temporal Subsampling
#### 2.2.3 Cosine-Based Temporal Subsampling  
Cosine similarity [34] is a metric that assesses how similar two vectors are to one another. It represents the cosine of the angle formed by the two vectors. Cosine similarity is formally defined as the division between the dot product of the vectors and the product of the Euclidean magnitude of each vector. The range of the cosine similarity value is from 0 to 1, with 1 denoting the highest similarity and 0 denoting the lowest. The following is the equation for the cosine similarity score between two feature vectors \(f_{i}\) and \(f_{j}\):  
\[\text{similarity }=cos(\theta)=\frac{f_{i}\cdot f_{j}}{\parallel f_{i} \parallel\parallel f_{j}\parallel} \tag{1}\]  
In our setup, we applied cosine similarity between each feature vector and its successor, and then stored the similarity score and index of the first feature vector in a tuple list \(S\). After gathering all the similarity scores, the tuple list \(S\) was sorted ascendingly. All the feature vectors denoted by scores in the upper 90% (i.e., the scores closer to 1) in the tuple list \(S\) were marked for elimination. This subsampling process is detailed in Algorithm 2. ```
Input: FVs[]: Feature matrix of train and test data sets Output: IDX_DEL[]: Frame indices to delete  Scores[]: Empty tuple to hold cosine scores for i = 0... count_off(FVs)-1 do  C = Cosine score between FVs(i,-) and FVs(i + 1,-)  Append [C,i] to Scores || end  Sort Scores[] ascendingly (based on C values)  IDX_DEL[] = Indices (i) of upper 90 th percentile in Scores[]
```  
**Algorithm 2**Cosine-based temporal subsampling of frames. The concept here is that higher similarity scores between feature vectors imply a higher degree of similarity between them, which indicates redundancy and allows the algorithm to eliminate one of the frames. For example, if we have the frames \([fr_{1},fr_{2},fr_{3},fr_{4},\ldots,fr_{n}]\) and their feature vectors: \([v_{1},v_{2},v_{3},v_{4},\ldots,v_{n}]\), the cosine similarity scores between them are \([c_{1},c_{2},c_{3},c_{4},\  
The authors of [36] first suggested using stepwise regression in video-based intelligent systems. Since then, it has been effectively employed in many vision-based applications, as documented in several works, including [12; 37; 38]. In this study, we used stepwise regression to reduce the dimensionality of our feature vectors, where features were treated as predictors and the class labels were treated as response variables. This was carried out to assess the suitability of the selected features and consequently reduce the dimensionality of the feature vectors if needed. Stepwise regression was only used with the training data because it is a supervised approach. Later, the dimensionality of the test data was reduced by using the indices of the retained feature variables of the training set, as illustrated in Figure 5.  
For completeness, a summary of the stepwise regression algorithm is as follows: for a feature set of \(x_{1},x_{2},\ldots,x_{k}\), \(F_{in}\) is the F-random feature for the feature to be added to the reduced feature space, and \(F_{out}\) is the feature to be dropped from the reduced feature space. The steps for stepwise regression are as follows:  
1. Create single-set models from all features: \[h(x)=\theta_{0}+\theta_{1}x_{1}\] (2) where \(h(x)\) is the hypothesis that the added features are important for classification. \(x_{1}\) was one of the features that yielded the highest F-score. \(f_{1}\) is the statistic of \(x_{1}\), and is given by the following formula: \[f_{1}=\frac{SS_{R}(\theta_{2}|\theta_{1}\theta_{0})}{MS_{E}(x_{2},x_{1})}\] (3) where \(MS_{E}\) is the mean square error, and \(SS_{R}\) is the regression sum square error. 2. Repeat step 1 for all feature variables. For every new \(h(x)\) produced, it is examined in combination with the existing \(h(x)\) if they produce a higher hypothesis than the older \(h(x)\) alone.