# Personalized Federated Learning for ECG Classification Based on Feature Alignment

Authors: Renjie Tang; Junzhou Luo; Junbo Qian; Jiahui Jin
Journal: Security and Communication Networks
 (2021)

---

## Abstract

Electrocardiogram (ECG) data classification is a hot research area for its application in medical information processing. However, insufficient data, privacy preserve, and local deployment are still challenging difficulties. To address these problems, a novel personalized federated learning method for ECG classification is proposed in this paper. First, a global model is trained with federated learning framework on multiple local data clients. Then, we use the global model and private data to train the local model. To reduce the feature inconsistency between global and private local data and for better fitting the private local data, a novel ”feature alignment” module is devised to guarantee the uniformity, which contains two parts, global alignment and local alignment, respectively. For global alignment, the graph metric of batch data is used to constrain the dissimilarity between features generated by the global model and local model. For local alignment, triplet loss is adopted to increase discriminative ability for local private data. Comprehensive experiments on our collected dataset are evaluated. The results show that the proposed method can be better adapted to local data and exhibit superior ability of generalization.


---

## Body

## 1. Introduction

Statistics of WHO report that heart disease is the most lethal chronic disease. Nearly 17.7 million people die of cardiovascular disease every year, which accounts for 31% of the total deaths in the world [1]. Electrocardiogram (ECG) is a physiological signal which is widely used in heart health monitoring. It contains many pathological information related to heart activity, and it is an effective way for monitoring and diagnosis of cardiovascular disease [2]. ECG is a long series of data and can be lasted for days, so it is very time and label consuming for monitoring and diagnosis with human experts. Therefore, it is necessary to use artificial intelligence technology for automatic cardiovascular disease diagnosis.Using the advanced machine learning technology especially deep learning, the cardiovascular recognition model can be trained with labeled ECG data, i.e., the method proposed in [3] achieves 0.837 F1 value for 12 kinds of cardiac irregularities. However, most state of the art methods are based on public available training datasets, which are relatively small and with limited varieties. Moreover, they are very difficult to deploy in practical applications.In order to expand available cardiovascular information and guarantee the privacy, data from multiple medical institutions can be combined as a unified dataset, which can be used to train a superior global model with federated learning framework [4]. Federated learning is a special machine learning model using datasets that are distributed across multiple devices while preventing data leakage. It is also a privacy-preserving decentralized collaborative learning technique [5]. There have been works that adopted federated learning for medical data processing and model training [6, 7].In this way, a centralized global model can be trained based on data from a large number of local nodes. Then, the global model is deployed to the local model for data prediction. However, there is a big challenge for which local models will get different performance by using the same global model. This is because data distributions of local clients vary with the global trained data distribution. Therefore, personalization of the global model for each client becomes necessary to overcome the problem posed by heterogeneity of data distribution [8].Device in terms of storage, computation, and communication capabilities will generate heterogeneous data. For ECG, sampling frequency and duration are different based on parameters setting and environment, which leads to nonuniform of pacing signal, left ventricular high voltage, and other diagnostic patterns. When there is large difference between data distributions of global server and local clients, it is hard to directly measure the feature inconsistency between them. Hence, this makes it difficult to deploy the global ECG classification model to local client with acceptable performance.In order to solve these problems, a novel personalized federated learning framework for ECG data classification is proposed. First, a global ECG classification model is trained with a typical federated learning method across multiple local clients. Then, the global model is inherited to local model and served as the backbone part. During local model personalized training, the inherited part model is fixed. The local model is personalized based on the proposed feature alignment module. To utilize the generalization of the global model, we form the features of batch data into graph representation, so the internal structure between nodes can be preserved. The graph distance between global feature and local feature is used for global alignment constrain. From another point of view, local alignment is used to make the model better adapt to local private data. The metric learning method is adopted, and a triplet loss is designed to make data point of same class close to each other and negative data point far away. Finally, these loss functions are combined together for model training. By the proposed method, the consistency between global and local data can be learned, and the local personalized model is built with better adaptability and generalization. As far as we know, there are no related research studies for problems of personalized ECG classification. The main contributions of this paper are two folds:(i)
In order to reduce the difference between global and local data, a novel feature alignment module is designed. With graph constraint and triplet metric, it can make the local model with better adaptability and generalization.(ii)
Extensive experimental evaluations are carried out, and performance analyses are reported from multiple aspects.The rest of this paper is organized as follows. Section2 gives the related works. Section 3 describes the methodology. Experimental evaluation and analysis are given in Section 4. Section 5 concludes this paper.


## 2. Related Works

Related works are introduced in this section, including ECG data classification method, federated learning framework, and personalization in federated learning.


### 2.1. ECG Classification Method

