{'fraction_non_alphanumeric': 0.027529792799900345, 'fraction_numerical': 0.010588381846115517, 'mean_word_length': 4.914538310412573, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Diagnosing Tuberculosis With a Novel Support Vector Machine-Based Artificial Immune Recognition System

Background: Tuberculosis (TB) is a major global health problem, which has been ranked as the second leading cause of death from an infectious disease worldwide. Diagnosis based on cultured specimens is the reference standard, however results take weeks to process. Scientists are looking for early detection strategies, which remain the cornerstone of tuberculosis control. Consequently there is a need to develop an expert system that helps medical professionals to accurately and quickly diagnose the disease. Artificial Immune Recognition System (AIRS) has been used successfully for diagnosing various diseases. However, little effort has been undertaken to improve its classification accuracy. Objectives: In order to increase the classification accuracy of AIRS, this study introduces a new hybrid system that incorporates a support vector machine into AIRS for diagnosing tuberculosis. Patients and Methods: Patient epacris reports obtained from the Pasteur laboratory of Iran were used as the benchmark data set, with the sample size of 175 (114 positive samples for TB and 60 samples in the negative group). The strategy of this study was to ensure representativeness, thus it was important to have an adequate number of instances for both TB and non-TB cases. The classification performance was measured through 10-fold cross-validation, Root Mean Squared Error (RMSE), sensitivity and specificity, Youden’s Index, and Area Under the Curve (AUC). Statistical analysis was done using the Waikato Environment for Knowledge Analysis (WEKA), a machine learning program for windows. Results: With an accuracy of 100%, sensitivity of 100%, specificity of 100%, Youden’s Index of 1, Area Under the Curve of 1, and RMSE of 0, the proposed method was able to successfully classify tuberculosis patients. Conclusions: There have been many researches that aimed at diagnosing tuberculosis faster and more accurately. Our results described a model for diagnosing tuberculosis with 100% sensitivity and 100% specificity. This model can be used as an additional tool for experts in medicine to diagnose TBC more accurately and quickly.


Background
Tuberculosis (TB) is a major global health problem, which has been ranked as the second leading cause of death from an infectious disease worldwide (1). Diagnosis based on cultured specimens is the reference standard, however results take weeks to process. The bacillus, Mycobacterium tuberculosis, causes this infectious disease (2), which affects mainly the lungs (pulmonary TB), however it can affect other body parts as well (extra pulmonary TB) (3). Mycobacterium tuberculosis invades the host in small infectious droplets in the lower respiratory tract, rather than in the upper respiratory tract (4). Resistance to Mycobacterium TB depends highly on the host's capability to induce an effective T-helper1 immune response (5)(6)(7)(8). Depending on the intensity of exposure to the bacteria, the risk of becoming infected could be high and the infection could last for a long time (9,10). Typical symptoms of pulmonary tuberculosis are persistent coughs, fever, weight reduction and night sweats (11). Sputum smear microscopy is the most common method for diagnosing TB, yet another method for the diagnosis of TB is the use of rapid molecular tests. Countries with a better developed laboratory capacity use the culture method to diagnose TB (3).
Modern computer technologies have assisted medical doctors to store vast amounts of records. It is obviously impossible for an unassisted human to process this huge amount of data. On the other hand if available medical data (such as patients' laboratory data and knowledge and experience of experts) are not in an easily compre-hensible format, they become less useful. The human immune system performs like a de-centralized learning system; it learns ways to identify patterns and then uses memory cells to recognize previously identified patterns. These very significant computational features have motivated researchers to create Artificial Immune Systems (AIS). Artificial immune systems were built primarily for feature extraction or data clustering, Watkins (12) introduced a supervised learning algorithm named the Artificial Immune Recognition System (AIRS) and focused on classification problems (13). This was the first version of AIRS that was later dubbed as AIRS1. Performance of AIRS1 when applied on various benchmark classification problems was comparable to other highly-regarded supervised learning techniques for the same benchmarks (14). Moreover, AIRS1 has shown significant achievements on a wide range of classification problems (13), and in medical decision making, classification plays a significant role. Cuevas et al. argued that bio-inspired computing has proven to be useful for classification problems (15).
Brownlee decided to refine the process of AIRS by reducing the complexity of the AIRS approach while maintaining the accuracy of results, and introduced AIRS2 (16). Watkins et al. showed that AIRS2 is simpler and computationally more efficient than AIRS1 and declared AIRS2 as the standard AIRS implementation (14). Performance of AIRS has been the subject of numerous researches (17,18) and AIRS has been found to have many successful applications in diagnosing various diseases (19)(20)(21). Analysis of our literature review revealed that relatively a few efforts have been made to improve the classification accuracy of AIRS; the majority of published articles have applied AIRS to solve a particular classification problem.
The AIRS uses k-Nearest Neighbor (kNN) as a classifier, and in machine learning, kNN was developed in a way that it identifies patterns of data without demanding for an exact match to any cases or stored patterns, which relatively speaking, means low accuracy. In addition, selecting k for kNN affects the performance of kNN, if k is chosen to be too small, the result might be sensitive to noise in data, and if k is too large, then the neighborhood may include points from other classes (22).

Objectives
This study made the following modification to the process of AIRS2: instead of using kNN as a classifier, this research used the Support Vector Machine (SVM), which is a very robust classifier with many applications. The effects of these changes were analyzed by applying the new model to a real tuberculosis dataset. Obtained classification accuracy was then compared with other classifiers using the same dataset. This new hybrid SVM-based AIRS2 system is dubbed as SAIRS2.

Patients and Methods
This cross-sectional study was carried out during the year 2014; it used SVM, which has a root in the advanced statistical learning theory. It is one of the most accurate and robust algorithms among all well-known algorithms; it is insensitive to the number of dimensions, and it needs only a dozen instances for training (22). The SVM is able to maximize the predictive accuracy of a model without over-fitting the training instances. It tries to find an optimal hyper plane in a multi-dimensional space, which separates cases of different classes (23). An ideal hyper plane can be constructed through an iterative training algorithm. In a two-class learning task, for example, SVM makes sure that the best hyper plane is found through maximizing the margin between the two classes. The margin is the shortest distance between the closest data points to a point on the hyper plane (22). In cases when training data cannot be separated without error, SVM needs to separate the training set with a minimal number of errors, which are also known as classification error (24).
The SVM tries to exclude training errors from the training set. The error-free part of the dataset can be separated without errors. Support Vector Machine models use a cost parameter C, in order to allow some flexibility in separating the classes. The cost parameter C creates a soft margin that allows some misclassifications (25); increasing C improves the classification accuracy for the training data; however, this may also lead to over-fitting, because it increases the cost of misclassifying points as well (26). The problem of finding the optimal hyper plane is an optimization problem and Cortes et al. used the saddle point of Lagrangian function to solve this problem (27). This classical optimization problem is solved by standard quadratic programming techniques and programs (27). The complexity of calculations does not depend on the dimension of the input space but on the number of support vectors, which is a small subset of the training vector (28); they assist model interpretation (29). Similarity and dissimilarity of data objects are quantified by kernels, which can be constructed for a broad range of data objects (29).
There are a number of kernels that can be used in SVM models. These include linear, polynomial, radial basis function (RBF) and sigmoid. This research uses RBF, which is the most popular choice of kernel used in SVMs. This is chiefly due to their finite and localized responses across the full range of the real x-axis (30).
The RBF is defined in Equation 1: Where γ is a kernel parameter. Increasing the value of γ improves the classification accuracy, yet this can also lead to over fitting (27,31,32).

Pseudo Code of SAIRS2
Box 1 illustrates the pseudo code for the new hybrid algorithm. SAIRS2 uses SVM and the general concept of AIRS2. It creates a random base called memory cell pool (M) and maintains the pool of cells, which are prepared through exposing the system to a one-shot iteration of the training data. As long as the memory cell is inadequately stimulated for a given input pattern, candidate memory cells are prepared. Most stimulated memory cells undergo a process of cloning and mutation. Then the algorithm deals with competition for resources in the development process of a candidate memory cell. The clones compete with each other based on the amount of resources each cell is using and its stimulation value. Competition for resources is necessary to control the size of the Artificial Recognition Ball (ARB) pool, as well as to promote such ARBs that have greater affinity (stimulation) for the antigen that the model is being trained on. The goal was to develop a memory cell that is most successful in accurately classifying a given antigen. Then the potential candidate memory cell is introduced into the set of already established memory cells, for training. If the memory cell candidate is more stimulated by the training antigen, than the memory cell match, then the memory cell candidate will be added to the set of memory cells. If the affinity between memory cell candidate and memory cell match is less than a threshold, then memory cell candidate replaces memory cell match in the pool of memory cells. The above process repeats until all antigens have been introduced to the system. The proposed algorithm prepares the content of M for the SVM by reformatting the content to the format used by the SVM. When training for all antigens is completed, this algorithm presents the formatted M to the SVM classifier for classification.
This research used Weka LibSVM (WLSVM) (33), which is a wrapper of Lib SVM (32) inside the Waikato Environment for Knowledge Analysis (WEKA) (34) to address the classification problem. 9. Select the B-cell in ARB with the highest affinity to antigen (candidate). If candidate has a higher affinity to antigen than mc, add candidate to M. If mc and candidate are sufficiently similar, then remove mc from M. Return M:prepare content of M for SVM IV. Transfer M to format: run SVM as classifier V. Perform SVM classification using M.

Real Data Set
This study used a tuberculosis data set, taken from the Pasteur laboratory of Amol, Iran. The data was collected during the year 2014, and ethical approval was obtained from the ethics committee. All equipment at the institute was regularly calibrated, and experts measured the clinical variables. For this study, representativeness was very vital therefore it was important to have adequate numbers of instances for both TB and non-TB cases. The initial data contained some missing values; after consulting with the experts, instances with missing values were either replaced by average values of the people of the same sex and age group, or the entire instance was excluded from data analysis. The dataset consisted of 175 samples. Each sample consisted of twenty-one features including: sex, Cluster of Differentiation 4 (CD4) counts, Human Immunodeficiency Virus (HIV), Purified Protein Derivative (PPD), chest pain, weight loss, coughs, night sweats, fever, shortness of breath, hemoglobin concentration, platelet count, total White Blood Cell (WBC) count, neutrophil count, lymphocyte count, erythrocyte sedimentation rate, alanine aminotransferase level, alkaline phosphatase level, lactate dehydrogenase concentration, and the status of TB (positive or negative). Overall, 114 of the samples belonged to the positive class (people who had TB), and remaining 60 samples belonged to the negative class. Table 1 illustrates average values, and standard deviation of numerical features of the data set.

Applied Parameters
Both AIRS2 and SAIRS2 come with user-defined parameters that allow users to control and fine tune these classifiers; their functions are explained below: Artificial Recognition Ball (ARB): represents a number of identical B-Cells and is also a mechanism to reduce duplication and dictate survival within the population. Affinity Threshold Scalar (ATS): is a value between 0 and 1 that when multiplied by the affinity threshold, it provides a cut-off value for memory cell replacement during the training phase. Clonal rate: is an integer value that is used to determine the number of mutated clones a given ARB is allowed to attempt to produce. Hyper-mutation rate: is an integer value that is used to determine the number of mutated clones that a given memory cell is allowed to inject into the cell population. Seed cell: repre-sents an antibody that is drawn from the training set and is used to initialize memory cell and ARB populations at the beginning of training. Stimulation value: is the value returned by the stimulation function; this function is used to measure the response of an ARB to an antigen or to another ARB. The function returns a value between 0 and 1. Total resources: is a parameter, which sets limitations on the number of ARBs allowed in the system. Each ARB is allocated a number of resources based on its stimulation value and the clonal rate (12). Table 2 shows parameter settings and their values that were used to run AIRS2 and AIRS2 algorithms. Here, k is a user defined variable that is used for the KNN algorithm; γ, C and cash memory size are also user defined variables that are used to adjust the SVM. This study used the Waikato Environment for Knowledge Analysis (WEKA); a machine learning software (34) to develop the SAIRS2 classifier. In order to evaluate SAIRS2's performance, this paper chose classifiers within the WEKA and applied them against the same TB data set. Chosen classifiers were:

Restrictions of the Research
This study ran the algorithm only on one computer with Intel core 7 CPU and 8 GB RAM. It is of interest to verify the performance with other computing resources, since the model uses the computer memory to keep the prepared memory cells. A further restriction was that we could not find real data for TB from other medical centers to verify the model.

Performance and Evaluation Measurements
In order to evaluate the performance of the proposed algorithm and compare it with that of benchmark algorithms, this study used classification accuracy, n-fold cross validation, sensitivity, specificity and root mean-squared error.

Classification Accuracy
The accuracy was calculated by dividing the number of truly classified instances by the number of instances in the test phase. The classification accuracy for the dataset was measured according to Equations 2 and 3 (12):

2)
Where T is the set of data items to be classified (the test set), t∈T, t.c is the class of the item t, and classify (t) returns the classification of t by AIRS.

N-Fold Cross Validation
In this approach, the instances were randomly divided to equal stratified subsets. Each instance is placed in one subset. At each iteration, n-1 subsets were merged to form the training set and the classification accuracy of the algorithm was measured on the remaining subset. This process was repeated n times, choosing a different sub-set as the test set each time. Therefore, all data instances were used n-1 times for training and once for testing. The final predictive accuracy was computed over all folds in the usual manner by dividing the number of correct classifications taken over all folds by the number of data instances in all folds. This study used 10-fold cross-validation for evaluation purposes.

Sensitivity and Specificity
Sensitivity refers to the proportion of people with disease who have a positive test result, and specificity refers to the portion of people without disease who have a negative test result (35).

Root Mean-Squared Error
Root mean-squared error is calculated by Equation 4:

Area Under the Curve (AUC)
Receiver Operating Characteristic (ROC) originates from the Signal Detection Theory (SDT) that was developed during the Second World War for the analysis of radar images. Radar operators needed to know whether the blip on the screen represented a friendly ship, an enemy, or just noise. Signal Detection Theory measures the ability of radar receiver operators to distinct these three important signs. This ability of the operators was called the Receiver Operating Characteristic (36). Receiver Operating Characteristic is a useful visualizing technique that is used for assessing data mining schemes; it is used to illustrate the trade-off between true hit rate and false alarm over a noisy channel (35). Graphs of ROC are able to provide a richer measure of classification performance than error cost, accuracy or error rate (37). Curves of ROC illustrate the performance of a classifier regardless of the error costs or class distribution; the vertical axis is used to plot the true positive rate and the horizontal axis represents the true negative rate (35).

FP FP+TN
Where TP is the number of true positives, FN is the num-ber of false negatives, FP is the number of false positives and TN is the number of true negatives. TP and TN are correct classifications; FP is the number of outcomes when the prediction is positive when it is actually negative, and FN is the number of outcomes when the prediction is negative when it is actually positive (35).
The area under the ROC curve (AUC) is a single quantity that summarizes ROC curves. This area denotes the probability that a classifier assigns a higher score to the positive instance than a randomly chosen negative sample (38). The greater the area, the better the model (35). A rough guide for classifying the accuracy of a test is the common academic grading scale (36)

Youden's Index J
One way to summarize the performance of a diagnostic test is to use the Youden's index J, which is a value in the range of zero and one. While a value of one indicates that the test is perfect without any false positives or false negatives, a value of zero indicates that the test is worthless. This index is calculated through Equation 7.

7)
J = Sensitivity + Specifity − 1 J is also equivalent to the AUC (39). This index value is considered by some researchers to be optimal in that sense that both specificity and sensitivity are given the same weight to their errors, thus maximizes the overall rate of correct classification in the absence of a loss function (40).

