We identified four key biomarkers (LOC389023, DUOX2, LCN2, and DEFA6) and used ten machine learning methods and SHAP models to assist in IBD diagnosis, clarifying the genetic characteristics, molecular pathways, and differentially abundant immune cells of IBD. Here, DEFA6 is linked to inflammatory bowel disease.