Accurate prediction of heart failure is crucial for early intervention and preventative care. This study aims to improve prediction accuracy using a Heart Failure Prediction dataset of 299 samples with 12 distinct features and a target variable. We addressed data imbalance using the NearMiss algorithm and normalized the data to ensure uniformity. Subsequently, Principal Component Analysis (PCA) was used to distill the dataset to 7 principal features, which, when aggregate with the original features, formed a restructured dataset. Several machine learning models were evaluated, and the random forest algorithm emerged as the most accurate, achieving an 83.5% prediction success rate. This outcome not only represents a significant improvement over previous studies but also highlights the importance of meticulous preprocessing and feature optimization in predictive modeling.