This study aims to investigate the relative importance of sociodemographic, built-environment, and station-related attributes on the impact of different electronic ticketing ways on metro origin-destination (OD) ridership during the morning and evening peak periods. Three distinct machine learning models were evaluated in this study: the random forest (RF) model, the gradient boosting decision trees (GBDT) model, and the extreme gradient boosting (XGBoost) model. Using data from Tianjin, China, the findings indicate that the XGBoost model exhibited superior performance relative to the other models. During the morning peak hour (7:00-9:00) on working days, the impact of the origin station on the metro OD ridership of the intracity smartcard and single-journey card is greater than that of the destination station. Conversely, the influence of the variables at the destination station on the metro OD ridership is greater than that at the origin station. During the evening peak period (17:00-19:00), the influence of the variables at the origin station of single-journey cards on the OD ridership of single-journey cards is greater than that at the destination station. For intercity smartcards, intracity smartcards, and QR-code payment, the variable at the destination station exerts a more pronounced influence on the metro OD ridership than at the origin station. The distance to center has a relatively high impact on each electronic ticketing way.