The four machine learning methods, expression pattern analysis, and ROC curve evaluation across multiple dimensions identified three key genes from the 23 shared genes: CYP1B1, SERPING1, and CHPT1. Pathway enrichment analysis of the three genes revealed their potential roles in immune responses, inflammation, lipid metabolism, cell growth, and immune evasion in both T2DM and TB. This evidence concerns the gene CYP1B1 and type 2 diabetes mellitus.