Real-time data stream processing presents a significant challenge in the rapidly changing Internet of Things (IoT) environment. Traditional centralized approaches face hurdles in handling the high velocity and volume of IoT data, especially in real-time scenarios. In order to improve IoT DataStream prediction performance, this paper introduces a novel framework that combines federated learning (FL) with a competitive random search optimizer (CRSO) of Long Short-Term Memory (LSTM) models based on attention. The proposed integration leverages distributed intelligence while employing competitive optimization for fine-tuning. The proposed framework not only addresses privacy and scalability concerns but also optimizes the model for precise IoT DataStream predictions. This federated approach empowers the system to derive insights from a spectrum of IoT data sources while adhering to stringent privacy standards. Experimental validation on a range of authentic IoT datasets underscores the framework's exceptional performance, further emphasizing its potential as a transformational asset in the realm of IoT DataStream prediction. Beyond predictive accuracy, the framework serves as a robust solution for privacy-conscious IoT applications, where data security remains paramount. Furthermore, its scalability and adaptability solidify its role as a crucial tool in dynamic IoT environments.