Comparing Classification Accuracy of SAIRS2 With Other Classifiers
Classification accuracies, sensitivities, specificities, Youden's Index (J Index), Area Under ROC Curve (AUC), and root mean-squared errors (RMSE) obtained with SAIRS2 and the above mentioned classifiers are illustrated in Table 3. This study used 10-fold cross-validation for evaluation purposes. As it can be seen, the performance of SAIRS2 is comparable to the top classifiers used in this study. It can be concluded that SAIRS2 with a classification accuracy of 100%, a sensitivity of 100%, a specificity of 100%, J Index of 1, AUC of 1, and a RMSE of 0 can be used to classify tuberculosis. SAIRS2 ranked excellent (A) among other classifiers in this study.

Discussion
There are different methods for determining whether or not someone has TB, such as culturing, sputum smear examination and molecular tests, however these methods take a long time to process results, need special equipment and are expensive. In special cases such as diagnosing TB in children, smear and culture method have been reported to have less than 50% accuracy and researchers are increasingly looking for new ways of rapid and accurate diagnosis (41). Furthermore, researchers have become more interested in studying new aspects of tuberculosis identification, including the use of artificial intelligence (21). Early and accurate identification of TB helps prevent, treat and control this disease. Timely and accurate diagnosis leads to timely treatment, which in turn reduces the risk of transmission to others. In addition smear microscopy has shown low sensitivity and versatility (42).
One of the most important decision-making tools in medicine is classification (43), and data classification problems are common in many fields including medicine (19). Huang et al. indicated that for saving patients' lives, classification accuracy of medical data sets has to be optimal (20).
Researchers have used only a few AIRS-based classifiers for diagnosing various diseases, and all of them have reported that their methods improved classification accuracy. Because of the need for more accurate classifiers, this study modified AIRS2 in such a way that the kNN was replaced by SVM. A real medical dataset, the tuberculosis dataset from the Pasteur laboratory of Iran, was used in this study.
For the same data set used in this study, other researchers obtained a classification accuracy of 99.14% with sensitivity and specificity of 87% and 86.12%, respectively; their model was named Fuzzy AIRS (21).
Currently many people are infected by and die from tuberculosis, which has impacts not only on their life but also on their family members and the society as a whole. There have been many researches on diagnosis of tuberculosis, yet we still need to do more to diagnose this disease faster and more accurately. Applications of computer science in medicine has entered a period of rapid discovery, because the technology allows us to find patterns in historical data and gain knowledge that can help experts diagnose diseases such as tuberculosis faster and more accurately.
Our study described a model for diagnosing tuberculosis, and revealed that SAIRS2 with an accuracy of 100%, sensitivity of 100% and specificity of 100%, Youden's Index equal to one, AUC equal to one, and RMSE equal to zero for TB classification is very well comparable with other top techniques evaluated in this study. Therefore it can be concluded that SAIRS2 is a highly sensitive and specific tool that can be used as an additional tool by experts in medicine to diagnose tuberculosis more accurately and quickly. SAIRS2 is an improvement of AIRS2 in terms of classification accuracy for the tuberculosis data set. SAIRS2 is open to other application areas.
Although, it might be reasonable to say that revisions of AIRS2 provide great accuracy, this cannot be blindly accepted as a characteristic of SAIRS2. As with all learning algorithms, the domain to be learned has a greater influence on the performance of the algorithm than any other factor, and authors recommend further studies and simulations of TB cases.