Rain classification consists of several categories of rain, such as light rain, moderate rain, and heavy rain. Classification is also useful in managing water resources and disaster mitigation, both floods and landslides. One of the methods used to classify rainfall is K-Nearest Neighbor (KNN). However, KKN has a weakness, namely in determining the value of the parameter k which is not maximized. Therefore, to cover the weaknesses of the KNN method, an optimization is needed for the K value using the Particle Swarm Optimization method so that the accuracy results obtained are optimal..PSO will optimize the selection of K values by initializing the respective K value particles used for KNN classification, then updating the position and velocity based on PBest and GBest. The process will be repeated in certain iterations until the criteria are met and will produce an optimal K value. The optimized K value will then be used for the KNN classification process.Based on the model that has been made with a total of 525578 training data and 41268 test data has the most optimal K value, namely K = 7. From the K value by testing using the confusion matrix obtained an accuracy of 99.88%. From optimizing using PSO on KNN, getting a better time in selecting K values is 3 minutes 52 seconds, whereas without optimizing using PSO on KNN, you get approximately 5 minutes. This proves that PSO optimization on KNN can provide good time efficiency in selecting the most optimal K value
Copyrights © 2026