With well-designed feature representation, ECG classification can be realized by models based on Bayes, K-means, Decision tree, and Linear Discriminate classifiers [9–11], along with commonly used optimization techniques [12, 13]. Features like cycle and higher order of QRS wave were extracted in reference [14]. Then, a fuzzy neural network was trained as classifier. Wavelet transform was used for feature extraction in reference [15]. Reference [16] adopted support vector machine for ECG classification.A convolutional neural network method suitable for multilead ECG data was proposed in reference [17]. The stacked denosing autoencoder recognition model was used in reference [18] for ECG data. In reference [19], deep belief networks were used to construct the model for arrhythmia diagnosis. The convolutional neural networks model was used in reference [20] for heart beat classification. In reference [21], the deep factor decomposition method was used to decrease the influence of complex noise on ECG signal. Deep autoencoder was first used for singal denosing and reconstruction, and then fully convolutional network was trained as classifier. In reference [22], nonnegative matrix factorization was used for data dimension reduction and feature was extracted with sparse representation. Feature representation with multiple scales was proposed in reference [23], and progressive decisions were fused for final classification.


### 2.2. Federated Learning

In order to utilize massive distributed data storage and keep the privacy, federated learning is a useful framework to provide efficient training from data island and make model collaboration [4]. In reference [24], local models are trained at each local node, and only the updated parameters set is shared for global training. A multitask-based federated learning method was proposed in reference [25], which can solve the problem of high communication cost and fault tolerance. In reference [26], a safe client-server was first constructed. Data were allocated according to different local users. A homomorphic encryption method was designed for model parameter aggregation so as to improve server security [27]. A differential privacy method for federated learning was introduced in reference [28]. It provides protection for client data by hiding the customer’s contribution during training. A ternary quantization method was proposed in reference [29], which optimizes the quantized networks and reduces lots of redundant parameters and excessive communication costs. To address problems of unlabeled and unannotated on-device data, reference [30] used a deep temporal neural network to train an auxiliary task by optimizing a contrastive objective with multiview strategy on diverse data sets.


### 2.3. Personalization in Federated Learning

Federated learning can be used to train a global model by utilizing distributed local data. However, for different local clients, the benefits they get from global model may vary greatly for various data distributions. To cope with non-IID data distributions of clients, personalized federated learning has been proposed to improve performance of each local client by training a personalized local model. Reference [31] reported that local models’ performances were hard to improve during federated learning, which may even worse than training only using local data. Therefore, it is important for model personalization according to specific local node. In reference [32], local nodes were first clustered, and each group models were training separately. In reference [33], part parameters of the global model were copied to the local model, and then local model was fine-tuned using local data. The metalearning method was adopted in reference [34], which treated model personalization as a meta testing procedure. In reference [35], there was a balance between global and local models. Global and local models were combined for final classification. In reference [36], the local model and global model were considered as two experts, and the personalized model was trained by mixed output of the personalized model and global model. Similar work was studied in reference [37]. Reference [38] introduced an attentive message passing mechanism to facilitate the collaboration effectiveness between clients.


## 2.1. ECG Classification Method

With well-designed feature representation, ECG classification can be realized by models based on Bayes, K-means, Decision tree, and Linear Discriminate classifiers [9–11], along with commonly used optimization techniques [12, 13]. Features like cycle and higher order of QRS wave were extracted in reference [14]. Then, a fuzzy neural network was trained as classifier. Wavelet transform was used for feature extraction in reference [15]. Reference [16] adopted support vector machine for ECG classification.A convolutional neural network method suitable for multilead ECG data was proposed in reference [17]. The stacked denosing autoencoder recognition model was used in reference [18] for ECG data. In reference [19], deep belief networks were used to construct the model for arrhythmia diagnosis. The convolutional neural networks model was used in reference [20] for heart beat classification. In reference [21], the deep factor decomposition method was used to decrease the influence of complex noise on ECG signal. Deep autoencoder was first used for singal denosing and reconstruction, and then fully convolutional network was trained as classifier. In reference [22], nonnegative matrix factorization was used for data dimension reduction and feature was extracted with sparse representation. Feature representation with multiple scales was proposed in reference [23], and progressive decisions were fused for final classification.


## 2.2. Federated Learning

In order to utilize massive distributed data storage and keep the privacy, federated learning is a useful framework to provide efficient training from data island and make model collaboration [4]. In reference [24], local models are trained at each local node, and only the updated parameters set is shared for global training. A multitask-based federated learning method was proposed in reference [25], which can solve the problem of high communication cost and fault tolerance. In reference [26], a safe client-server was first constructed. Data were allocated according to different local users. A homomorphic encryption method was designed for model parameter aggregation so as to improve server security [27]. A differential privacy method for federated learning was introduced in reference [28]. It provides protection for client data by hiding the customer’s contribution during training. A ternary quantization method was proposed in reference [29], which optimizes the quantized networks and reduces lots of redundant parameters and excessive communication costs. To address problems of unlabeled and unannotated on-device data, reference [30] used a deep temporal neural network to train an auxiliary task by optimizing a contrastive objective with multiview strategy on diverse data sets.


## 2.3. Personalization in Federated Learning

Federated learning can be used to train a global model by utilizing distributed local data. However, for different local clients, the benefits they get from global model may vary greatly for various data distributions. To cope with non-IID data distributions of clients, personalized federated learning has been proposed to improve performance of each local client by training a personalized local model. Reference [31] reported that local models’ performances were hard to improve during federated learning, which may even worse than training only using local data. Therefore, it is important for model personalization according to specific local node. In reference [32], local nodes were first clustered, and each group models were training separately. In reference [33], part parameters of the global model were copied to the local model, and then local model was fine-tuned using local data. The metalearning method was adopted in reference [34], which treated model personalization as a meta testing procedure. In reference [35], there was a balance between global and local models. Global and local models were combined for final classification. In reference [36], the local model and global model were considered as two experts, and the personalized model was trained by mixed output of the personalized model and global model. Similar work was studied in reference [37]. Reference [38] introduced an attentive message passing mechanism to facilitate the collaboration effectiveness between clients.


