Introduction: Cancer is the second cause of death in America. Currently, the death rate of cancer patients is higher than the treatment rate, and one of the most important factors of this issue is the side effects of chemotherapy drugs, high heart and liver toxicity, as well as late diagnosis of cancer. Scientists have identified cancer patients who are exposed to chemotherapy drugs and have a higher risk of heart failure than other patients with the help of artificial intelligence and have taken an important step towards cancer treatment. Methods and Materials: In this study, the electronic data of patients at the California Health Center were used. It should be noted that patients must first be diagnosed with cancer, then heart failure should be diagnosed. The data of this study is from 2011. Until 2017, it includes 143,199 cancer patients. The data used to identify heart patients from the 9th and 10th editions of the international classification of patients were used, and cancer patients were also identified with a matrix code. They also used RXnorm. They also used four machine learning algorithms and two coding methods to increase the accuracy of the study. Conclusion: In this study, four machine learning algorithms have been used to predict cancer patients who are at risk of heart failure. From the 143,199 patients identified according to the criteria used and the screening done, we reached 1,958 cases and 15,488 controls. Chemotherapy drugs that were used the most are methotrexate in 1486 patients, cyclosfamide in 1371 patients, and carboplatin in 1275 patients. These patients have a high risk of heart failure compared to the patients in the control group. We also found that diagnosis during stress high blood pressure, atrial fibrillation, shortness of breath, hyperlipidemia in people increase the potential of heart failure.