Many secondary schools in Sub-Saharan countries face the problem of students dropping out of school due to various reasons which are difficult to diagnose directly. Various initiatives such as the big results now initiatives, free education for all, no child left behind, and secondary education development programme as well as machine learning prediction models used to reduce the severity of the problem in Sub-Saharan countries. The ongoing dropout problem, particularly in secondary schools, is ascribed to improper root cause identification and the absence of formal procedures that may be used to estimate the severity of the issue. Bayesian Optimization technique has been used to project the student dropout by optimizing the prediction results. The forecast accuracy of machine learning algorithms is hampered by default optimization techniques, making it difficult to pinpoint the real causes of student dropouts. The performance of the optimized model was evaluated by the average accuracy, precision, recall, f1, Roc curve, and AUC. Prediction accuracy results indicate that NB = 95%, LDA = 94%, SGD = 96%, DT = 97%, RF = 97%, LR = 96%, KNN = 97%, and AdaBoost = 97%. Features including student marks, age, school distance, parental education, number of children, and parental occupation significantly contribute to student dropouts. Results indicate the prediction accuracy of the proposed model outperforms the default optimization method of the machine learning algorithms. A well-optimized strategy draws a lot of attention to the findings related to student dropout rates in Sub-Saharan countries.