## 3. Methodology

In this section, the proposed personalized federated learning for ECG classification based on feature alignment is described. Figure1 gives the main framework of the proposed method. First, a global model MG′ is constructed with a typical federated learning framework from multiple local clients. Then, for each client ci, we train a personalized local model with private dataset. The local model contains three parts, including MG, MC, and Mf. MG is inherited from the global model MG′. MC is a convolution neural networks module for local feature extraction and representation. Mf is a fully connected layer or softmax layer to form the final classifier. During local model training, MG is fixed to maintain the generalization ability of the global model. Specially, two alignment modules, global alignment and local alignment, are designed to constrain the feature distribution between local model and global model, which are realized by constraints of graph representation of feature generated by MG and MC, along with metric learning for intraclass and interclass losses. Finally, global alignment loss La, local alignment loss Lt, and cross-entropy loss Lc are all incorporated to optimize the objective function. Details are described in the following subsections.Figure 1
Main framework of the proposed method.


### 3.1. Global Model Training

In order to make the best use of distributed data and privacy guarantee, federated learning is a popular way for model training. In the first step, the global modelMG′ is trained with a most widely used federated learning framework FedAvg [39], which is synchronous update for each communication round.Figure2 demonstrates the framework for global model training in our work. There are n clients, and each contains a local dataset Pi and a local model Mi. Initially, the global server sends the model parameters to all clients. Then, each client ci performs local model training based on local data and then sends parameter update wi back to the server. The server collects all local updates, and the global model parameters are optimized, and this process is repeated for multiple times. For efficiency, the global model can be updated when part of local updates is collected.Figure 2
Global model training with federated learning.(1)lciwi=1ni∑k=1nilxk,yk,wi,(2)minwilciwi.For clientci, its model parameter wi is trained with local data xk,yk∈Pi. Equation (1) gives the loss function lci, which is the mean value of loss l () for all training data. ni is the total number of data in Pi. Then, equation (2) gives the minimize objective by adjusting wi with SGD and BP method.When clients finish their training, the server updates the global model parameterwG by averaging all client model’s parameters wi. As shown in equations (3) and (4), N is the number of clients and ti is the weight threshold for each model.(3)eG=1N∑i=1Nti∗wi,∑i=1Nti=1,(4)minwG1N∑i=1NlciwG.wG is distributed to all clients after one iteration, and each client uses sG as the base model to make further training using equations (1) and (2). After multiple iterations, the global model MG′ can be trained with optimal performance. Moreover, other federated learning frameworks can also be adopted for global model training.


### 3.2. Local Model Training

The global modelMG′ is trained with federated learning over distributed data in the last subsection. However, MG′ cannot be directly deployed to local clients for local data inference when there is large difference between data distributions of global server and local clients. In this subsection, a personalized model adaptation method is designed based on the global trained model and private data of a specific client. The local model ML contains 3 main components, ML=MG,MC,Mf. MG is inherited by the global trained model MG′, which serves as the backbone and is fixed during local model training. MC and Mf are used for local feature representation and final classifier of the local model.For better fitting the local private data, a special constraint strategy “feature alignment” is devised to guarantee the uniformity between global and local models. The alignment module is further divided into two parts, global alignment and local alignment, which are described as follows.


#### 3.2.1. Global Alignment

A global alignment module is first designed to constrain the local model training by constructing the structure between feature nodes. Different from other methods, the batch training data are used to from a graph structure, which can represent the relationship between data node. In this way, effect of single data feature shift can be reduced and relation between data nodes is retained. As shown in Figure3, for ith training batch data samples Xi,Yi in a private dataset, its global feature fgXi and local feature fpXi are extracted through models MG and MC. Then, the batch training data are treated as the basic group for global alignment operation.Figure 3
Demonstration of the global alignment module.The features of samples are then used to construct graph representation usingfgXi and fpXi. Suppose there are n samples in a training batch, then the graph representation contains n nodes and n2 edges. The nodes of graph are represented with the features of samples in a training batch, and the edges of graph are represented by the distances between nodes. gmXi and gpXi are used to denote the graph representation of ith batch data by global and local models, respectively.In order to measure the similarity between two batch data, matrix format is used to represent the graph structure representation. In this paper, only edges between nodes are incorporated for representation. It is hypothesis that the internal skeleton between nodes of a graph is more important and should be learned from the global model. If the node feature is used, then there will be strong probability that the local model is more like the global model. The white and yellow matrices in Figure3 are used to denote gmXi and gpXi, which are formulated as equations (5) and (6). e represents the edge between two nodes. xji and xki are two training samples in Xi.(5)gmXi=∪xji,xki∈Xiefgxji,fgxki,(6)gpXi=∪xji,xki∈Xiefpxji,fpxki.Equation (7) gives the distance metric for two graph representations of a given batch data Xi. d means a distance computation method, and Xi denotes the size of batch data. Basically, all edges of two feature graph representations are compared.(7)dXi=dgmXi,gpXi=1Xi∑xji,xki∈Xidefgxji,fgxki,efpxji,fpxki.


