Wrong-way riding (WWR) behavior of electric bikes (e-bikes) is a hazardous practice that frequently threatens traffic safety. It is imperative to accurately detect instances of WWR and analyze the various factors contributing to this behavior to develop and implement effective management policies. The emergence of shared e-bikes and advancements in machine learning have opened up new avenues for accurately examining the determinants of WWR behavior. Therefore, this study utilizes a large-scale dataset of shared e-bike trajectory data to establish a framework for detecting WWR behavior. Subsequently, association rule mining investigates the correlation among road, traffic, environmental factors, and the likelihood of higher and lower WWR behavior. The results indicate that: (1) In the association rules for higher WWR frequency, the absence of central separation facilities and bike lane separation facilities on the tertiary road, as well as lower land use density and the lack of public transportation facilities, enhanced the likelihood of WWR occurrence; (2) In the association rules for lower WWR frequency, longer crossing facility distance, physical bike lane separation, along with higher land use mixing and the presence of public transportation facilities, reduce the probability of WWR occurrence; (3) Time conditions display spatial heterogeneity, and different land use and road condition modulate the impact of time factors on rider’ intention for WWR. Finally, based on the study findings, adequate policy recommendations are proposed for urban management agencies to reduce WWR behavior and enhance the safety of the e-bike traffic system.