Predicting diabetes second-line therapy initiation in the Australian population via time span-guided neural attention network

PLoS One. 2019 Oct 18;14(10):e0211844. doi: 10.1371/journal.pone.0211844. eCollection 2019.


Introduction: The first line of treatment for people with Diabetes mellitus is metformin. However, over the course of the disease metformin may fail to achieve appropriate glycemic control, and a second-line therapy may become necessary. In this paper we introduce Tangle, a time span-guided neural attention model that can accurately and timely predict the upcoming need for a second-line diabetes therapy from administrative data in the Australian adult population. The method is suitable for designing automatic therapy review recommendations for patients and their providers without the need to collect clinical measures.

Data: We analyzed seven years of de-identified records (2008-2014) of the 10% publicly available linked sample of Medicare Benefits Schedule (MBS) and Pharmaceutical Benefits Scheme (PBS) electronic databases of Australia.

Methods: By design, Tangle inherits the representational power of pre-trained word embedding, such as GloVe, to encode sequences of claims with the related MBS codes. Moreover, the proposed attention mechanism natively exploits the information hidden in the time span between two successive claims (measured in number of days). We compared the proposed method against state-of-the-art sequence classification methods.

Results: Tangle outperforms state-of-the-art recurrent neural networks, including attention-based models. In particular, when the proposed time span-guided attention strategy is coupled with pre-trained embedding methods, the model performance reaches an Area Under the ROC Curve of 90%, an improvement of almost 10 percentage points over an attentionless recurrent architecture.

Implementation: Tangle is implemented in Python using Keras and it is hosted on GitHub at

Publication types

  • Research Support, Non-U.S. Gov't

MeSH terms

  • Australia
  • Diabetes Mellitus / drug therapy*
  • Diabetes Mellitus / epidemiology
  • Female
  • Humans
  • Machine Learning*
  • Male
  • Metformin / therapeutic use*
  • Models, Biological*
  • Neural Networks, Computer*
  • Predictive Value of Tests


  • Metformin

Grant support

This research is funded by Multiple Sclerosis Italian Foundation (cod. 2015/R/03) with the following URL: (the recipient of the award is SF), and Capital Markets Cooperative Research Centre (CMCRC) Limited with the following URL: and Australian Institute of Health and Welfare (AIHW) with the following URL: (the recipient of the award is FH). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.