#### 3.2.2. Local Alignment

For model personalization with local private data, a local alignment module is also designed, which aims to increase the classification performance for local private data.As shown in Figure4, for a sample training batch data Xi,Yi in a private dataset, its local feature fpXi is extracted through models MC. Then, the batch training data are used as the basic group for local alignment operation. Using metric learning method, we try to decrease distance between features from the same class; otherwise, the distance is increased. A training sample is randomly selected from fpXi, which is denoted as fpxia. It is called anchor sample. Then, another two samples are selected. One sample has the same label with anchor, and the other sample has different label. These three samples constitute a triplet fpxia,fpxip,fpxin, where fpxip denotes the positive sample and fpxin denotes the negative sample. Through training, it is expected to decrease the distance between fpxia and fpxip and increase the distance between fpxia and fpxin. The constraint is shown in the following equation:(8)fpxia−fpxip22+αfpxia−fpxin22,∀fpxia,fpxip,fpxin∈Γ,where α is the threshold for minimal distance and Γ is the triplet set.Figure 4
Demonstration of the local alignment module.


### 3.3. Training Objective Function

The final loss function of our proposed model contains three parts, global alignment lossLa, local alignment loss Lt, and cross-entropy loss Lc, respectively.Global alignment lossLa is given in equation (9), which is inherited from equation (7). M means the number of batch data in all training dataset and i indicates the index of batch data.(9)La=∑i=1MdXi.Local alignment lossLt is given in equation (10), which is on the basis of equation (8). “+” means that function value is 0 when content in [ ] is smaller than 0; otherwise, it is the normal loss function value. Γi is the triplet set for ith batch data.(10)Lt=∑i=1M∑∀fpxia,fpxip,fpxin∈Γifpxia−fpxip22−fpxia−fpxin22+a+.Cross-entropy lossLc is given in equation (11). CE is the standard cross-entropy function. M and i are the same as equation (8). YXi is the ground truth label of batch data Xi, and Y′Xi is the output value of the local model.(11)Lc=∑i=1MCEYXi,Y′Xi.The final loss functionL is a combination of La, Lt, and Lc, as shown in equation (12). wa, wt, and wc are weighted hyperparameters. L is used to update the parameter of MC and Mf modules in the local personalized model:(12)L=wa∗La+wt∗Lt+wc∗Lc.


## 3.1. Global Model Training

In order to make the best use of distributed data and privacy guarantee, federated learning is a popular way for model training. In the first step, the global modelMG′ is trained with a most widely used federated learning framework FedAvg [39], which is synchronous update for each communication round.Figure2 demonstrates the framework for global model training in our work. There are n clients, and each contains a local dataset Pi and a local model Mi. Initially, the global server sends the model parameters to all clients. Then, each client ci performs local model training based on local data and then sends parameter update wi back to the server. The server collects all local updates, and the global model parameters are optimized, and this process is repeated for multiple times. For efficiency, the global model can be updated when part of local updates is collected.Figure 2
Global model training with federated learning.(1)lciwi=1ni∑k=1nilxk,yk,wi,(2)minwilciwi.For clientci, its model parameter wi is trained with local data xk,yk∈Pi. Equation (1) gives the loss function lci, which is the mean value of loss l () for all training data. ni is the total number of data in Pi. Then, equation (2) gives the minimize objective by adjusting wi with SGD and BP method.When clients finish their training, the server updates the global model parameterwG by averaging all client model’s parameters wi. As shown in equations (3) and (4), N is the number of clients and ti is the weight threshold for each model.(3)eG=1N∑i=1Nti∗wi,∑i=1Nti=1,(4)minwG1N∑i=1NlciwG.wG is distributed to all clients after one iteration, and each client uses sG as the base model to make further training using equations (1) and (2). After multiple iterations, the global model MG′ can be trained with optimal performance. Moreover, other federated learning frameworks can also be adopted for global model training.


## 3.2. Local Model Training

The global modelMG′ is trained with federated learning over distributed data in the last subsection. However, MG′ cannot be directly deployed to local clients for local data inference when there is large difference between data distributions of global server and local clients. In this subsection, a personalized model adaptation method is designed based on the global trained model and private data of a specific client. The local model ML contains 3 main components, ML=MG,MC,Mf. MG is inherited by the global trained model MG′, which serves as the backbone and is fixed during local model training. MC and Mf are used for local feature representation and final classifier of the local model.For better fitting the local private data, a special constraint strategy “feature alignment” is devised to guarantee the uniformity between global and local models. The alignment module is further divided into two parts, global alignment and local alignment, which are described as follows.


### 3.2.1. Global Alignment

