In the increasing trend of population aging, medical security has become an important issue in social life that cannot be ignored. The elderly population generally faces the threat of a variety of cardiovascular diseases, which not only bring potential hazards to their physical health, but also pose more serious challenges to the medical system. Therefore, there is an urgent need to monitor the health indicators of the elderly and provide timely medical care. This article shows the corresponding machine learning model, which can provide relatively accurate predictions based on a given data set. By comparing and studying three Bayesian-optimized algorithms and baseline models (including Decision Tree, Support Vector Machine, Logical Regression, Random Forest, XGB, LGBM), a relatively better algorithm was selected. In this paper, it is believed that the model performance given by LGBM after Bayesian optimization is relatively good. It has a sound framework, high accuracy in predicting cardiovascular disease, and good performance when processing large-scale data, making it feasible for application in the field of medical security. At the same time, this research builds a visualization platform to afford assistance in the early detection of heart disease, is more friendly to non-professionals, and has made contributions in the fields of medical security and public health.