In our study, the 10 genes associated with osteoporosis metabolism were screened by machine learning, and these 10 genes were GPR31, GATM, DDB2, ARMCX1, RPS6, BTBD3, ADAMTSL4, COQ6, B3GNT2, and CD9. Meanwhile, in our external data validation, GPR31 was highly expressed in patients with low-level bone mineral density and patients with osteoporosis. This evidence concerns the gene B3GNT2 and osteoporosis.