Lasso and RF algorithms confirmed 7 key genes as potential biomarkers for HF, and further analysis using the ROC curve identified 4 hub genes with good diagnostic value, namely, High mobility group N 2 (HMGN2), Myosin Heavy Chain 6 (MYH6), High temperature requirement A1 (HTRA1), and Microfibrillar-associated protein 4 (MFAP4), which were validated in an external dataset and by RT-qPCR. Here, MFAP4 is linked to hydrops fetalis.