The traditional way of predicting heart disease is usually through the subjective judgment of doctors, which is high subjectivity. Current machine learning methods do not pay enough attention to its universality. The two datasets used in this study are from Kaggle and preprocessed in advance, including standardization by using Z-Score and dimensionality reduction by KPCA. The two datasets were designated as the source domain and the target domain. The source domain dataset was further divided into two subsets with an 80:20 split, where 80% was used for training the model and the remaining 20% served as the test set. The trained model was then applied to the target domain to compare the differences in prediction results. Through the exploration of Multilayer Perceptron (MLP), Random Forest and Support Vector Machine (SVM), for the data set used in this study, when MLP uses a simple structure, the difference in prediction accuracy dropped from 13.8% to 5.07. For Random Forest, by increasing the number of decision trees and decreasing the minimum number of samples required for splitting, the difference is reduced from 15.6% to 9.32%. By modifying the penalty parameter C value of SVM, the difference on different datasets is reduced from 13.39% to 4.46%. This study is one of the few to explore the generalizations of heart disease prediction. The results demonstrate that the generalization performance of the model for heart disease prediction can be significantly enhanced through appropriate modifications to its structure and hyperparameters.