By combining WGCNA with various machine learning methods, we identified six key genes as biomarkers for NAFLD and AIS: CEBPD, SOCS2, THBS1, IFIT2, TNFSF10, and IL2RB. Here, SOCS2 is linked to metabolic dysfunction-associated steatotic liver disease.