The most common cause of death in the world is heart disease. The early detection and risk assessment of this disease is crucial to the prevention and treatment of the disease. The predictive power of machine learning is investigated by developing models for heart disease using machine learning. This paper evaluates six machine learning algorithms to see how well they predict heart disease risk. This study analyzed 12 features, including age, gender, blood pressure, cholesterol, and glucose levels, using logistic regression, random forests, K nearest neighbors, decision trees, and support vector classification. We divided the dataset into training and testing sets, and the algorithms were trained on the training set and evaluated on the testing set. According to the results, all six algorithms can reasonably forecast heart disease risk. The random forest is the best-performing algorithm, which achieved 79.34% accuracy and 78.44% F1 score. Both the modified ensemble classifier and KNN perform well, achieving 78.75% and 77.69% accuracy, respectively. Based on the findings of this study, machine learning can be used to develop effective heart disease predictive models. By using these models, we can identify people with high risks of developing heart disease and take preventive measures. The abovementioned algorithms can be combined with Naive Bayes, artificial neural networks, and deep learning algorithms to predict heart disease. The performance of these algorithms needs to be examined on larger and more diverse datasets.