This European patent describes a method for training a machine learning model, particularly in the context of communication networks like 5G. The primary focus is to improve the accuracy of machine learning models trained using federated learning (FL) by addressing the issue of data heterogeneity among the FL clients. The proposed method involves determining the similarity between the federated learning server's test data and the clients' training data and using this determination to decide whether or not to incorporate a client's model update into the global model.