Heart attack or heart failure cases are rising quickly each day, thus it is crucial and worrisome to anticipate any problems in advance. A heart attack is a significant medical emergency that happens when the blood circulation to the heart is abruptly clogged, normally by a blood clot. For the prevention and treatment of heart failure, an accurate and prompt identification of heart disease is essential. Traditional medical history has been criticized for not being a trustworthy method of diagnosing heart disease in many ways. Machine learning techniques are effective and reliable for classifying healthy individuals from heart attack risk factors. This study proposes a model based on machine learning methods such as decision trees, random forests, neural networks, voting, gradient boosting, and logistic regression using a dataset from the UCI repository that incorporates numerous heart disease-related variables. The aim of this paper is to foresee the probability of a heart attack or failure in patients. According to the results, the gradient boosting approach exhibits the best performance in terms of accuracy, precision, recall, specificity, and f1-score. Decision tree, random forest, voting, and gaussian naive Bayes also have shown good performance.