Heart failure (HF) is a global health threat, requiring urgent research in its classification. This study proposes a novel approach for HF classification by integrating advanced supervised learning (ASL) and particle swarm optimization (PSO). ASL techniques like bagging and AdaBoost are employed within the PSO+ASL optimization model to enhance prediction accuracy. PSO optimizes model weights and bias, while ASL addresses overfitting or underfitting issues. Split validation and cross-validation (70:30, 80:20, 90:10 with k-fold=10) are used for further optimization. The testing phase involves 12 classifiers in five groups: decision tree models (DTM), support vector machines (SVM), Naïve Bayes classifiers models (NBCM), logistic regression models (LRM), and lazy model (LM). Evaluating the proposed approach with an HF patient dataset from https://www.kaggle.com, results are compared against the standard model, PSO optimization, and PSO+ASL. Experimental findings demonstrate the superiority of the proposed approach, achieving higher accuracy in HF prediction. The PSO+ASL optimization model with the k-nearest neighbor (k-NN) method exhibits the best classification performance. It consistently achieves the highest accuracy across all tests on dataset composition ratios, with 100% accuracy, f-measure, sensitivity, specificity values, and area under cover (AUC) of 1. The proposed approach serves as a reliable tool for early detection and prevention of HF.