Distributed Denial of Service (DDoS) attacks pose significant challenges to network security, causing disruptions and financial losses worldwide. Traditional mitigation techniques often fall short in adapting to the evolving complexity of these attacks. This research work introduces a novel approach to improving the detection and mitigation of DDoS attacks through the application of advanced machine learning algorithms, especially the Local Outlier Factor algorithm. It is designed to enhance the security and resilience of digital environments, effectively countering the constantly evolving nature of such attacks. For this it uses a Deep Q-Network. By integrating insights from previous studies and employing a rigorous, cutting-edge approach, this research prioritizes not only innovative solutions but also their practicality and effectiveness in real-world applications. The proposed model will be able to provide accurate detection of DDoS attacks. Given the constantly changing landscape of digital threats, these efforts are vital for safeguarding the stability and durability of global network infrastructures. This research highlights the potential of machine learning as a transformative tool in fortifying cybersecurity defenses against DDoS attacks.