Multiple sclerosis (MS) causes chronic inflammation and demyelination of the central nervous system and comprises a class of neurodegenerative diseases in which interactions between multiple immune cell types mediate the involvement of MS development. However, the early diagnosis and treatment of MS remain challenging. Gene expression profiles of MS patients were obtained from the Gene Expression Omnibus (GEO) database. Single-cell and intercellular communication analyses were performed to identify candidate gene sets. Predictive models were constructed using LASSO regression. Relationships between genes and immune cells were analyzed by single sample gene set enrichment analysis (ssGSEA). The molecular mechanisms of key genes were explored using gene enrichment analysis. An miRNA network was constructed to search for target miRNAs related to key genes, and related transcription factors were searched by transcriptional regulation analysis. We utilized the GeneCard database to detect the correlations between disease-regulated genes and key genes. We verified the mRNA expression of 4 key genes by reverse transcription-quantitative PCR (RT‒qPCR). Monocyte marker genes were selected as candidate gene sets. CD3D, IL2RG, MS4A6A, and NCF2 were found to be the key genes by LASSO regression. We constructed a prediction model with AUC values of 0.7569 and 0.719. The key genes were closely related to immune factors and immune cells. We explored the signaling pathways and molecular mechanisms involving the key genes by gene enrichment analysis. We obtained and visualized the miRNAs associated with the key genes using the miRcode database. We also predicted the transcription factors involved. We used validated key genes in MS patients, several of which were confirmed by RT‒qPCR. The prediction model constructed with the CD3D, IL2RG, MS4A6A, and NCF2 genes has good diagnostic efficacy and provides new ideas for the diagnosis and treatment of MS.