Personalized federal learning human body behavior recognition method based on statistical feature clustering
By calculating the statistical characteristics of client model parameters and using the K-means algorithm for dynamic clustering, the problem of poor generalization and personalization performance in the Non-IID data environment is solved, and more efficient clustering clustering and better human behavior recognition performance are achieved.
Patent Information
- Application Number
- CN202411781117.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-28
AI Technical Summary
When existing federated learning methods deal with non-independent homogeneous data, it is difficult to effectively cluster clients, calculate similarity, and select appropriate aggregation strategies, resulting in poor generalization and personalization performance of the model in human behavior recognition tasks.
By calculating the statistical characteristics of client model parameters, the K-means algorithm is used for dynamic clustering, the clustering results are obtained and the cluster model of each cluster is calculated, and the client's personalized model is updated to achieve more efficient clustering clustering.
The generalization and personalized performance of the model under the Non-IID data distribution is improved, and the similarity between clients is measured more accurately. The dynamic clustering mechanism can flexibly adjust cluster allocation, improving the performance of human behavior recognition tasks.
Smart Images

Figure CN119719829A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of human behavior recognition in a federated learning environment, and in particular relates to a personalized federated learning human behavior recognition method based on statistical feature clustering. Background Art
[0002] In today's data-driven smart devices and health monitoring applications, human activity recognition (HAR) has become a core technology in the field of smart wearable devices. However, in these application scenarios, traditional centralized learning methods often require a large amount of personal data to be uploaded to the central server for training, which poses data privacy and security risks. Therefore, federated learning (FL), as a distributed training framework, provides a solution for privacy protection. However, federated learning still faces significant challenges when dealing with non-independent and identically distributed (Non-IID) data. In response to the challenges of Non-IID data distribution, personalized federated learning (PFL) has gradually developed into an important method to improve model accuracy and generalization. PFL can allocate clients to appropriate clusters through clustering and personalized model design, thereby improving the generalization ability of the model. However, the current personalized federated learning method still lacks effective design and implementation based on the above-mentioned existing technology analysis in terms of how to cluster clients, calculate similarity, and select appropriate aggregation strategies. There is an urgent need for a new personalized federated learning method to more accurately measure the similarities between clients and realize dynamic clustering, so as to improve the generalization and personalization performance of the model under Non-IID data distribution, so as to more effectively cope with the HAR task requirements in practical applications. Summary of the invention
[0003] To solve the above technical problems, the present invention proposes a personalized federated learning human behavior recognition method based on statistical feature clustering, which calculates the similarity through the statistical characteristics of the client model parameters to achieve more efficient clustering, thereby obtaining better performance in non-independent and identically distributed human behavior recognition tasks with strong personalization requirements.
[0004] To achieve the above object, the present invention provides a personalized federated learning human behavior recognition method based on statistical feature clustering, comprising:
[0005] S1. Obtain a human behavior recognition data set, and preprocess the human behavior recognition data set to divide it into a training set and a test set;
[0006] S2. Initialize the global model and deploy the parameters of the global model to the local model and personalized model of the client;
[0007] S3, using the training set to train and update the client local model;
[0008] S4, obtaining the updated statistical features of the client local model parameters, clustering the statistical features, and obtaining clustering results;
[0009] S5. Calculate a cluster model of each cluster according to the clustering result, and update the personalized model of the client based on the cluster model;
[0010] S6. Repeat S3-S5 until the preset communication round is reached to obtain a trained personalized model;
[0011] S7. Performing a human behavior recognition task based on the trained personalized model.
[0012] Optionally, stochastic gradient descent is used to minimize the loss function when training the client local model using the training set.
[0013] Optionally, the stochastic gradient descent minimization loss function adopts a cross entropy loss function, and the cross entropy loss function is:
[0014]
[0015] Among them, C represents the total number of categories, y i,c is an indicator function indicating whether sample i belongs to category C. is the probability that the customer model assigns sample i to category C.
[0016] Optionally, a K-means algorithm is used when clustering the statistical features.
[0017] Optionally, the K-means algorithm performs clustering by calculating the Euclidean distance of the client local model parameters, wherein calculating the Euclidean distance includes:
[0018] The Euclidean distance between a data point X and the centroid C is calculated as:
[0019]
[0020] Where n is the dimension of the data;
[0021] The cluster centers are updated to:
[0022]
[0023] Among them, S is the set of all samples assigned to the cluster, and |S| is the number of samples in the sample set.
[0024] Optionally, the cluster model is obtained by weighted averaging local model parameters of clients within the cluster.
[0025] Optionally, the updating of the personalized model includes:
[0026]
[0027] in, is the personalized model of the kth client at round t+1, is the personalized model of the kth client in round t, η is the learning rate, ▽L k (.) is the gradient of the kth client, λ is the regularization coefficient, is the c-th cluster model at round t.
[0028] Optionally, the client recalculates statistical features based on the latest local model parameters before each round of clustering, wherein the statistical features include peak frequency average, percentile and median absolute deviation;
[0029] The peak frequency average is calculated as:
[0030]
[0031] Where N is the number of segments, f peak,i is the peak frequency of the ith segment;
[0032] The percentile is calculated as:
[0033]
[0034] Where p is the percentage sought and n is the total number of data points;
[0035] The median absolute deviation is calculated as:
[0036] MAD=median(x i -median(x)),
[0037] Among them, x i Represents each element in the data set, and median(x) is the median of the entire data set.
[0038] Technical effect of the present invention: The present invention discloses a personalized federated learning human behavior recognition method based on statistical feature clustering, obtains a human behavior recognition data set, and pre-processes the human behavior recognition data set to divide it into a training set and a test set; initializes a global model, and deploys the parameters of the global model to the local model and personalized model of the client; trains and updates the local model of the client, and adopts stochastic gradient descent to minimize the loss function; evaluates the difference between the predicted value of the local model of the client and the actual label by selecting the cross entropy loss function; based on the statistical characteristics of the local model parameters of the client, dynamically clusters the client using the K-means algorithm to obtain a clustering result; according to the clustering result, calculates the cluster model of each cluster, and updates the personalized model of the client based on the cluster model; repeats the dynamic clustering, cluster model calculation and personalized model update steps until the preset communication round is reached to obtain a trained personalized model; performs a human behavior recognition task based on the trained personalized model. Calculate similarity through the statistical characteristics of the client model parameters to achieve more efficient clustering, thereby obtaining better performance in the Non-IID human behavior recognition task. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0040] Figure 1 A flowchart of a personalized federated learning human behavior recognition method based on statistical feature clustering according to an embodiment of the present invention;
[0041] Figure 2 This is a flow chart of the PC-PFL method according to an embodiment of the present invention;
[0042] Figure 3 It is a schematic diagram of dynamic clustering of 7 sets of IMU data based on percentile statistical features according to an embodiment of the present invention;
[0043] Figure 4 This is a curve diagram of the accuracy of PC-PFL under different numbers of clusters according to an embodiment of the present invention. DETAILED DESCRIPTION
[0044] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0045] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0046] like Figure 1 As shown, this embodiment provides a personalized federated learning human behavior recognition method based on statistical feature clustering, including:
[0047] Obtaining a human behavior recognition data set, and preprocessing the human behavior recognition data set to divide it into a training set and a test set;
[0048] Initialize the global model, and deploy the parameters of the global model to the local model and personalized model of the client;
[0049] Train and update the client local model, using stochastic gradient descent to minimize the loss function;
[0050] The difference between the client-side local model prediction and the actual label is evaluated by selecting the cross entropy loss function;
[0051] Based on the statistical characteristics of the client's local model parameters, the K-means algorithm is used to dynamically cluster the clients to obtain clustering results;
[0052] According to the clustering result, a cluster model of each cluster is calculated, and a personalized model of the client is updated based on the cluster model;
[0053] Repeat the steps of dynamic clustering, cluster model calculation and personalized model update until a preset communication round is reached to obtain a trained personalized model;
[0054] A human behavior recognition task is performed based on the trained personalized model.
[0055] Furthermore, the ratio of the training set to the test set of the human action recognition dataset is 4:1.
[0056] Furthermore, the loss function minimized using stochastic gradient descent includes:
[0057]
[0058] Among them, η is the preset learning rate, is the local model gradient with respect to batch b.
[0059] Furthermore, the cross entropy loss function is defined as:
[0060]
[0061] Among them, C represents the total number of categories, y i,c is an indicator function indicating whether sample i belongs to category C. is the probability that the customer model assigns sample i to category C.
[0062] Furthermore, the K-means algorithm is used for clustering: After obtaining the calculated statistical features, the K-means algorithm is used to cluster the clients according to these features, where the number of clusters C is preset according to the needs. K-means is a widely used clustering algorithm that minimizes the variance within each cluster by assigning data to C clusters. The algorithm first randomly selects C initial centroids, and then iteratively performs two key steps: assigning each data point to the nearest centroid based on the Euclidean distance, and updating the centroid based on the mean of the points assigned to each cluster.
[0063] The K-means algorithm performs clustering by calculating the Euclidean distance of the client local model parameters, wherein calculating the Euclidean distance includes:
[0064] The Euclidean distance between a data point X and the centroid C is calculated as:
[0065]
[0066] Where n is the dimension of the data;
[0067] The cluster centers are updated to:
[0068]
[0069] Among them, S is the set of all samples assigned to the cluster, and |S| is the number of samples in the sample set.
[0070] Furthermore, the cluster model is obtained by weighted average calculation of local model parameters of the clients in the cluster.
[0071] Furthermore, the updating of the personalized model includes:
[0072]
[0073] in, is the personalized model of the kth client at round t+1, is the personalized model of the kth client in round t, η is the learning rate, ▽L k (.) is the gradient of the kth client, λ is the regularization coefficient, is the c-th cluster model at round t.
[0074] Furthermore, the client recalculates statistical features based on the latest local model parameters before each round of clustering, wherein the statistical features include peak frequency average, percentile and median absolute deviation;
[0075] Average Peak Frequency (Apf): The average value of the peak frequencies in the signal. This metric can help capture the overall trend of the signal's frequency distribution. Percentiles: Percentiles are numerical values that represent the percentage of data less than this value in the total data. For example, if the 25th percentile of a set of data is 50, this means that 25% of the data values are less than or equal to 50. Calculating percentiles usually involves sorting the data set, determining the position k of the pth percentile, where p is the percentage sought and n is the total number of data points. If k is not an integer, the percentile is obtained by interpolating the values at the kth and k+1th positions. Such calculations help understand the distribution and extreme values of the data. Median Absolute Deviation (Mad): It is a robust statistic used to measure the difference between each value in a set of data and the median. It is calculated by subtracting the median of the entire data set from each observation, taking the absolute value of these differences, and then calculating the median of these absolute differences.
[0076] The peak frequency average is calculated as:
[0077]
[0078] Where N is the number of segments, f peak,i is the peak frequency of the ith segment;
[0079] The percentile is calculated as:
[0080]
[0081] Where p is the percentage sought and n is the total number of data points;
[0082] The median absolute deviation is calculated as:
[0083] MAD=median(x i -median(x)),
[0084] Among them, x i Represents each element in the data set, and median(x) is the median of the entire data set.
[0085] Furthermore, the method is applicable to Non-IID distribution data scenarios, especially in the fields of health monitoring and behavior analysis.
[0086] A specific application example of the present invention is:
[0087] like Figure 1 FIG. 1 is a schematic diagram of the method flow of this embodiment, and the steps include:
[0088] S1, selection and preprocessing of human action recognition dataset, and division into training set and test set.
[0089] In this embodiment, four public datasets are selected for preprocessing, namely, IMU dataset, HARBox dataset, WISDM dataset and UWB dataset.
[0090] The IMU (Inertial Measurement Unit) dataset is a sensor dataset for gait recognition. The data comes from inertial measurement units worn on different parts of the human body (such as wrists, waists, ankles, etc.). These sensors record the acceleration and angular velocity data generated by the human body during walking. The dataset contains data from three walking activities (walking in the corridor, going upstairs, and going downstairs) of 7 volunteers. A sampling frequency of 50 Hz and a window size of 2 seconds are used, and the data is split into training and test sets in a ratio of 4:1.
[0091] HARBox Dataset is a large dataset for human action recognition, designed to capture and analyze a variety of activities in daily life, which can be downloaded at https: / / github.com / xmouyang / FL-Datasets-for-HAR. The dataset is collected through the Android application "HARBox", which records the 9-axis IMU data of users when they perform five activities (walking, jumping, talking on the phone, waving, and typing). The data collection is crowdsourced, with a total of 121 users participating, using 77 different models of smartphones. The raw IMU data is collected at a sampling rate of 50Hz, each data sample covers a 2-second time window, generates a 900-dimensional feature vector, and splits the data in a 4:1 manner. This dataset is particularly suitable for evaluating the scalability and robustness of human activity recognition algorithms due to its large scale, diverse users and diverse devices.
[0092] WISDM (Wireless Sensor DataMining) is a widely used human behavior recognition dataset created by the WISDM laboratory of Fordham University and can be downloaded at https: / / www.cis.fordham.edu / wisdm / dataset.php. The dataset contains activity data collected by 36 volunteers through the accelerometer and gyroscope in Android phones, covering six activities: walking, jogging, sitting, standing, going upstairs, and going downstairs. Based on previous research experience, a sampling frequency of 20Hz and a window size of 10 seconds are used, and the data is split in a ratio of 4:1.
[0093] UWB (Ultra Wide Band) is an ultra-wideband sensing system based on radar technology. The dataset for human behavior recognition can be downloaded at https: / / github.com / xmouyang / FL-Datasets-for-HAR. In this dataset, two UWB radars with a spacing of 3 meters are deployed in three different environments: parking lots, corridors, and rooms to detect human motion. The dataset contains eight subjects, each of whom walks randomly in a specified area for 10 minutes. The data is collected at a sampling rate of 5Hz using two-way ranging technology, and is manually annotated and segmented at a ratio of 4:1.
[0094] S2, builds a personalized federated learning method PC-PFL based on the processed data.
[0095] For ease of reading, Table 1 lists important symbols and gives their explanations.
[0096] The PC-PFL method proposed in the present invention is characterized in that each client has two models, a local model w l , a personalized model v. This method clusters by analyzing the statistical characteristics of the client's local model parameters, and the obtained cluster model guides the update of the personalized model of the client in this cluster.
[0097] Table 1
[0098]
[0099] The complete process of PC-PFL is as follows Figure 2 As shown, the following are the steps in a typical communication round, taking client k in communication round t as an example:
[0100] (1) Global model initialization: Initialize the global model parameters initialization.
[0101] (2) Model parameter deployment: At communication round t = 1, the global model Deploy parameters to the client's local model and personalized models In subsequent communication rounds, the cluster model is used Deploy model parameters for local models within the same cluster.
[0102] (3) Local model training and updating: The client uses its local data to perform E generations of parallel training and applies stochastic gradient descent (SGD) to minimize the loss function L, as shown in Equation (1).
[0103]
[0104] Where η is the preset learning rate, is the local model gradient with respect to batch b.
[0105] (4) Choice of loss function: The cross entropy loss function is selected to evaluate the difference between the customer model prediction value and the actual label. This loss function is very suitable for multi-classification problems. The cross entropy loss is defined as
[0106]
[0107] In the formula, C represents the total number of categories, y i,c is an indicator function indicating whether sample i belongs to category C, y i,c is the probability that the customer model assigns sample i to category C.
[0108] (5) Calculate local model parameter statistical indicators: After each model parameter update, the calculated statistical indicators are marked as
[0109] A variety of statistical features were compared on the WISDM dataset, and the experimental results are shown in Table 2. According to the data in Table 2, the three statistical indicators of Average Peak Frequency (APF), Percentiles, and Median Absolute Deviation (MAD) showed the highest accuracy in all comparisons, and were therefore selected as the main features for analysis and further clustering of client model parameters in subsequent experiments. The three statistical indicators are defined as follows:
[0110] Table 2
[0111]
[0112]
[0113] 1) Average Peak Frequency (Apf): The average value of the peak frequency in the signal. This indicator can help capture the overall trend of the signal frequency distribution.
[0114]
[0115] Where N is the number of segments, f peak,i is the peak frequency of the ith segment.
[0116] 2) Percentiles: A percentile is a numerical value that represents the percentage of data less than this value in the total data. For example, if the 25th percentile of a set of data is 50, it means that 25% of the data values are less than or equal to 50. Calculating percentiles usually involves sorting the data set and using formula (4) to determine the position k of the pth percentile, where p is the percentage sought and n is the total number of data points. If k is not an integer, the percentile is obtained by interpolating the values of the kth and k+1th positions. Such calculations help understand the distribution and extreme values of the data.
[0117]
[0118] 3) Median Absolute Deviation (Mad): It is a robust statistic used to measure the difference between each value in a set of data and the median. Its calculation formula is to subtract the median of the entire data set from each observation, take the absolute value of these differences, and then calculate the median of these absolute differences. The calculation formula is shown in (5).
[0119] MAD=median(x i -median(x)) (5)
[0120] where x i Represents each element in the data set, and median(x) is the median of the entire data set. MAD is a method to measure data variability, especially when there are outliers in the data, it is more robust than the standard deviation.
[0121] (6) Clustering using the K-means algorithm: After obtaining the calculated statistical features, the K-means algorithm is used to cluster the clients based on these features, where the number of clusters C is preset according to demand.
[0122] K-means is a widely used clustering algorithm that assigns data to C clusters to minimize the variance within each cluster. The algorithm first randomly selects C initial centroids and then iteratively performs two key steps: assigning each data point to the nearest centroid based on Euclidean distance and updating the centroid based on the mean of the points assigned to each cluster.
[0123] Specifically, the Euclidean distance calculation formula between the data point X and the centroid C is shown in (6).
[0124]
[0125] Where n is the dimension of the data. The cluster center is updated as:
[0126]
[0127] Among them, S is the set of all samples assigned to the cluster, and |S| is the number of samples in the set. In this way, the K-means algorithm aims to minimize the sum of the distances between the samples in the cluster and their cluster centers, thus achieving effective clustering of data.
[0128] (7) Calculate cluster model: Obtain the cluster model in each cluster according to the previously set aggregation algorithm. For specific methods, please refer to the paper (Wen X, Wang Y, Yuan M, et al. Enhancing Human Activity Recognition with FedPA: Focusing on Non-IID Data Challenges in Federated Learning [J]. IEEE Sensors Journal, 2024.).
[0129] (8) Updating the personalized model: In the personalized federated learning (PC-PFL) method of the present invention, each client has two models at the same time: a local model and a personalized model. This method is designed to improve the overall performance of the model through joint learning in the cluster while ensuring the personalization of the model. The method of updating the personalized model reflects the balance of two main goals: one is to optimize the personalized performance of the user, and the other is to reduce the deviation between the user model and the cluster model.
[0130] Specifically, the update of the personalized model follows the following instructions:
[0131]
[0132] This update announcement shows a trade-off mechanism: by adjusting the size of λ, the importance between personalization needs and group consistency can be controlled. When λ = 0, the model is trained entirely based on the client's local data and is completely personalized; as the value of λ increases, the personalized model tends to be more and more clustered, enhancing the model's adaptability to the entire cluster data. This approach allows each client to benefit from the knowledge shared by the cluster while maintaining a certain degree of personalization, which is particularly important for dealing with federated learning environments with uneven data distribution.
[0133] (9) After the personalized model is updated, continue to loop step 2 to step 8 until the maximum communication round is reached. Since the statistical characteristics of the client model parameters are calculated in each round for clustering, the cluster distribution in each round is re-clustered based on the latest trained model parameters of the client in this round, realizing the dynamic clustering process to achieve the optimal cluster distribution.
[0134] S3, using the constructed PC-PFL method to complete human behavior recognition.
[0135] (1) Hyperparameter settings: The learning rate is 0.01, and the number of generations of local training is 2. For the batch size, it is set to 32 for the WISDM and HARBox datasets, and to 5 for the IMU and UWB datasets. In terms of the number of clusters, the WISDM dataset is set to 4 clusters, the IMU and UWB datasets are set to 3 clusters, and the HARBox dataset is set to 10 clusters. In the baseline experiment and the supplementary experiment, the consistency of the hyperparameter settings is maintained to ensure the fairness of the experimental comparison.
[0136] (2) Model setup: A two-dimensional convolutional neural network model was selected for training. Its structure is as follows: The model accepts input data with multiple channels, which first passes through two convolutional layers and a pooling layer for feature extraction and downsampling. Each convolutional layer is followed by a ReLU activation function and then a maximum pooling layer. Next, the output of the convolutional layer is flattened, and further feature transformation is performed through a fully connected layer, and finally the classification result is output through another fully connected layer.
[0137] (3) Accuracy setting: In the present invention, the personalized model of each client is tested on its local test set to obtain the accuracy of that round. At the same time, in order to evaluate the generalization ability of the model, the personalized model of each client is tested on the set of all client test sets to obtain the generalization accuracy.
[0138] (4) Baseline method: In order to better reflect the performance of PC-PFL, the base model FedCHAR method (LiY, Wang X, An L. Hierarchical clustering-based personalized federated learning for robust and fair human activity recognition [J]. Proceedings of the ACM on Interactive, Mobile, Wearable and Ubiquitous Technologies, 2023, 7(1): 1-38.) was selected to perform behavior recognition under the same experimental conditions and make comparisons.
[0139] The FedCHAR method clusters users based on the cosine distance of the client model update direction. This method performs clustering by calculating the cosine similarity between the model update parameters uploaded by each client, thereby measuring the similarity of the model update direction between users. Cosine distance is a method to measure the similarity of the direction of two vectors, and its value ranges from -1 to 1, where 1 means the vectors are exactly the same, -1 means they are completely opposite, and 0 means they are orthogonal and have no correlation.
[0140] In the FedCHAR framework, the server first receives model parameter updates from each client, and then calculates the cosine similarity between these parameter updates. Through this similarity analysis, the server can cluster clients with similar update directions into the same cluster. This clustering method based on data distribution similarity helps the model to perform more targeted training within each cluster, thereby improving the overall performance and personalized adaptability of the model.
[0141] Although FedCHAR clusters data using cosine distance, which can capture similarities between users to a certain extent, this method may not be sensitive enough to dynamic changes in user behavior. Over time, user behavior patterns may change, making existing clusters no longer suitable for the new data distribution. In this case, re-clustering may be required to adapt to changes in user behavior, but this will bring additional complexity and processing delays.
[0142] (5) Comparison of experimental results of PC-PFL and FedCHAR methods: In this embodiment, the performance comparison of PC-PFL and FedCHAR methods on different data sets is shown in Table 3. The experiment covers four data sets: IMU, HARBox, WISDM, and UWB, and conducts detailed evaluations on different statistical features (Apf, Percentiles, Mad). As can be seen from Table 3, PC-PFL shows higher accuracy on multiple data sets, especially in IMU and HARBox data sets.
[0143] Table 3
[0144]
[0145] In the IMU dataset, PC-PFL combined with percentile features achieved the highest values of 99.26% and 99.01% in accuracy and generalization accuracy, respectively, which is significantly better than FedCHAR's 98.54% and 97.93%. In addition, PC-PFL only needs 60 rounds of communication to achieve a generalization accuracy of 99.01%, while FedCHAR needs 272 rounds, demonstrating the significant advantage of PC-PFL in convergence speed.
[0146] In the HARBox dataset, PC-PFL outperforms FedCHAR in all statistical features, especially the percentile feature, where PC-PFL's accuracy reaches 95.39%, exceeding FedCHAR's 92.40%. PC-PFL can achieve this accuracy after 48 rounds of communication, while FedCHAR needs 98 rounds, which also reflects PC-PFL's advantage in communication efficiency.
[0147] For the WISDM dataset, the accuracy of each statistical feature is better than PC-PFL, but the percentiles and median absolute deviations are slightly inferior in terms of generalization accuracy. In the UWB dataset, PC-PFL also outperforms FedCHAR in terms of accuracy, optimal communication rounds, generalization accuracy, and generalized optimal communication rounds under each feature, with the highest accuracy and generalization accuracy exceeding 10.15% and 16.59% respectively.
[0148] In summary, PC-PFL shows better adaptability than FedCHAR on the four data sets, especially when dealing with complex statistical features, its higher accuracy and generalization performance make it a more effective method.
[0149] Since the IMU dataset has only 7 clients, the dynamic clustering diagram drawn is more intuitive and easy to understand. In addition, the experimental results show that in the IMU dataset, the PC-PFL model based on percentile statistical features has the highest accuracy. Figure 3 The figure shows the dynamic clustering diagram of each client when conducting experiments based on percentile statistical features in the IMU dataset.
[0150] from Figure 3 As can be seen in the figure, in the first round, clients 1 and 7 were assigned to the same cluster, clients 2, 3, and 4 were assigned to another cluster, and clients 5 and 6 formed the third cluster. In the second round, the clustering was adjusted, for example, clients 1 and 5 were assigned together. It can be clearly seen that the distribution state of the clients in each cluster has changed dynamically, and this adjustment is particularly frequent in the first few rounds. However, as the training progresses, the clustering state of the clients gradually stabilizes, and the accuracy of the model continues to improve and is close to convergence. This shows that the dynamic clustering mechanism of PC-PFL can flexibly adjust the allocation of clusters in the early stage to find the optimal clustering strategy and ultimately improve the model performance.
[0151] (6) Results of PC-PFL with different cluster numbers: The number of clusters is a pre-set hyperparameter, and a large number of experiments were conducted to obtain the results. Figure 4 The experimental results show that the PC-PFL method has different model accuracy performance under different cluster number settings. By analyzing four data sets (IMU, HARBox, WISDM and UWB), it can be observed that the number of clusters has a significant impact on the performance of the personalized model.
[0152] In the IMU and HARBox datasets, when the number of clusters is small, the overall accuracy is high, indicating that in these datasets, aggregating users into larger clusters helps the model share information within the cluster, thereby improving the performance of the personalized model. However, as the number of clusters increases, the accuracy gradually decreases, indicating that excessive division may cause clients with high similarity to be dispersed into different clusters, reducing the aggregation effect.
[0153] In the WISDM and UWB datasets, a smaller number of clusters can also achieve higher accuracy, which means that in these datasets, the personalized model is also more inclined to benefit from the aggregation of fewer clusters. However, as the number of clusters increases further, especially in the UWB dataset, the accuracy drops significantly, indicating that the reduction in the number of users in the cluster has a negative impact on the model performance.
[0154] In summary, for different data sets, the appropriate number of clusters can effectively improve the performance of the personalized model of the PC-PFL method. Selecting a smaller number of clusters helps to share information more effectively within the cluster and avoid performance degradation caused by data heterogeneity, but it is also necessary to prevent information loss caused by too few clusters.
[0155] (7) Comparison between PC-PFL and FedAvg: FedAvg is a traditional aggregation algorithm. PC-PFL uses the FedAvg aggregation algorithm by default to generate cluster models. Therefore, by comparing PC-PFL+FedAvg with the single aggregation algorithm FedAvg, we can reflect the advantages of adding the PC-PFL method. Table 4 summarizes the performance comparison between PC-PFL and the traditional FedAvg method.
[0156] Experimental results on multiple data sets show that the PC-PFL framework significantly outperforms the traditional FedAvg aggregation algorithm in both performance and training speed by introducing a clustering mechanism. Although both use the same aggregation algorithm, the advantage of PC-PFL is that its personalized aggregation strategy can better adapt to the heterogeneity of client data.
[0157] In Table 4, first, on the IMU and HARBox datasets, the percentile statistical feature method in PC-PFL achieved an accuracy of 99.26% and 95.39% respectively, which is about 2% to 15% higher than FedAvg. This significant performance improvement shows that the clustering mechanism of PC-PFL can better handle the diversity of client data, thereby improving the generalization ability of the model.
[0158] Table 4
[0159]
[0160] Secondly, on the WISDM dataset, the PC-PFL method based on the average of the peak frequency (Apf) achieved an accuracy of 95.67%, significantly better than FedAvg's 92.35%. Not only that, PC-PFL also performed well in terms of training speed. For example, the method based on the median absolute deviation (Mad) achieved an accuracy of 95.20% in only 37 rounds, while the FedAvg method required 199 rounds to reach 92.35%. This shows that the PC-PFL method can more effectively utilize the client data features and converge to better results in a shorter time.
[0161] In addition, on the UWB dataset, the PC-PFL method based on the average value of peak frequency (Apf) also achieved the highest accuracy of 94.85%, while the accuracy of FedAvg was only 83.21%. This difference further verifies the effectiveness of the clustering strategy in PC-PFL, which improves the overall model performance through personalized aggregation.
[0162] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A personalized federated learning human behavior recognition method based on statistical feature clustering, comprising: S1. Obtain a human behavior recognition data set, and preprocess the human behavior recognition data set to divide it into a training set and a test set; S2. Initialize the global model and deploy the parameters of the global model to the local model and personalized model of the client; S3, using the training set to train and update the client local model; S4, obtaining the updated statistical features of the client local model parameters, clustering the statistical features, and obtaining clustering results; S5. Calculate a cluster model of each cluster according to the clustering result, and update the personalized model of the client based on the cluster model; S6. Repeat S3-S5 until the preset communication round is reached to obtain a trained personalized model; S7. Performing a human behavior recognition task based on the trained personalized model.
2. The personalized federated learning human behavior recognition method based on statistical feature clustering as claimed in claim 1, characterized in that: When the client local model is trained using the training set, stochastic gradient descent is used to minimize the loss function.
3. The personalized federated learning human behavior recognition method based on statistical feature clustering as claimed in claim 2, characterized in that: The stochastic gradient descent minimization loss function adopts a cross entropy loss function, and the cross entropy loss function is: Among them, C represents the total number of categories, y i,c is an indicator function indicating whether sample i belongs to category C. is the probability that the customer model assigns sample i to category C.
4. The personalized federated learning human behavior recognition method based on statistical feature clustering as claimed in claim 1, characterized in that: The K-means algorithm is used to cluster the statistical features.
5. The personalized federated learning human behavior recognition method based on statistical feature clustering as claimed in claim 4, characterized in that: The K-means algorithm performs clustering by calculating the Euclidean distance of the client local model parameters, wherein calculating the Euclidean distance includes: The Euclidean distance between a data point X and the centroid C is calculated as: Where n is the dimension of the data; The cluster centers are updated to: Among them, S is the set of all samples assigned to the cluster, and |S| is the number of samples in the sample set.
6. The personalized federated learning human behavior recognition method based on statistical feature clustering as claimed in claim 1, characterized in that: The cluster model is obtained by weighted average calculation of local model parameters of the clients in the cluster.
7. The personalized federated learning human behavior recognition method based on statistical feature clustering as claimed in claim 1, characterized in that: The updating of the personalized model includes: in, is the personalized model of the kth client at round t+1, is the personalized model of the kth client in round t, η is the learning rate, is the gradient of the kth client, λ is the regularization coefficient, is the c-th cluster model at round t.
8. The personalized federated learning human behavior recognition method based on statistical feature clustering as claimed in claim 1, characterized in that: The client recalculates statistical features based on the latest local model parameters before each round of clustering, wherein the statistical features include peak frequency average, percentile and median absolute deviation; The peak frequency average is calculated as: Where N is the number of segments, f peak,i is the peak frequency of the ith segment; The percentile is calculated as: Where p is the percentage sought and n is the total number of data points; The median absolute deviation is calculated as: MAD=median(x i -median(x)), Among them, x i Represents each element in the data set, and median(x) is the median of the entire data set.