# The Use of Transfer Learning for Activity Recognition in Instances of Heterogeneous Sensing
## 3 Transfer Learning Framework for Recognising Activities of Daily Living across Sensing Technology
### Teacher/Learner Phase  
Similarly to the conventional machine-learning modelling's process, TL-FmRADLs entails two stages, namely, training and testing. The training stage embraces all three phases of TL-FmRADLs (data preparation, transfer learning, and AL), whereas the testing stage embraces only phases 2 and 3 (transfer learning and AL). Referring to the steps from phase 1 illustrated in Figure 1, raw data gathered from the available sensor devices are immediately pre-processed (1, 2). Data are then fragmented in small time-windows to capture fine gestures involved within the AR events (3). As part of the second phase, the segmented data are sent to a front-desk (\(FD\)) component (4), which will then seek for a legacy version or else a compatible AR model based on a semantic-based search [36]. If the \(FD\) finds a legacy version, the legacy version is assigned with a teacher role (5a); otherwise the model builder (\(MB\)) component builds the AR model upon any labelled data available at this step (5d). Another possible variation, however, is when the \(FD\) finds more than one legacy AR model (5b), in which case the AR model with higher classification accuracy will emerge as teacher (5c). Formalisation and Pseudo-Code  
To further detail on the functionality of the different components introduced above, this Section first presents the primary algorithm corresponding to the T/L phase, followed by its derived dependencies/functions. As presented before and illustrated within steps from 5a to 5d from Figure 1, one of the responsibilities of the \(FD\) component consists of assigning a T/L role to the incoming AR models. In Algorithm 1, we can observe that the \(FD\) assigns roles based on the performance of the AR model given by \(\textit{unseenActRate}=\sum_{k=1}^{l}\frac{D_{S}^{\prime}}{D_{S_{k}}}\), in which \(k\) is the \(k\)th AR model within a pool of AR trained models \(D_{S[\cdot]}\), and \(D_{S}^{\prime}\) stands for a complementary AR trained model, where \(D_{S}^{\prime}\in D_{S[\cdot]}\) and \(D_{S}^{\prime}\
eq D_{Sk}\). Although \(unseenActRate\) consists of a scalar value that states the error loss retrieved from the function \(setTrainingModel(\cdot)\) the validation to determine the T/L roles is dictated by the function \(getValidationUponRuleScheema(\cdot)\) (detailed in Algorithm 2), in which the lower the ratio of unseen activities, the more chances to become a Teacher (\(D_{S}\)). To ensure selecting the proper teacher model, the \(FD\) tests all associated models utilising the function \(setTrainingModel(\cdot)\) (detailed in Algorithm 3), and only those AR models whose \(unseenActRate\) satisfy the selection rules are taken into account. Figure 1: A high-level overview of TL-FmRADLs which combines AL phase as a mechanism of self-training, where the digits represent the sequential order of how data are processed. ```
1:\(X=\) A pool of unlabelled instances. \(D_{S[:]}=\) A pool of AR trained models \(\{D_{S1},D_{S2},\dots,D_{Sk}\}\). \(D^{\prime}_{S}=\) A complementary AR model different than \(D_{Sk}\). \(k=\) Index variable. \(output\): \(output=\) [data, labels]. \(D_{S}=\) Most informative AR model (Teacher). 2:for (\(k=0\); \(k<=len(D_{S[:]})\), \(k++\)) do
3: Search for an existent AR model in \(D_{S[:]}\) that relates to the unlabelled instances \(X\). 4: Assign to \(unseenActRate\) the error lost retrieved from \(setTrainingModel(D_{Sk},X)\). 5: Assign to \(D_{Sk}\) the most informative teacher model determined by having the lowest error value from \(unseenActRate\) (\(\sum_{k=1}^{l}\frac{D^{\prime}_{S}}{D_{Sk}}\)). 6:if satisfy threshold given by \(getValidationUponRuleSchema(unseenActRate)\) then
7:\(D_{Sk}\) is assigned as teacher model. 8:\(D_{S}=D_{Sk}\). 9:ends if
10:\(output=buildModel(D_{S},X)\). 11:return [\(D_{S},output\)]
```  
**Algorithm 1** Selection of the teacher models and training of the untrained learner model.