A global alignment module is first designed to constrain the local model training by constructing the structure between feature nodes. Different from other methods, the batch training data are used to from a graph structure, which can represent the relationship between data node. In this way, effect of single data feature shift can be reduced and relation between data nodes is retained. As shown in Figure3, for ith training batch data samples Xi,Yi in a private dataset, its global feature fgXi and local feature fpXi are extracted through models MG and MC. Then, the batch training data are treated as the basic group for global alignment operation.Figure 3
Demonstration of the global alignment module.The features of samples are then used to construct graph representation usingfgXi and fpXi. Suppose there are n samples in a training batch, then the graph representation contains n nodes and n2 edges. The nodes of graph are represented with the features of samples in a training batch, and the edges of graph are represented by the distances between nodes. gmXi and gpXi are used to denote the graph representation of ith batch data by global and local models, respectively.In order to measure the similarity between two batch data, matrix format is used to represent the graph structure representation. In this paper, only edges between nodes are incorporated for representation. It is hypothesis that the internal skeleton between nodes of a graph is more important and should be learned from the global model. If the node feature is used, then there will be strong probability that the local model is more like the global model. The white and yellow matrices in Figure3 are used to denote gmXi and gpXi, which are formulated as equations (5) and (6). e represents the edge between two nodes. xji and xki are two training samples in Xi.(5)gmXi=∪xji,xki∈Xiefgxji,fgxki,(6)gpXi=∪xji,xki∈Xiefpxji,fpxki.Equation (7) gives the distance metric for two graph representations of a given batch data Xi. d means a distance computation method, and Xi denotes the size of batch data. Basically, all edges of two feature graph representations are compared.(7)dXi=dgmXi,gpXi=1Xi∑xji,xki∈Xidefgxji,fgxki,efpxji,fpxki.


### 3.2.2. Local Alignment

For model personalization with local private data, a local alignment module is also designed, which aims to increase the classification performance for local private data.As shown in Figure4, for a sample training batch data Xi,Yi in a private dataset, its local feature fpXi is extracted through models MC. Then, the batch training data are used as the basic group for local alignment operation. Using metric learning method, we try to decrease distance between features from the same class; otherwise, the distance is increased. A training sample is randomly selected from fpXi, which is denoted as fpxia. It is called anchor sample. Then, another two samples are selected. One sample has the same label with anchor, and the other sample has different label. These three samples constitute a triplet fpxia,fpxip,fpxin, where fpxip denotes the positive sample and fpxin denotes the negative sample. Through training, it is expected to decrease the distance between fpxia and fpxip and increase the distance between fpxia and fpxin. The constraint is shown in the following equation:(8)fpxia−fpxip22+αfpxia−fpxin22,∀fpxia,fpxip,fpxin∈Γ,where α is the threshold for minimal distance and Γ is the triplet set.Figure 4
Demonstration of the local alignment module.


## 3.2.1. Global Alignment

A global alignment module is first designed to constrain the local model training by constructing the structure between feature nodes. Different from other methods, the batch training data are used to from a graph structure, which can represent the relationship between data node. In this way, effect of single data feature shift can be reduced and relation between data nodes is retained. As shown in Figure3, for ith training batch data samples Xi,Yi in a private dataset, its global feature fgXi and local feature fpXi are extracted through models MG and MC. Then, the batch training data are treated as the basic group for global alignment operation.Figure 3
Demonstration of the global alignment module.The features of samples are then used to construct graph representation usingfgXi and fpXi. Suppose there are n samples in a training batch, then the graph representation contains n nodes and n2 edges. The nodes of graph are represented with the features of samples in a training batch, and the edges of graph are represented by the distances between nodes. gmXi and gpXi are used to denote the graph representation of ith batch data by global and local models, respectively.In order to measure the similarity between two batch data, matrix format is used to represent the graph structure representation. In this paper, only edges between nodes are incorporated for representation. It is hypothesis that the internal skeleton between nodes of a graph is more important and should be learned from the global model. If the node feature is used, then there will be strong probability that the local model is more like the global model. The white and yellow matrices in Figure3 are used to denote gmXi and gpXi, which are formulated as equations (5) and (6). e represents the edge between two nodes. xji and xki are two training samples in Xi.(5)gmXi=∪xji,xki∈Xiefgxji,fgxki,(6)gpXi=∪xji,xki∈Xiefpxji,fpxki.Equation (7) gives the distance metric for two graph representations of a given batch data Xi. d means a distance computation method, and Xi denotes the size of batch data. Basically, all edges of two feature graph representations are compared.(7)dXi=dgmXi,gpXi=1Xi∑xji,xki∈Xidefgxji,fgxki,efpxji,fpxki.


## 3.2.2. Local Alignment

For model personalization with local private data, a local alignment module is also designed, which aims to increase the classification performance for local private data.As shown in Figure4, for a sample training batch data Xi,Yi in a private dataset, its local feature fpXi is extracted through models MC. Then, the batch training data are used as the basic group for local alignment operation. Using metric learning method, we try to decrease distance between features from the same class; otherwise, the distance is increased. A training sample is randomly selected from fpXi, which is denoted as fpxia. It is called anchor sample. Then, another two samples are selected. One sample has the same label with anchor, and the other sample has different label. These three samples constitute a triplet fpxia,fpxip,fpxin, where fpxip denotes the positive sample and fpxin denotes the negative sample. Through training, it is expected to decrease the distance between fpxia and fpxip and increase the distance between fpxia and fpxin. The constraint is shown in the following equation:(8)fpxia−fpxip22+αfpxia−fpxin22,∀fpxia,fpxip,fpxin∈Γ,where α is the threshold for minimal distance and Γ is the triplet set.Figure 4
Demonstration of the local alignment module.


