## 3 Materials and Methods  
This article proposes a TREASURE framework, that follows affinity analysis to find various relations between the dataset and filters out the patterns among these records via set intersection and occurring frequency. Algorithm 1 gives the outline of the TREASURE model. Thousands of documents pertaining to each drug are collected from the PubMed database. The collected documents are preprocessed as they undergo tokenizing, stemming, stop words removal and tf-idf calculation phases. The preprocessed data are visualized through word cloud to give an idea about the frequently occurring words in the collected dataset. Then, the preprocessed data undergoes an affinity analysis phase, which determines various co-occurring relationships among the words in the dataset and generates the relation records accordingly. These relation records are then filtered, based on maximum co-occurrence value and set intersection property, to obtain the resultant set. Thus, different resultant sets for different TB drugs are obtained and are then analyzed to provide various inferences. The overall architecture of the TREASURE framework is depicted in Figure 1.  
```
Input: Abstracts from PubMed Database Output: A filtered resultant set containing frequently occurring word patterns
1. Data preprocessing 1.1 Tokenizing 1.2 Remove punctuations and stop words 1.3 Stemming 1.4 TF-IDF calculation
2. Generate the relation records via affinity analysis
3. Based on the co-occurrence value of each element and set intersection property, the resultant set is filtered out from the relation records

### Data Preprocessing

The TREASURE model gathers data from the PubMed database. As the data gathering methods are loosely controlled, the gathered data might contain garbage values, out-of-range values, missing values, etc. This data must be transformed to a useful and an efficient format. It is done by various preprocessing steps. Algorithm 2 shows the TREASURE data preprocessing. The gathered data is first cleaned to handle the noisy and missing data. Then, tokenization breaks the sentences or clauses into separate words. The punctuations among the sentences are removed. In any dataset, there are always some commonly used words such as \"the\", \"for\", \"should\", and \"to\", which do not contribute to any kind of learning. They are known as stop words. Removing them is an important step in data preprocessing. Inpython, NLTK (Natural Language Toolkit) library has a list of stop words. Along with this, an additional list of stop words, if given as user input, is also removed. The dataset might contain words like affects, affecting, affected, while all these words mean the same thing. These words are either reduced to their root words or word stems that affixes to suffixes or prefixes, and this process is referred as stemming. The next step in data preprocessing is to extract the important words through tf-idf calculation. Once the words are reduced to their stem the term frequency (tf) and the inverse document frequency (idf) are computed for each word as given in Equations (1) and (2). The tf-idf weight is a statistical measure used to determine the importance of a word (term) to a document (doc) in the dataset [25; 26]. Its calculation is given in Equation (3). \[\text{tf}_{\text{(term, doc)}}=\frac{\text{frequency of }term\text{ in }doc}{\text{Total number of words in }doc} \tag{1}\]

Figure 1: TREASURE framework for the analysis of TB drugs. \[\text{idf}_{(\text{term})}=\text{ln}\ \frac{\text{Total number of documents}}{\text{Number of documents containing term}} \tag{2}\] \[\text{tf}-\text{idf}_{(\text{term, doc})}=\ \text{tf}_{(\text{term, doc})}\times\ \text{idf}_{(\text{term})} \tag{3}\]
```
Input: PubMed abstracts in a csv file Output: Preprocessed data in a csv file
1. Loop through the entire csv file 1.1 Perform tokenization on the document 1.2 Remove punctuations 1.3 Remove stop words 1.4 Stem the tokenized words to get the root words
2. Calculate term frequency for the words in document as given in Equation (1)
3.