Research Article

A Neighbor Prototype Selection Method Based on CCHPSO for Intrusion Detection

Algorithm 2

The proposed method.
Input: training, validation, and testing datasets with labels, KNN as the main classifier, CCHPSO algorithm
Output: testing accuracy (acc), DR, FPR, and confusion matrix.
(1) Training:
(2)  Obtain the training, validation, and testing datasets by the stratification strategy
(3)   repeat
(4)    for each swarm
(5)     for each particle
(6)      fitness = KNN (pop, train scale, train label, validation scale, and validation label);
(7)      update the local and global Sol;
(8)      end for
(9)      Perform position and velocity updates using (2), (3), or (4)
(10)     end for
(11)    until termination is met;
(12)    Obtain the appropriate prototypes and feature weights according to the global optimal Sol.
(13)    Testing:
(14)    [testing accuracy, confusion matrix] = KNN (Sol, prototype data, prototype label, test scale, test label);