Osteoarthritis (OA) is thought to be the most prevalent chronic joint disease. The incidence of OA is rising because of the ageing population and the epidemic of obesity. This research was designed for the identification of novel diagnostic biomarkers for OA and analyzing the possible association between critical genes and infiltrated immune cells. 10 OA samples from patients with spinal OA and 10 normal samples were collected. GSE55235 and GSE55457 datasets including human OA and normal samples were downloaded from the GEO datasets. Differentially expressed genes (DEGs) were identified between 20 OA and 20 controls. SVM-RFE analysis and LASSO regression model were carried out to screen possible markers. The compositional patterns of the 22 types of immune cell fraction in OA were determined by the use of CIBERSORT. The expression level of the biomarkers in OA was examined by the use of RT-PCR. In this study, an overall 44 DEGs were identified: 18 genes were remarkably upregulated and 26 genes were distinctly downregulated. KEGG pathway analyses revealed that pathways were significantly enriched including IL-17 signal path, rheumatoid arthritis, TNF signal path, and lipid and atherosclerosis. Based on the results of machine learning, we identified APOLD1 and EPYC as critical diagnostic genes in OA, which were further confirmed using ROC assays. Immune cell infiltration analysis revealed that APOLD1 was correlated with mastocytes stimulated, NK cells resting, T cells CD4 memory resting, DCs stimulated, T cells gamma delta, macrophages M0, NK cells stimulated, and mastocytes resting. Moreover, we found that EPYC was correlated with mastocytes stimulated, NK cells resting, T cells CD4 memory resting, DCs stimulated, T cells gamma delta, macrophages M0, NK cells stimulated, and mastocytes resting. Overall, our findings might provide some novel clue for the exploration of novel markers for OA diagnosis. The critical genes and their associations with immune infiltration may offer new insight into understanding OA developments.