Atherosclerosis is an immunoinflammatory disease caused by lipids which is an important factor in causing coronary heart disease and stroke. Medical researchers around the world are working on more effective ways to diagnose and treat it. This article will introduce a method of machine learning algorithm to screen biomarkers and perform pan-cancer analysis for reference. First, we downloaded the GEO dataset containing information on atherosclerotic patients for differential gene screening. At the same time, we also used TCGA and GTEx databases for pan-carcinogenic analysis of differential genes. Then, we performed WGCNA analysis. The selected module genes were crossed with the differential genes to obtain 122 key genes. Four machine learning algorithms, XGBoost, RandomForest, SVM-REF and GLM, were used to calculate the critical genes and get the junction of the results to obtain 4 hub genes (SLAMF8, TLR2, VAMP8 and VSIG4). Next, we build a diagnostic model and assess the capabilities of this model.At the same time, the ROC curves of the four genes also suggest that their role in the development of atherosclerosis is critical. Next, we performed gene correlation analysis, immune infiltration analysis and RT-PCR verification of the four core genes, and finally screened out TLR2 for pan-carcinoma. Through analysis, we can find that the expression of TLR2 in patients with a variety of tumors is different from that of normal people, and it is strongly associated with the proportion of prognosis of patients with diverse cancers. The results suggest that TLR2 may be a target for intervention in the development of diseases such as atherosclerosis and tumors.