## 3.3. Training Objective Function

The final loss function of our proposed model contains three parts, global alignment lossLa, local alignment loss Lt, and cross-entropy loss Lc, respectively.Global alignment lossLa is given in equation (9), which is inherited from equation (7). M means the number of batch data in all training dataset and i indicates the index of batch data.(9)La=∑i=1MdXi.Local alignment lossLt is given in equation (10), which is on the basis of equation (8). “+” means that function value is 0 when content in [ ] is smaller than 0; otherwise, it is the normal loss function value. Γi is the triplet set for ith batch data.(10)Lt=∑i=1M∑∀fpxia,fpxip,fpxin∈Γifpxia−fpxip22−fpxia−fpxin22+a+.Cross-entropy lossLc is given in equation (11). CE is the standard cross-entropy function. M and i are the same as equation (8). YXi is the ground truth label of batch data Xi, and Y′Xi is the output value of the local model.(11)Lc=∑i=1MCEYXi,Y′Xi.The final loss functionL is a combination of La, Lt, and Lc, as shown in equation (12). wa, wt, and wc are weighted hyperparameters. L is used to update the parameter of MC and Mf modules in the local personalized model:(12)L=wa∗La+wt∗Lt+wc∗Lc.


## 4. Experimental Evaluation

In this section, dataset description and experiment setting are first given. Then, the performance of the proposed method for personalized ECG classification is evaluated in terms of various environments.


### 4.1. Dataset and Experiment Setting

As there are no research studies on personalized federated learning for ECG classification, we construct a specific circumstance to evaluate the proposed algorithm. We collect about 120,000 ECG data from 8 hospitals. Table1 gives the detail description of dataset. Six symptoms such as sinus rhythm, sinus arrhythmia, sinus tachycardia, sinus bradycardia, T-wave alternans, and normal are selected, which are the commonest types and data rich. There are 20201, 18581, 13682, 15854, 14211, and 38524 for types of sinus rhythm, sinus arrhythmia, sinus tachycardia, sinus bradycardia, T-wave alternans, and normal, respectively. Data distributions of each medical institution are also listed in Table 2.Table 1
Dataset used in our experiment.
No.TypeQuantity1Sinus rhythm202012Sinus arrhythmia185813Sinus tachycardia136824Sinus bradycardia158545T-wave alternans142116Sinus normal38524Table 2
Data distributions of each medical institution.
TypeNode1Node2Node3Node4Node5Node6Node7Node8Sinus rhythm29241940230814833610310336451188Sinus arrhythmia24511720189312643171272835131841Sinus tachycardia1913128314071308226221782619712Sinus bradycardia2046152316601418289826652857787T-wave alternans1850129514771227241822602767917Normal55333866392036536652619674731231In our research, each medical institution is corresponded to a local node, and these local nodes provide private data for global training. Hence, the federated learning circumstance is set up.


### 4.2. Base Model Training

The server (global model) employs the FedAvg to train the model globally whereas each local client updates its model locally after successive global aggregations using the SGD style algorithm. The CNN model withResNet-34 is used as the base network structure for both global model and local model.Each experiment is run for 100 global aggregations, withe = 4 epochs for SGD between successive global aggregations. The constant learning rate of 0.01 is used across global aggregations and clients.Table3 gives the classification result of each local node after federated learning. Average classification rate is used as the metric in our work. There are two node types, local and global. The global model has a classification rate of 82.6%. For local nodes, there are two evaluations. Local nodes 1 to 8 obtain the classification rate of 89.48%, 88.76%, 90.25%, 91.54%, 88.31%, 89.57%, 90.18%, and 90.54%, respectively, on their corresponding local private data set. Meanwhile, local nodes 1 to 8 obtain the classification rate of 54.65%, 57.18%, 49.75%, 51.43%, 48.92%, 46.35%, 52.45%, and 50.20%, respectively, on global testing data set. It can be obviously seen that the performance of local models is better than that of global model on private data. Local models get low performance on global data data, with about 30% lower than the global model. These indicate that local models are more preferable to local data, while the global model trained with traditional federated learning framework needs further improvement. Therefore, it is urgent requirement to make model personalization.Table 3
Performance of each local node after federated learning.
Node typeNo.Classification rate (local)Classification rate (global)Local189.4854.65Local288.7657.18Local390.2549.75Local491.5451.43Local588.3148.92Local689.5746.35Local790.1852.45Local890.5450.20Global82.6


### 4.3. Model Personalization Evaluation

