Cancer is an increasing burden on global health. Breast and lung cancers are the two tumors with the highest incidence rates. The study shows that early detection and early diagnosis are important prognostic factors for breast and lung cancers. Due to the great advantages of artificial intelligence in feature extraction, the combination of infrared analysis technology may have great potential in clinical applications. This study explores the potential application of mid-infrared spectroscopy combined with machine learning for the differentiation of breast and lung cancers. The experiment collects blood samples from clinical sources, separates serum, trains classification models, and finally predicts unknown sample categories. We use k-fold cross-validation to determine the training set of 301 cases and the test set of 50 cases. Through differential spectrum analysis, we found that the intervals of 1318.59–1401.03 cm−1, 1492.15–1583.27 cm−1, and 1597.25–1721.64 cm−1 have significant differences, which may reflect the absorption of key chemical bonds in protein molecules. We use a total of 24 models such as decision trees, discriminant analysis, support vector machines, and K-nearest neighbor to train, identify, and distinguish spectra. The results show that under the same conditions, the prediction model trained based on fine KNN has the best performance and can perform 100% prediction on the test set samples. This also shows that our model has important potential for auxiliary diagnosis of serum breast cancer and lung cancer. This method may help to further achieve comprehensive screening of associated cancers in underserved areas, thereby reducing the cancer burden through early detection of cancer and appropriate treatment and care of cancer patients.