The physical condition of patients is heterogeneous and complex, making it challenging to accurately predict surgery duration and postoperative recovery length before surgery, which brings challenges to the hospital in surgery scheduling. Medical informatization has produced a large amount of medical data, and the effective use of the diagnosis and treatment data of history patients can provide guidance for the surgery scheduling of newly arrived patients. This paper proposes a machine learning approach that constructs a patient feature-based uncertainty set, taking into account the uncertainty of surgery duration and postoperative recovery length. To minimize total costs during the scheduling period, a two-stage robust optimization model is established from the perspective of patient segmentation, and a column and constraint algorithm is designed to generate accurate solutions. Numerical experiments with real hospital data show that the proposed method can improve the quality of surgical scheduling and alleviate downstream unit shortages.