In this subsection, the proposed personalization model-based feature alignment is evaluated.The global modelMG′ obtained in the above subsection is first downloaded to each local node, and then the personalized model for each local node is trained on the basis of local data set Dp and MG′. Complying with Section 2, wa, wt, and wc are set with 0.3, 0.3, and 0.4, respectively. Batch size is set with 16, and learning rate is 0.001.Table4 gives the result of model personalization. Column 1 is the node index. Column 2 and 3 are average performance on local data with models of training with only local data and training with personalization. Column 4 and 5 are average performance on global data with models of training with only local data and training with personalization. It can be seen that the performance of model with personalization is decreased with about 3%. This demonstrates that the personalization model is less deviated to distribution of local data. For global testing data, the performance of the model with personalization is greatly increased with about 15–18%. It is a good validation that the personalization model is more generalized.Table 4
Performance of each local node after federated learning.
NodeAvg. (local)Avg. (local with personalization)Avg. (global)Avg. (global with personalization)189.4886.2554.6584.42288.7687.1857.1883.25390.2587.5049.7584.58491.5488.4251.4383.60588.3185.8548.9282.46689.5785.3446.3583.15790.1887.6852.4584.56890.5488.1550.2084.10


### 4.4. Comparisons with Other Methods

In this subsection, some related model personalization methods are compared with our proposed model. We implement algorithms of [31, 34, 35], and the average classification rate on local and global testing data is evaluated.Table5 demonstrates the comparison result. Methods in [33–35] get an average performance of 84.41%, 82.70%, and 83.55% on local node testing data and 79.80%, 78.68%, and 76.45% on global testing data. There are about 4% and 6% compared with our proposed method, and this validates the effectiveness of the proposed personalization framework and feature alignment module.Table 5
Comparisons with other methods.
AlgorithmAvg. (local)Avg. (global)On-device personalization [33]84.4179.80Agnostic meta learning [34]82.7078.68Mixture models [35]83.5576.45Proposed method87.8583.92


### 4.5. Effect of Global Alignment and Local Alignment

In this subsection, effect of global alignment and local alignment is evaluated. Global alignment and local alignment are two novel operations proposed in our work, which aims to catch the generalization ability of the global model and extract the discrimination ability of local private data. Here, the effect of global alignment and local alignment by assigning them different weights is evaluated.Table6 demonstrates the comparison result. Five parameter settings for wa, wt, and wc are adopted. It can be seen from the table that with the raise of wa, value avg. (local) increases; meanwhile, the value of avg. (global) decreases. There are similar appearances for wt. wa and wt are two parameters to trade off the performance balance between global data and local data. Parameter setting with 0.3, 0.3, and 0.4 obtains the optimal performance.Table 6
Effect of global alignment and local alignment.
wawtwcAvg. (local)Avg. (global)0.50.10.490.560.280.40.20.485.880.70.30.30.487.8583.920.20.40.486.081.10.10.50.480.383.2


### 4.6. Evaluation of Execution Time

In this subsection, personalized model execution time is evaluated. Three CNNs structures with various training batch sizes are tested. Table7 shows that the VGG16 model costs the most execution time, with 1.26 s, 1.67 s, 2.31 s, and 3.74 s for the batch size of 8, 12, 16, and 24 for each training iteration. ResNet-34 gets the least execution time, with about 58% of VGG16’s. For model inference, three models take 0.120 s, 0.076 s, and 0.063 s for testing data, respectively. ResNet-34 is the preferred model for its excellent performance and acceptable cost.Table 7
Execution time (seconds).
Execution timeBatch sizeVGG16Inception-v4ResNet-34Training time81.261.030.97121.671.291.18162.311.851.72243.742.262.15Testing timex0.120.0760.063


## 4.1. Dataset and Experiment Setting

As there are no research studies on personalized federated learning for ECG classification, we construct a specific circumstance to evaluate the proposed algorithm. We collect about 120,000 ECG data from 8 hospitals. Table1 gives the detail description of dataset. Six symptoms such as sinus rhythm, sinus arrhythmia, sinus tachycardia, sinus bradycardia, T-wave alternans, and normal are selected, which are the commonest types and data rich. There are 20201, 18581, 13682, 15854, 14211, and 38524 for types of sinus rhythm, sinus arrhythmia, sinus tachycardia, sinus bradycardia, T-wave alternans, and normal, respectively. Data distributions of each medical institution are also listed in Table 2.Table 1
Dataset used in our experiment.
No.TypeQuantity1Sinus rhythm202012Sinus arrhythmia185813Sinus tachycardia136824Sinus bradycardia158545T-wave alternans142116Sinus normal38524Table 2
Data distributions of each medical institution.
TypeNode1Node2Node3Node4Node5Node6Node7Node8Sinus rhythm29241940230814833610310336451188Sinus arrhythmia24511720189312643171272835131841Sinus tachycardia1913128314071308226221782619712Sinus bradycardia2046152316601418289826652857787T-wave alternans1850129514771227241822602767917Normal55333866392036536652619674731231In our research, each medical institution is corresponded to a local node, and these local nodes provide private data for global training. Hence, the federated learning circumstance is set up.


## 4.2. Base Model Training

