# Bridge Health Monitoring Using Proper Orthogonal Decomposition and Transfer Learning
## 2 TL-Based Damage Identification
### TL Using JDA-kernel
Upon determining \(\mathbf{A}\), the optimal transformation matrix, \(\mathbf{Z}\), is calculated as [26]:  
\[\mathbf{Z}=\mathbf{A}^{T}\mathbf{K} \tag{5}\]  
Maximum Mean Discrepancy (MMD) is a kernel-based approach used to compute differences between marginal (\(P(X_{s})\) and \(P(X_{t})\)) and conditional distributions (\(P(y_{s}|X_{s})\) and \(P(y_{t}|X_{t})\)) in the source and target domains. This distance is calculated using the summation of the distances between sample means of source and target domain [26]. Distances for marginal distributions in the feature space with kernelized data are calculated as:  
\[\left|\left|\frac{1}{n_{s}}\ \sum_{i=1}^{n_{s}}\mathbf{Z}_{i}-\frac{1}{n_{t}}\sum_{j= n_{s}+1}^{n_{s}+n_{t}}\mathbf{Z}_{j}\left|\right|^{2}=tr\Big{(}\mathbf{Z}\mathbf{M}_{0} \mathbf{Z}^{T}\Big{)}\right. \tag{6}\]  
where \(M_{0}\) is the MMD matrix calculated as:  
\[\left(M_{0}\right)_{ij}=\left\{ \begin{array}{ll}\frac{1}{n_{s}n_{s}},&\text {for }\mathbf{x}_{i},\ \mathbf{x}_{j}\ \in\ \mathcal{D}_{s},\\ \frac{1}{n_{t}n_{t}},&\text{for }\mathbf{x}_{i},\ \mathbf{x}_{j}\ \in\ \mathcal{D}_{t}, \text{or}\\ \frac{1}{n_{t}n_{t}},&\text{for }\mathbf{x}_{i},\ \mathbf{x}_{j}\ \in\ \mathcal{D}_{t}, \text{or}\\ \frac{1}{n_{t}n_{t}}.\end{array} \right. \tag{7}\]Since the target domain is not labeled, JDA uses pseudo labels (\(y_{t}^{*}\)). The modified distance considering both marginal and conditional distributions is calculated as:  
\[\left|\left|\frac{1}{n_{s}}\ \sum_{i=1}^{n_{s}}\mathbf{Z}_{i}-\frac{1}{n_{t}}\sum_{j=n_{s }+1}^{n_{s}+n_{t}}\mathbf{Z}_{j}\left|\right|^{2}=tr\Big{(}\mathbf{Z}\mathbf{M}_{c}\mathbf{Z}^{T }\Big{)}\right. \tag{8}\]  
where \(\mathbf{M}_{c}\) is the MMD matrix including class labels and it is calculated as:  
\[\left(M_{c}\right)_{ij}= \begin{cases}\frac{1}{n_{s}^{(c)}n_{s}^{(c)}},\ \text{for}\ \mathbf{x}_{i},\ \mathbf{x}_{j}\ \in\ D_{s}^{(c)}\\ \frac{1}{n_{t}^{(c)}n_{t}^{(c)}},\ \text{for}\ \mathbf{x}_{i},\ \mathbf{x}_{j}\ \in\ D_{t}^{(c)}\\ \frac{1}{n_{s}^{(c)}n_{t}^{(c)}}\ \text{for}\ \begin{cases}\mathbf{x}_{i}\in\ D_{s}^{(c)},\ \mathbf{x}_{j}\ \in\ D_{s}^{(c)}\\ \mathbf{x}_{j}\in\ D_{s}^{(c)},\ \mathbf{x}_{i}\ \in\ D_{s}^{(c)}\\ 0.\end{cases}\,\text{ or}\\ \end{cases}  \tag{9}\]  
To constrain the problem, the regularization parameter, \(\lambda\), is defined and the optimization problem is formed as follows:  
\[\underset{\mathbf{A}^{T}\mathbf{K}\mathbf{H}\mathbf{K}^{T}\mathbf{A}=\mathbf{I}}{\text{Min}}\sum_{c=0} ^{\text{C}}tr\Big{(}\mathbf{A}^{T}\mathbf{K}\mathbf{M}_{c}\mathbf{K}^{T}\mathbf{A}\Big{)}+\lambda \|\mathbf{A}\|^{2} \tag{10}\]  
By defining the Lagrangian function, this optimization problem is solved as an eigenvalue problem that contains the \(k\) smallest eigenvalues:  
\[\left(\mathbf{K}\sum_{c=0}^{\text{C}}\mathbf{M}_{c}\mathbf{K}^{T}+\lambda\mathbf{I}\right)\bm {A}=\mathbf{K}\mathbf{H}\mathbf{K}^{T}\mathbf{A}\mathbf{\Phi} \tag{11}\]  
The \(k\)-dimensional optimal adaptation matrix, \(\mathbf{A}\), is a transformed matrix in the feature space and is further used for classification purposes. The JDA-kernel algorithm and KNN classifier are repeated several times until convergence happens. After each iteration, the performance of the algorithm is measured by comparing the true target labels (\(y_{t}\)) with the obtained pseudo label (\(y_{t}^{*}\)). Once the algorithm is converged, the optimized transformed matrix and corresponding predicted labels for target domain (\(y_{t}\)) are obtained.