Despite the growing adoption of artificial intelligence (AI) in healthcare, improving AI frameworks remains essential for effective medical implementation. A major challenge in developing reliable machine learning models is handling imbalanced medical datasets. Although metaheuristic algorithms can improve machine learning performance, their effectiveness on imbalanced medical data has received limited attention. This study evaluates four nature-inspired optimization techniques, bat algorithm (BA), genetic algorithm (GA), improved grey wolf optimization (IGWO), and improved whale optimization (IWO), for enhancing balanced random forest (BRF) classification on imbalanced datasets involving breast tumors, heart failure survival, mammogram microcalcification detection, and diabetes. Based on F1 scores, IGWO achieved the greatest improvements (0.256–0.060), followed by IWO (0.229–0.045), GA (0.214–0.036), and BA (0.203–0.036). Validation results confirmed IGWO’s strong convergence and optimization efficiency, consistently outperforming the other methods. The best performance was achieved by IGWO-BRF in breast cancer diagnosis (F1 = 1.000), while the lowest was observed for BA-BRF in mammogram microcalcification detection (F1 = 0.570). Optimization time depended on both the search strategy and dataset characteristics, with IWO showing the fastest optimization across all datasets. Overall, nature-inspired optimizers significantly improved classification performance on imbalanced medical datasets.
