数据划分
Key changes made:
- 
Split trajectories into train/test before any sampling 
- 
Generate anomalies (detours and switches) using the original non-sampled test trajectories 
- 
Apply sampling rate to the generated anomalies after they're created 
- 
Keep the same sampling approach for train, test, and OOD data 
This modification ensures that:
- 
Anomaly generation uses complete trajectory information 
- 
The sampling rate is consistently applied to all final datasets 
- 
The relative structure of the anomalies is preserved before sampling 
得到的结果,相差是否很大?以西安为例
sample_rates = [1, 0.99, 0.95, 0.92, 0.90]
Results for xian:
==============================
Client client_0:
Training time: 1.37 minutes
Inference time: 2.59 minutes
Total time: 3.96 minutes
Evaluation Metrics:
Normal & Detour - ROC_AUC: 0.7410, PR_AUC: 0.6993
Normal & Switch - ROC_AUC: 0.7998, PR_AUC: 0.7754
OOD & Detour - ROC_AUC: 0.5806, PR_AUC: 0.6753
OOD & Switch - ROC_AUC: 0.6483, PR_AUC: 0.7361
Evaluation time: 0.03 minutes
Client client_1:
Training time: 0.94 minutes
Inference time: 2.34 minutes
Total time: 3.27 minutes
Training completed at: 2024-12-25 23:46:56
Inference completed at: 2024-12-25 23:49:16
Evaluation Metrics:
Normal & Detour - ROC_AUC: 0.6327, PR_AUC: 0.5078
Normal & Switch - ROC_AUC: 0.6616, PR_AUC: 0.5527
OOD & Detour - ROC_AUC: 0.5115, PR_AUC: 0.5666
OOD & Switch - ROC_AUC: 0.5417, PR_AUC: 0.5988
Evaluation time: 0.02 minutes
Client client_2:
Evaluation Metrics:
Normal & Detour - ROC_AUC: 0.5152, PR_AUC: 0.3801
Normal & Switch - ROC_AUC: 0.5509, PR_AUC: 0.3985
OOD & Detour - ROC_AUC: 0.4260, PR_AUC: 0.4795
OOD & Switch - ROC_AUC: 0.4631, PR_AUC: 0.4982
Evaluation time: 0.02 minutes
Client client_3:
Evaluation Metrics:
Normal & Detour - ROC_AUC: 0.5012, PR_AUC: 0.3721
Normal & Switch - ROC_AUC: 0.5502, PR_AUC: 0.4088
OOD & Detour - ROC_AUC: 0.5308, PR_AUC: 0.5529
OOD & Switch - ROC_AUC: 0.5797, PR_AUC: 0.5914
Evaluation time: 0.01 minutes
Client client_4:
Training time: 0.42 minutes
Inference time: 1.91 minutes
Total time: 2.33 minutes
Training completed at: 2024-12-25 23:55:16
Inference completed at: 2024-12-25 23:57:11
Evaluation Metrics:
Normal & Detour - ROC_AUC: 0.4824, PR_AUC: 0.3438
Normal & Switch - ROC_AUC: 0.5304, PR_AUC: 0.3740
OOD & Detour - ROC_AUC: 0.5116, PR_AUC: 0.5309
OOD & Switch - ROC_AUC: 0.5590, PR_AUC: 0.5639
Evaluation time: 0.01 minutes
可以看见采样率取值一般是在0.9-1之间比较合适
2. 然后,再用Fedavg确认效果
System Setup:
- 
The system initializes multiple clients (default is 5) 
- 
Each client gets their own trainer with specific data paths 
- 
All clients share the same model architecture but start with different weights 
- 
Clients have their own local datasets for training and testing 
Training Process:
- 
The training happens in rounds (federated rounds) 
- 
In each round: - 
First, each client trains independently on their local data 
- 
Then, all client models are collected centrally 
- 
The central server averages all model parameters (this is the FedAvg step) 
- 
Finally, all clients receive the averaged model back 
 
- 
Parameter Averaging:
- 
After local training, each client's model parameters are collected 
- 
The system creates an average by: - 
Taking each layer's parameters from all clients 
- 
Computing the mathematical average for each parameter 
- 
Creating a new model with these averaged parameters 
 
- 
- 
This averaged model is then distributed back to all clients 
Exclude road embedding in average:
Most parameters are averaged across clients (VAE, confidence layers, projection heads)
BUT road embeddings are specifically kept local to each client through:
- 
Storing original road embeddings for each client 
- 
Not including them in the averaging process 
- 
Returning them back to their original clients unchanged 
以西安的FedAvg为例,各个客户端使用FedAvg反而下降了,说明直接聚合是不可行的
Client client_0:
Training time: 8.60 minutes
Inference time: 2.65 minutes
Total time: 11.25 minutes
Evaluation Metrics:
Normal & Detour - ROC_AUC: 0.6848, PR_AUC: 0.6206
Normal & Switch - ROC_AUC: 0.7600, PR_AUC: 0.7263
OOD & Detour - ROC_AUC: 0.5455, PR_AUC: 0.6310
OOD & Switch - ROC_AUC: 0.6268, PR_AUC: 0.7111
Evaluation time: 0.04 minutes
Client client_1:
Evaluation Metrics:
Normal & Detour - ROC_AUC: 0.5955, PR_AUC: 0.4640
Normal & Switch - ROC_AUC: 0.6609, PR_AUC: 0.5461
OOD & Detour - ROC_AUC: 0.4926, PR_AUC: 0.5418
OOD & Switch - ROC_AUC: 0.5586, PR_AUC: 0.6050
Client client_2:
Normal & Detour - ROC_AUC: 0.5039, PR_AUC: 0.3612
Normal & Switch - ROC_AUC: 0.5601, PR_AUC: 0.3896
OOD & Detour - ROC_AUC: 0.4298, PR_AUC: 0.4740
OOD & Switch - ROC_AUC: 0.4862, PR_AUC: 0.5030
Client client_3:
Normal & Detour - ROC_AUC: 0.4737, PR_AUC: 0.3356
Normal & Switch - ROC_AUC: 0.5273, PR_AUC: 0.3672
OOD & Detour - ROC_AUC: 0.5216, PR_AUC: 0.5350
OOD & Switch - ROC_AUC: 0.5744, PR_AUC: 0.5708
Evaluation time: 0.04 minutes
Client client_4:
Normal & Detour - ROC_AUC: 0.4614, PR_AUC: 0.3180
Normal & Switch - ROC_AUC: 0.5204, PR_AUC: 0.3524
OOD & Detour - ROC_AUC: 0.5107, PR_AUC: 0.5238
OOD & Switch - ROC_AUC: 0.5678, PR_AUC: 0.5638
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号