Preventing sudden cardiac death (SCD) in clinical settings and establishing it accurately in forensic investigations remain difficult because of the lack of uniform quantitative standards for assessing morphological and histopathological changes in the heart. This study aimed to create a machine learning-powered system for evaluating cardiac lesions, thereby enabling more precise quantitative diagnosis and risk assessment of SCD. The investigation incorporated 2284 adult autopsy cases from the forensic center at Sun Yat-sen University together with 1883 cases from five independent external centers to construct and validate a diagnostic model based on postmortem findings. Eight different machine learning algorithms were tested, and the superior model underwent additional assessment through human–machine collaboration experiments. This model was subsequently adapted to detect myocardial infarction within a prospective clinical group of 204 individuals who presented with chest pain. Cases of SCD displayed markedly increased right ventricular wall thickness (OR: 1.17 [95% CI: 1.04–1.32] per mm) along with enlarged valve annulus circumferences for the tricuspid (OR: 1.17 [95% CI: 1.04–1.33] per cm), pulmonary (OR: 1.54 [95% CI: 1.34–1.76]), mitral (OR: 1.16 [95% CI: 1.04–1.29]), and aortic (OR: 1.24 [95% CI: 1.06–1.44]) valves. The logistic regression model showed excellent ability to distinguish SCD, recording an area under the receiver-operating characteristic curve (AUC) of 0.839 (95% CI: 0.821–0.858) in the training dataset and ranging from 0.840 to 0.907 in the external validation groups. When pathologists used the model as support, diagnostic performance improved significantly, with elevated AUC (P = 0.004) and sensitivity (P = 0.01) in identifying SCD. In cases of sudden coronary artery death, the morphology-based model reached an AUC of 0.781 (95% CI: 0.738–0.825). When applied to myocardial infarction detection with features measurable by echocardiography, the model produced an AUC of 0.697 (95% CI: 0.587–0.817). The extensively validated model represents a new supportive instrument that enables pathologists to conduct quantitative SCD evaluations and offers clinicians a promising resource for recognizing myocardial infarction and issuing early warnings for potential SCD events.