Early Stopping Implementation

Hello

a option could be to implement a new class e.g.

class EarlyStoppingStrategy(fl.server.strategy.FedAvg):                                                          
    def __init__(self, patience, target_metric):
        super().__init__()
        self.patience = patience
        self.target_metric = target_metric   # mainly the loss or someting else e.g. accuracy, f1score...                                                                                
        self.beset_metric = 0  
        self.counter = 0                                                                                                                   

    def aggregate_evaluate(self, server_round, results, failures):
        aggregated_metrics = super().aggregate_evaluate(server_round, results, failures)
        if server_round == 1:
            if self.target_metric in aggregated_metrics:
                self.best_metric = aggregated_metrics[self.target_metric]                                           
        else:
            if self.target_metric in aggregated_metrics:
                current_metric =  aggregated_metrics[self.target_metric]                                                                        
                if current_metric > self.best_metric:
                    self.best_metric = current_metric
                    self.counter = 0
                else:
                    self.counter += 1  
                if self.counter >= self.patience: 
                    return aggregated_metrics
            return aggregated_metrics

The question remains how to stop training. Maybe if you set your server_round to your selected server_round. There is certainly an optimal solution