Reducing postoperative cardiovascular and neurological complications (PCNC) during thoracic surgery is the key to improving postoperative survival. We aimed to investigate independent predictors of PCNC, develop machine learning models, and construct a predictive nomogram for PCNC in patients undergoing thoracic surgery for lung cancer. This study used data from a previous retrospective study of 16,368 patients with lung cancer (training set: 11,458; validation set: 4,910) with American Standards Association physical statuses I-IV who underwent surgery. Postoperative information was collected from electronic medical records to help build models based on cause-and-effect and statistical data, potentially revealing hidden dependencies between factors and diseases in a big data environment. The optimal model was analyzed and filtered using multiple machine-learning models (Logistic regression, eXtreme Gradient Boosting, Random forest, Light Gradient Boosting Machine and Naïve Bayes). A predictive nomogram was built and receiver operating characteristics were used to assess the validity of the model. The discriminative power and clinical validity were assessed using calibration and decision-making curve analyses. Multivariate logistic regression analysis revealed that age, surgery duration, intraoperative intercostal nerve block, postoperative patient-controlled analgesia, bronchial blocker use and sufentanil use were independent predictors of PCNC. Random forest was identified as the optimal model with an area under the curve of 0.898 in the training set and 0.752 in the validation set, confirming the excellent prediction accuracy of the nomogram. All the net benefits of the five machine-learning models in the training and validation sets demonstrated excellent clinical applicability, and the calibration curves showed good agreement between the predicted and observed risks. The combination of machine-learning models and nomograms may contribute to the early prediction and reduction in the incidence of PCNC.