Objective The random forest and Logistic regression method were used to analyze the prognostic factors of cardiogenic death in patients with chronic heart failure complicated by atrial fibrillation. Methods Using the method of the cohort study, we selected patients with chronic heart failure complicated by atrial fibrillation in six traditional Chinese medicine (TCM) hospitals in Shandong Province (Affiliated Hospital of Shandong University of TCM, Weifang Hospital of TCM, Rizhao Hospital of TCM, Zibo Hospital of TCM, Qingdao Hospital of TCM, and Jinan Hospital of TCM) as the research object. We collected a total of 72 original data samples during hospitalization, including baseline data, complications, TCM pattern factors, cardiac color Doppler ultrasound, laboratory examination, and Chinese and Western medicinal treatment. After discharge, we followed up with the patients every six months to obtain the incidence of cardiac death. According to the occurrence of cardiac death, the included cases were divided into the endpoint group and the non-endpoint group. The statistically significant variables between the groups were selected by single factor analysis and successively included in the random forest model. The variable set with the smallest estimation error rate outside the bag was taken as the pre-treatment factor of cardiac death, and the importance of prognostic factors was ranked according to the reduction in the average Gini index. Multivariate logistic regression was further used to analyze the nature of prognostic factors. Results A total of 723 cases were included in the study, including 99 cases of cardiogenic death; 25 of 72 variables were screened out by single-factor analysis. Results of the stepwise random forest model showed that when the number of included variables was 11, estimation error rate outside the bag of the model was the smallest. Finally, the top 11 variables of the mean Gini index reduction were selected as the prognostic factors of cardiac death. Cardiac function grading, aortic valve stenosis, anticoagulant drugs, Yiqi TCM injection, heart rate, bilirubin, diastolic pressure, yang deficiency pattern, peripheral vascular disease, hypolipidemia drugs, and NT-ProBNP were ranked from high to low. Multivariate Logistic regression analysis showed that factors such as increased cardiac function grading (OR = 2.204) combined with aortic stenosis (OR = 12.852), increased heart rate (OR = 1.008), increased bilirubin (OR = 1.025), as well as increased diastolic blood pressure (OR = 1.029) combined with peripheral vascular disease (OR = 8.751) and an increase of NT-ProBNP (OR = 1.922), were risk factors for cardiac death in Western medicine. Taking anticoagulants (OR = 0.437) and hypolipidemics (OR = 0.366) were both protective factors for cardiac death in Western medicine. The yang deficiency pattern (OR = 1.127) was a TCM risk factor for cardiogenic death in patients, while the use of Yiqi TCM injections (OR = 0.261) was a TCM protective factor of cardiogenic death in patients. Conclusion Cardiac function grading, aortic valve stenosis, anticoagulants, Yiqi TCM injection, heart rate, bilirubin, diastolic pressure, yang deficiency pattern, peripheral vascular disease, hypolipidemics, and NT-ProBNP are prognostic factors of cardiogenic death in patients with chronic heart failure complicated by atrial fibrillation. The data analysis method combined with random forest and Logistic regression can realize complementary advantages and is suitable for high-dimensional and complex prognostic factor analysis of Chinese and Western medicine, which has clinical promotion value. [ABSTRACT FROM AUTHOR]