Due to the fierce competition of commercial banks, customers are becoming more and more important to banks. Therefore, customer churn has become a major problem that banks need to face. In this paper, XGboost algorithm was used on a data set of customers of a US bank from Kaggle to predict customer churn, and grid search method was used to find the best hyperparameters. Moreover, K-means algorithm is adopted to further subdivide the lost customers. For predicting customer churn, XGBoost algorithm achieves 0.84 in accuracy, 0.83 in precision, 0.84 in recall and 0.84 in F1 score on the test set. And the most important score for features in the case of the algorithm adopted are customers' estimated salary, credit score and balance. For the segmentation of churn customers, K-means algorithm divides these customers into 5 groups. These five groups of customers have different values for banks, so this paper puts forward corresponding recovery suggestions for their respective characteristics