ImportanceOral endocrine treatments have been shown to be effective when carefully adhered to. However, in patients with early breast cancer, adherence challenges are notable, with 17% experiencing nonpersistence and 41% nonadherence at least once.ObjectiveTo model the persistence of and adherence to oral anticancer treatment of a patient with localized breast cancer.Design, Setting, and ParticipantsThis cohort study was conducted using anonymous reimbursement data belonging to French female patients with breast cancer, extracted from the French Health Insurance database from January 2013 to December 2018. Data analysis was conducted from January 2021 to May 2022.Main Outcomes and MeasuresThe main outcome was the detection of episodes of nonpersistence and nonadherence 6 months before they happened. Adherence was defined as the ratio between the time covered by a drug purchase and the time between 2 purchases; patients were considered nonadherent if the ratio of their next 3 purchases was less than 80%. Disparities in persistence and adherence based on criteria such as age, treatment type, and income were identified.ResultsA total of 229 695 female patients (median [IQR] age, 63 [52-72] years) with localized breast cancer were included. A deep learning model based on a gated-recurrent unit architecture was used to detect episodes of nonpersistence or nonadherence. This model demonstrated an area under the receiving operating curve of 0.71 for persistence and 0.73 for adherence. Analyzing the Shapley Additive Explanations values also gave insights into the contribution of the different features over the model’s decision. Patients older than 70 years, with past nonadherence, taking more than 1 treatment in the previous 3 months, and with low income had greater risk of episodes of nonpersistence. Age and past nonadherence, including regularity of past adherence, were also important features in the nonadherence model.Conclusions and RelevanceThis cohort study found associations of patient age and past adherence with nonpersistence or nonadherence. It also suggested that regular intervals in treatment purchases enhanced adherence, in contrast to irregular purchasing patterns. This research offers valuable tools for improving persistence of and adherence to oral anticancer treatment among patients with early breast cancer.