Early detection of diabetes is critical to reducing the number of cases, which continues to rise year after year. Many approaches to diagnosis have been used, but they still have flaws in making clinical decisions that are more effective and efficient. The use of intelligent systems is very effective in assisting in data analysis and clinical decision support. The purpose of this article is to develop a model to predict diabetes mellitus using the Pima Indian Diabetes Dataset (PIDD). The ensemble method has shown to be quite effective at increasing accuracy, but it has the issue of determining the optimal weight. As a result, to improve prediction accuracy, this study employs PSO optimization in the selection of ensemble majority voting weights. The test results show that predictions for ensemble majoritarian voting using PSO perform well, with an accuracy rate of 0.9322, precision of 0.9412, recall of 0.8421, and F1-score of 0.8889. PSO accuracy is improved by 4% and 7%, respectively. This demonstrates that applying PSO to the ensemble model can improve accuracy.