As the alarming growth of computer connectivity and the significant number of computer-related applications increased lately, the challenge of achieving cyber-security has become progressively difficult. It also needs an adequate defense mechanism against a variety of cyber attacks. Detecting inconsistencies and threats in a computer network, as well as designing intrusion detection systems (IDS) that can help with cyber-security. A useful data-driven intrusion detection system has been developed using artificial intelligence (AI), particularly machine learning (ML) techniques. In this study, two different classification techniques for intrusion detection (ID) with each having its unique use cases were compared. Particle Swarm Optimization (PSO) algorithm was employed for dimensionality reduction before employing the two classifiers for the classification procedure. This study considered the classification techniques to categorize the network anomalies. The two classifiers employed are PSO + Decision Tree (PSO+DT) and PSO + K-Nearest Neighbor (PSO+KNN). The results of the detection techniques were verified using KDD-CUP 99 dataset. The usefulness of success indicators such as specificity, recall, f1-score, accuracy, precision, and consistency on cyber-security databases for different categories of cyber-attacks was employed on the result of the implementation. The two classifiers were also compared to deduce which of the classifier achieves exceedingly in terms of accuracy, detection rate (DR), and false-positive rate (FPR). Finally, the system was compared with the existing IDS. The results show that PSO+KNN outperformed the PSO+DT classifier algorithm in terms of identifying network anomalies.