The purpose of this study was to identify the potential diagnostic biomarkers in hepatocellular carcinoma (HCC) by machine learning (ML) and to explore the significance of immune cell infiltration in HCC. From GEO datasets, the microarray datasets of HCC patients were obtained and downloaded. Differentially expressed genes (DEGs) were screened from five datasets of GSE57957, GSE84402, GSE112790, GSE113996, and GSE121248, totalling 125 normal liver tissues and 326 HCC tissues. In order to find the diagnostic indicators of HCC, the LASSO regression and the SVM-RFE algorithms were utilized. The prognostic value of VIPR1 was analyzed. Finally, the difference of immune cell infiltration between HCC tissues and normal liver tissues was evaluated by CIBERSORT algorithm. In this study, a total of 232 DEGs were identified in 125 normal liver tissues and 326 HCC tissues. 11 diagnostic markers were identified by LASSO regression and SVM-RFE algorithms. FCN2, ECM1, VIRP1, IGFALS, and ASPG genes with AUC>0.85 were regarded as candidate biomarkers with high diagnostic value, and the above results were verified in GSE36376. Survival analyses showed that VIPR1 and IGFALS were significantly correlated with the OS, while ASPG, ECM1, and FCN2 had no statistical significance with the OS. Multivariate assays indicated that VIPR1 gene could be used as an independent prognostic factor for HCC, while FCN2, ECM1, IGFALS, and ASPG could not be used as independent prognostic factors for HCC. Immune cell infiltration analyses showed that the expression of VIPR1 in HCC was positively correlated with the levels of several immune cells. Overall, VIPR1 gene can be used as a diagnostic feature marker of HCC and may be a potential target for the diagnosis and treatment of liver cancer in the future.