The server (global model) employs the FedAvg to train the model globally whereas each local client updates its model locally after successive global aggregations using the SGD style algorithm. The CNN model withResNet-34 is used as the base network structure for both global model and local model.Each experiment is run for 100 global aggregations, withe = 4 epochs for SGD between successive global aggregations. The constant learning rate of 0.01 is used across global aggregations and clients.Table3 gives the classification result of each local node after federated learning. Average classification rate is used as the metric in our work. There are two node types, local and global. The global model has a classification rate of 82.6%. For local nodes, there are two evaluations. Local nodes 1 to 8 obtain the classification rate of 89.48%, 88.76%, 90.25%, 91.54%, 88.31%, 89.57%, 90.18%, and 90.54%, respectively, on their corresponding local private data set. Meanwhile, local nodes 1 to 8 obtain the classification rate of 54.65%, 57.18%, 49.75%, 51.43%, 48.92%, 46.35%, 52.45%, and 50.20%, respectively, on global testing data set. It can be obviously seen that the performance of local models is better than that of global model on private data. Local models get low performance on global data data, with about 30% lower than the global model. These indicate that local models are more preferable to local data, while the global model trained with traditional federated learning framework needs further improvement. Therefore, it is urgent requirement to make model personalization.Table 3
Performance of each local node after federated learning.
Node typeNo.Classification rate (local)Classification rate (global)Local189.4854.65Local288.7657.18Local390.2549.75Local491.5451.43Local588.3148.92Local689.5746.35Local790.1852.45Local890.5450.20Global82.6


## 4.3. Model Personalization Evaluation

In this subsection, the proposed personalization model-based feature alignment is evaluated.The global modelMG′ obtained in the above subsection is first downloaded to each local node, and then the personalized model for each local node is trained on the basis of local data set Dp and MG′. Complying with Section 2, wa, wt, and wc are set with 0.3, 0.3, and 0.4, respectively. Batch size is set with 16, and learning rate is 0.001.Table4 gives the result of model personalization. Column 1 is the node index. Column 2 and 3 are average performance on local data with models of training with only local data and training with personalization. Column 4 and 5 are average performance on global data with models of training with only local data and training with personalization. It can be seen that the performance of model with personalization is decreased with about 3%. This demonstrates that the personalization model is less deviated to distribution of local data. For global testing data, the performance of the model with personalization is greatly increased with about 15–18%. It is a good validation that the personalization model is more generalized.Table 4
Performance of each local node after federated learning.
NodeAvg. (local)Avg. (local with personalization)Avg. (global)Avg. (global with personalization)189.4886.2554.6584.42288.7687.1857.1883.25390.2587.5049.7584.58491.5488.4251.4383.60588.3185.8548.9282.46689.5785.3446.3583.15790.1887.6852.4584.56890.5488.1550.2084.10


## 4.4. Comparisons with Other Methods

In this subsection, some related model personalization methods are compared with our proposed model. We implement algorithms of [31, 34, 35], and the average classification rate on local and global testing data is evaluated.Table5 demonstrates the comparison result. Methods in [33–35] get an average performance of 84.41%, 82.70%, and 83.55% on local node testing data and 79.80%, 78.68%, and 76.45% on global testing data. There are about 4% and 6% compared with our proposed method, and this validates the effectiveness of the proposed personalization framework and feature alignment module.Table 5
Comparisons with other methods.
AlgorithmAvg. (local)Avg. (global)On-device personalization [33]84.4179.80Agnostic meta learning [34]82.7078.68Mixture models [35]83.5576.45Proposed method87.8583.92


## 4.5. Effect of Global Alignment and Local Alignment

In this subsection, effect of global alignment and local alignment is evaluated. Global alignment and local alignment are two novel operations proposed in our work, which aims to catch the generalization ability of the global model and extract the discrimination ability of local private data. Here, the effect of global alignment and local alignment by assigning them different weights is evaluated.Table6 demonstrates the comparison result. Five parameter settings for wa, wt, and wc are adopted. It can be seen from the table that with the raise of wa, value avg. (local) increases; meanwhile, the value of avg. (global) decreases. There are similar appearances for wt. wa and wt are two parameters to trade off the performance balance between global data and local data. Parameter setting with 0.3, 0.3, and 0.4 obtains the optimal performance.Table 6
Effect of global alignment and local alignment.
wawtwcAvg. (local)Avg. (global)0.50.10.490.560.280.40.20.485.880.70.30.30.487.8583.920.20.40.486.081.10.10.50.480.383.2


## 4.6. Evaluation of Execution Time

In this subsection, personalized model execution time is evaluated. Three CNNs structures with various training batch sizes are tested. Table7 shows that the VGG16 model costs the most execution time, with 1.26 s, 1.67 s, 2.31 s, and 3.74 s for the batch size of 8, 12, 16, and 24 for each training iteration. ResNet-34 gets the least execution time, with about 58% of VGG16’s. For model inference, three models take 0.120 s, 0.076 s, and 0.063 s for testing data, respectively. ResNet-34 is the preferred model for its excellent performance and acceptable cost.Table 7
Execution time (seconds).
Execution timeBatch sizeVGG16Inception-v4ResNet-34Training time81.261.030.97121.671.291.18162.311.851.72243.742.262.15Testing timex0.120.0760.063


## 5. Conclusions

This work proposes a novel personalized federated learning method for ECG classification. We explore feature alignment for personalization strategies on both global and local sides. Through experiments on our collected dataset, it shows that personalization benefits the local model with high performance and more generalization. To our knowledge, this is the first evaluation of personalization federated learning for ECG data analysis.Our future works will focus on two aspects: (1) we will make more in-depth research on the personalization method with specific structure and (2) external dataset should be used to improve model performance, such as webly grabbed data [40].



---

*Source: 6217601-2021-11-01.xml*