Network Intrusion Detection Using Machine Learning: A Comparative Study of Logistic Regression, KNN, and Random Forest

20 Sep

Authors: Komala R, Tejashree H Y

Abstract: Network Intrusion Detection Systems (NIDS) play a critical role in defending networks against unauthorized access and cyber threats. This paper presents a real-time, web-enabled NIDS built using machine learning techniques to effectively identify and categorize network-based attacks. The system is trained on the NSL-KDD dataset, a refined alternative to earlier datasets, addressing issues like redundancy and class imbalance. We implement and evaluate three supervised learning algorithms—Logistic Regression, K-Nearest Neighbors (KNN), and Random Forest. The workflow includes comprehensive preprocessing, class balancing, and hyperparameter tuning via grid search with cross-validation. Among the models tested, Random Forest achieved the highest detection performance, showing excellent accuracy with minimal false positives. While KNN also produced reliable results, it was comparatively slower. Logistic Regression delivered quick and interpretable outcomes but struggled with complex intrusion patterns. This work contributes a practical, browser-accessible NIDS platform that brings together machine learning capabilities and real- time threat detection.

DOI: http://doi.org/