Abstract: Federated learning (FL) is an effective solution to train machine learning models on the increasing amount of data generated by IoT devices and smartphones while keeping such data localized. Most previous work on federated learning assumes that clients operate on static datasets collected before training starts. This approach may be inefficient because it ignores new samples clients collect during training and may require a long preparatory phase. Moreover, learning on static datasets may be impossible in scenarios with small aggregate storage. We formulate and study the problem of federated learning for data streams, proposing a general FL algorithm that utilizes weighted empirical risk minimization. Our theoretical analysis provides insights to configure such an algorithm, and we evaluate its performance on a wide range of machine learning tasks.
Introduction
Federated Learning (FL) allows multiple decentralized edge devices to collaboratively train a machine learning model without sharing raw data. However, most FL research operates under the assumption that clients have static datasets collected before training begins. In reality, devices like environmental sensors or smartphones continuously generate new data streams. Due to limited storage, these devices must constantly overwrite old data with new samples.
Standard algorithms like FedAvg struggle in these dynamic environments. They either inefficiently ignore valuable new samples or fail to learn when devices can only store a small number of samples at any given time. This paper addresses the challenge of optimally training a global model when clients learn from continuous, memory-constrained data streams.
Methodology: Weighted Empirical Risk Minimization
To address the streaming nature of data, the authors propose a meta-algorithm that minimizes a weighted empirical risk. Instead of treating every data point equally, the algorithm assigns weights to samples based on their age in memory and their origin across different clients. The core of this approach is a mathematical decomposition of the overall model error into two components:
- Generalization Error (Bias): How well the data currently in memory represents the true underlying distribution.
- Optimization Error (Variance): How efficiently the algorithm minimizes the loss function, which is affected by gradient noise.
In a "fog computing" scenario with Historical clients (static datasets) and Fresh clients (streaming data), the algorithm uses a heuristic to estimate the ratio $c_2/c_1$. This ratio determines the optimal "importance weight" ($p^*_{hist}$) for historical versus fresh data. As shown in Figure 1, when the noise/variance cost ($c_2$) is high relative to the bias cost ($c_1$), the algorithm correctly places more weight on the stable historical data to stabilize training.
Experimental Evaluation
The framework was evaluated using several standard benchmarks:
- CIFAR-10 & CIFAR-100: Image classification with simulated data heterogeneity.
- FEMNIST: Handwritten character recognition partitioned by writer.
- Shakespeare: Language modeling partitioned by speaking roles.
- Synthetic Data: Custom datasets for logistic regression analysis.
Key Results and Discussion
A fundamental insight of this work is the Bias-Optimization Trade-off. Prioritizing older, stored samples reduces gradient variance (speeding up optimization) but increases model bias. Conversely, focusing only on the newest samples reduces bias but introduces massive gradient noise.
As illustrated in Figure 3, naive adaptations of FedAvg—such as weighting clients uniformly or based solely on current memory—often lead to suboptimal performance. The proposed dynamic weighting heuristic consistently matched or outperformed these baselines.
On CIFAR-10, the proposed method achieved 66.9% accuracy, significantly beating the "Fresh only" (59.6%) and "Uniform" (61.5%) strategies. On FEMNIST and Shakespeare, the algorithm correctly identified that incorporating fresh data would introduce too much noise, auto-configuring itself to prioritize historical data and maintaining superior accuracy (66.1% and 49.0%, respectively).
Conclusion
This research demonstrates that learning from data streams in a federated setting requires a careful balance between bias and variance. By dynamically weighting historical and fresh data, the proposed framework allows FL to adapt to the constraints of real-world IoT environments. Future work will explore non-stationary distributions (concept drift) and more complex memory eviction policies beyond simple FIFO rules.
Summary updated