Skip to main content
Acta Informatica Medica logoLink to Acta Informatica Medica
. 2019 Jun;27(2):103–107. doi: 10.5455/aim.2019.27.103-107

An Expert System to Diagnose Pneumonia Using Fuzzy Logic

Leila Akramian Arani 1,, Frahnaz Sadoughi 2, Mustafa Langarizadeh
PMCID: PMC6688294  PMID: 31452567

Abstract

Introduction:

Pneumonia is the most common and widespread killing disease of respiratory system which is difficult to diagnose due to identical clinical signs of respiratory system.

Aim:

In this research, to diagnose this, a structure of a fuzzy expert system has been offered. This is done in order to help general physicians and the patients make decision and also differentiate among chronic bronchitis, tuberculosis, asthma, embolism, lung cancer.

Methods:

This system has been created using fuzzy expert system and it has been created in 4 stages: definition of knowledge system, design of knowledge system, implementation of system, system testing using prototype life cycle methodology.

Results:

The system has 97 percent sensitivity, 85 percent specificity, 93 percent accuracy to diagnose the disease.

Conclusion:

Framework of the knowledge of specialist physicians using fuzzy model and its rules can help diagnose the disease correctly.

Keywords: Expert systems, Fuzzy Logic, diagnosis, pneumonia

1. INTRODUCTION

Respiratory system is one of the most important systems of the body which helps human life continue (1). Lung diseases like pneumonia, chronic bronchitis and tuberculosis are among the second dangerous diseases in the world (2). Pneumonia is the inflammation of lung which is caused by lung infection by different microorganisms. Clinical signs of pneumonia are various and they often follow fever, shaking, night perspiration, chest pain, cough, dyspnea, sputum and headache. Due to strong similarity among clinical signs of respiratory system diseases, diagnosing pneumonia correctly is time-consuming and also costs a lot. This makes troubles for doctors to diagnose pneumonia and so they ask experiments to be done several times before any decision making. Therefore, in order to diagnose this disease correctly and save the patients suffering this disease, it is necessary to get access to experience and the knowledge of specialist physicians continuously (3).

Methods have been used and in this regard, using computer in order to make decision about medicine has been widely used and accepted (4).Expert system functions using ambiguous information. Unreliability about information hurdles making the best decision or even it causes improper decisions by the system so that it leads to improper treatment in medicine (5). Lots of theories such as classical probability Bayesian probability, Shannon theory, Dumpster–Schafer theory and fuzzy sets theory have discussed and reviewed unreliability. Fuzzy set theory which quantifies the quality aspects is related to a group of objects which have indistinguishable boundaries, and also reasoning which uses natural language. Object memberships in any of these groups are described using concepts called membership degree (6).

In order to diagnose diseases several fuzzy expert systems have been developed in medicine such as Fuzzy expert system for diagnosis of pneumonia in children (7), a fuzzy expert system for heart disease diagnosis (8), fuzzy rule-based expert system for diagnosing asthma (9), evaluation of pulmonary function tests by using fuzzy logic theory (10), a fuzzy rule based lung disease diagnostic system combining positive and negative knowledge (11) and fuzzy rule based inference system for detection and diagnosis of lung cancer (12).

2. AIM

The purpose of this research is to offer fuzzy expert system in order to diagnose pneumonia. This system can make distinction between the patients suffering pneumonia and the patients suffering other respiratory diseases such as chronic bronchitis, asthma, lung cancer, embolism and tuberculosis.

3. METHODS

3.1. Architecture of System

Fuzzy expert system consists of 17 fuzzy input variables, knowledge base, inference engine, fuzzy fire, defuzzifire, 6 output fuzzy variables and user interface.

2.1.1. Knowledge base of System

The knowledge of system is derived from the experience of expert doctors, lung specialist doctors and the books and articles related to respiratory system. For differential diagnosis of pneumonia, effective parameters and clinical signs have been detected and their relations with chronic bronchitis, tuberculosis, asthma and lung cancer were identified. The knowledge of system is depicted and organized using decision table and semantic network. Clinical signs for disease diagnosis are placed in the columns of decision making and the diseases as the goals of system are placed in rows of the table. The symptoms shown at the intersection of any rows with each column, demonstrate the relationship degree between clinical signs and the disease. For any of the diseases, a semantic network was designed according to decision table. The system objectives are placed at nodes on the top of semantic network and decision making parameters are put in the middle nodes and volume of decision parameters are in leaves. The bows show the relation among nodes. For each disease, the clinical signs which have equal volumes in decision table are put in one group in semantic network (OR operator). The signs like Tachypnea which are related to both the age and respiratory rates of the patient, are connected to the operator AND in leaves. Decision table in Table 1 and semantic network related to pneumonia in Figure 1 have been demonstrated.

Figure 1. Semantic network to diagnose pneumonia Circle: It shows the objective (node), clinical signs and the required volumes Oval: It is the symbol of and & or logic operators which shows the relation between nodes Arrow: It shows the relation between nodes.

Figure 1.

Due to using fuzzy logic method, knowledge base system consists of fuzzy sets, membership functions and also fuzzy rules. For each input and output fuzzy variables of the system, fuzzy sets and membership functions are defined according to linguistic volumes determined by doctors and their explanations are in 2.1.2. For each pneumonia and the other diseases, sets of separate fuzzy rules were defined according to semantic network. Their weights of these rules were defined based on written symptoms in the decision table. The weights considered for the rules were 0/1, 0/2, 0/5, 0/8, and 1 and were based on the comments of specialist physicians. Therefore fuzzy rules which have the weight of 1 and 0/8, have the most effect on the diagnosis the above-mentioned system (Figure 2).

Figure 2. Fuzzy rules for created system. Each row in this figure is a fuzzy rule and the numbers in paranthesis are the weights of the rules.

Figure 2.

2.1.2. Input and output fuzzy variables and membership functions

Clinical signs and important parameters which are considered for differential diagnosis are: fever, cough, sputum, chest pain, breath distress, decrease of breath sounds, rale and wheezing sounds, tachypnea, tachycardia, decrease of systolic blood pressure, hypoxia, leukocytes, Leukocytosis, lung infiltration. Input system is a vector which consists of 17 input fuzzy variables that its membership functions are offered as followings:

Input variables of body temperature, systolic blood pressure, the number of the white cells and the pressure of oxygen have sigmoid membership functions. For input fuzzy variables of cough and sputum, Gaussian and bell functions in turn were used.

For each input variables of breath rates and heart rates, trapezoid function was defined based on 3 age groups of adults, children and infants. For fuzzy variable of the age, three membership functions were defined for three age groups.

Input fuzzy variables of chest pain, rale and wheezing sounds, decrease of breath sounds, chest X-ray, positive sputum culture, dyspnea and breath distress have fuzzy sets of [0-1] and sigmoid membership function was defined for them.

The system has 6 output fuzzy variables for each pneumonia, chronic bronchitis, tuberculosis, embolism, asthma, and lung cancer. For each output variables, Membership functions were defined which consists of lack of disease, probability of disease, strong possibility of disease and certainty about disease.

2.1.3. Inference engine with fuzzy fire and defuzzy fire

Inference fuzzy engine considered for the system is a kind of Mamedani fuzzy model which does de fuzzy fire measurement using fuzzy rules, membership functions and input variables and it determines the certainty level of disease by the system. In the stage of fuzzy making, inference fuzzy engine makes the amount of input fuzzy variables fuzzy using fuzzy rules and membership functions available in the hypothesis of each rule and determines a membership degree for each input in fuzzy set. To determine the level of reliability of hypothesis part of rules, S_Norm and T_Norm operators were used. To measure output fuzzy sets for each output variables, max- min product method and membership functions which is available in the resulting part of fuzzy rules were used. For each group of rules related to one disease, aggregator was determined. The resulting output fuzzy sets from fuzzy rules for each disease were aggregated using Sum function. To change output fuzzy sets into a digital volume between 0 and 1, DE fuzzy fire method calculation of Centroid was used.

2.1.4. User interface

In order to design and develop parts of fuzzy expert system of pneumonia diagnosis such as user interface, inference engine and knowledge base, the tool box of fuzzy logic in Matlab software version R2009a was used. User interface designed for this system consisted of 2 output and input parts.

Input part receives related data about age and clinical signs of the patients from user and sends them to fuzzy inference engine as digital volumes. The output part of user interface receives the resulting output of disease diagnosis from inference engine. Then it announces the final diagnosis of the disease in addition to certainty degree for the user. User interface is capable of demonstration of rules and three-dimensional surfaces (the relationship between output and input variables) at the time of system running.

The demonstration screen of rules helps the doctor and user find out which rules were effective in output and on what basis the system has made decision and diagnosed the disease. The surface demonstration screen shows the relationship between output and input volumes. Therefore, the system provides the ability to explain reasoning and response for the user in graphic form. User interface system in Figure 3 has been shown at the time of application of the system for a specific patient.

Figure 3. It shows user interface created in the running time for one patient suffereing from penumenia.

Figure 3.

4. RESULTS

In the evaluation stage, the results achieved from system are compared with final diagnosis recorded in the medical record of the patients and for this regard; Kappa statistic testing SPSS software is used.

The volume of K (the correspondence degree between the system and doctor‘s diagnosis) was discussed based on Landis and Koch interpretation table (13).

Out of 188 medical record of the patients, 176 cases were based on doctor‘s diagnosis and 12 cases of diagnosis were different from the doctor‘s diagnosis and the output of the Kappa test for the K variable was 0/8437. It meant that based on Table 2, the system output was in perfect agreement with final diagnosis recorded in medical record.

The created system for the patients suffering from pneumonia was right in 131 cases and for 53 patients suffering from the other respiratory system diseases was right in 45 cases. The system has 97% sensitivity, 85% specificity and 93% accuracy.

The Receiver Operating Characteristics (ROC) curve and the area below the curve are to evaluate and judge the efficiency and the performance of the system (14).

The area below the curve for the Expert System to Diagnose Pneumonia in this article is obtained as 94 % using the seventh and eighth relationship.

5. DISCUSSION

In expert fuzzy system for the diagnosis of pneumonia of the children, the table of decision making for the system has not been used because the only objective of the system was to diagnose pneumonia. However to determine the relationship between 7 clinical signs and pneumonia, two methods of Mamedani method with max-min and multi-dimension analytic method were used. That was for 115 medical records of children suffering from pneumonia. The figures obtained show a difference between 5 clinical signs and pneumonia in the mentioned system. In order to measure the relationship between features and diseases accurately, in addition to experience of specialist physicians, a mix of methods of multi-dimension analytic method and Mamedani fuzzy inference system should be used.

In the evaluation system of lung function experiments using fuzzy logic which was done by Umituncu, like fuzzy expert system for pneumonia created in this research, decision making table has been used to show and organize the system knowledge. However, columns and rows in decision table are two parameters for making decision and the purpose is at the intersection of rows and columns. But in this research in Table 1, the purposes which are the very diagnosis of the diseases are in the rows. Since there is a cause and effect among clinical signs of the disease, the application of this kind of relations in knowledge base causes the system to function more intelligently and deliver better and more certain diagnosis.

In expert system of Asthma A and B, semantic network is used to demonstrate knowledge system. In this system, clinical signs are grouped in the form of module based on doctor‘s comments and ideas. They have been drawn in abstract form and the relation between nodes and the way of classification inside modules is not clear. In the decision system to diagnose lung diseases, making decision tree was used instead of semantic network to demonstrate knowledge structure in knowledge base. The reasoning method was feed forward but since in expert systems with fuzzy logic, all rules are implemented simultaneously, decision tree and feed forward and backward methods have no application.

Various and different input fuzzy variables were used to diagnose diseases in expert system. These variables are parts of decision making parameters and clinical signs. In the diagnosis system of lung diseases based on fuzzy logic using positive and negative knowledge, 140 clinical signs were used to diagnose 19 lung diseases. In the diagnosis system of children penumenia, 7 clinical signs of Dyspnea, hypoxia, chest X-Ray temperature of body, heart rate and respiratory rate were used while in diagnosis system of respiratory diseases with fuzzy logic and inference system based on fuzzy logic to diagnose lung cancer, 4 and 5 input fuzzy variables were used respectively which dyspnea, chest pain, sputum and chest X-Ray are common. The more variables as inputs, the more accurate the decision will be because more clinical signs are involved to diagnose the disease. However it would be difficult and complex to design the system and it would take more time to diagnose the diseases. So, a balance should be created among the number of decision making and the accuracy of the results and complexity. It is better to consider important and effective parameters as input variables of the system. As the number of disease diagnosed by the system increases such as diagnosis of pneumonia in this article, it is necessary to use more input fuzzy variables to make distinction among diseases.

Rules in knowledge base are used in all expert systems but in systems in which fuzzy logic has been used, there are fuzzy rules which have weights. Weights in fuzzy logic rules determine the effectiveness of resulting part or the results of rules in output system. Fuzzy rules with the equal weight of 1 have been used in all previously-mentioned systems in this article. It means that all the fuzzy rules have had equal effectiveness to determine the system but in the fuzzy expert system delivered in this research, different weights of 0/2 0/8‘0/5‘0/3‘0/ have been used based on expert doctor‘s comments and also based on the amount of effect that current variables had in introductory part of the rules. For the variables that have negative effect on diagnosis of the disease (as in Table 1), some other rules as opposite ones with the weight of 0/1 have been considered.

Expert system which is based on fuzzy rules to diagnose Asthma A an B and was used 106 patients, has the sensitivity of 94% and specificity of100%. Expert system to diagnose children pneumonia had used two methods of inference fuzzy max-min multi-dimension analytic to determine the relations of variables (clinical signs) with disease diagnosis which its output had been tested for both methods and also for 38 medical records of the patients. The validity of diagnosis prediction was too close and it was 78/3% and 75/3%. These figures have a marginal difference of 25% from the accurate performance obtained in this article (only the comments of experienced doctors were used to determine the relation between clinical signs and diagnosis). The amount of accuracy obtained in this article for the performance of the system was 93%.

Since it is likely that the report about sensitivity and accuracy in the form of digital ones cannot demonstrate the performance of the system very well, the curve demonstrating the receiver‘s performance can show the system performance graphically using SPSS software. In this figure, as the distance between intersection point of the two parameters and diameter increases and turns left and goes up and also the area below the curve increases, it shows better and more efficient performance of the system. The curve showing the receiver‘s performance to determine the amount of the accuracy in the expert system performance mentioned in the background of the article, has not been drawn.

6. CONCLUSION

Fuzzy logic is based on natural language and it is also based on the structures of quality description in informal languages. Also, fuzzy logic can tolerate uncertain fuzzy inputs properly and mathematics concepts used in fuzzy reasoning are simple. So, it is better to use fuzzy set theory in order to develop expert systems based on knowledge in medicine which helps us diagnose and treat the diseases. This is done because there are so many ambiguous terms in medicine which are changed into clear digital numbers in computer using fuzzy logic.

Acknowledgment:

This study was part of M.S. a thesis supported by Iran University of Medical Sciences.

Author’s contribution:

L.A collaborated in analyzing, designing and developing fuzzy expert system and drafting the article. F.S and M.A revised the article critically and also gave final approval of the version to be published

Conflicts of interest:

There are no conflicts of interest.

Financial support: and sponsorship:

Nil.

REFERENCES

  • 1.Miettinen OS, Flegel KM, Steure J. Clinical diagnosis of pneumonia, typical of experts. Journal of Evaluation in Clinical Practice. 2010;14(2):343–350. doi: 10.1111/j.1365-2753.2007.00873.x. [DOI] [PubMed] [Google Scholar]
  • 2.Chastre J, Fagon JY. Ventilator-associated pneumonia. American journal of respiratory and critical care medicine. 2010;165(7):867–872. doi: 10.1164/ajrccm.165.7.2105078. [DOI] [PubMed] [Google Scholar]
  • 3.Koenig SM, Truwit JD. Ventilator-associated pneumonia: diagnosis, treatment, and prevention. Clinical microbiology reviews. 2010;19(4):637–657. doi: 10.1128/CMR.00051-05. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Sim I, Gorman P, Greenes RA, Haynes RB, Kaplan B, Lehmann H. Clinical decision support systems for the practice of evidence-based medicine. Journal of the American Medical Informatics Association. 2010;8(6):527–534. doi: 10.1136/jamia.2001.0080527. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Masic I, Ridjanovic Z, Pandza H, Masic Z. Medical Informatics. Avicena. Sarajevo. Chapter: Computer Support to Medical Decision Making. 2010:255–280. ISBN: 978-9958-720-39-0. [Google Scholar]
  • 6.Phuong NH, Kreinovich V. Fuzzy logic and its applications in medicine. International journal of medical informatics. 2010;62(2-3):165–173. doi: 10.1016/s1386-5056(01)00160-5. [DOI] [PubMed] [Google Scholar]
  • 7.Pereira J, Tonelli P, Barros L, Ortega N. Clinical signs of pneumonia in children: association with and prediction of diagnosis by fuzzy sets theory. Brazilian journal of medical and biological research. 2010;37(5):701–709. doi: 10.1590/s0100-879x2004000500012. [DOI] [PubMed] [Google Scholar]
  • 8.Adeli A, Neshat MA. Fuzzy Expert System for Heart Disease Diagnosis. MEC. 2010;11:542–548. [Google Scholar]
  • 9.Fazel Zarandi MH, Zolnoori M, Moin M, Heidarnejad HA. Fuzzy Rule-Based Expert System for Diagnosing Asthma. Transaction E: Industrial Engineering. 2010;17(2):129–142. [Google Scholar]
  • 10.Uncu U. Evaluation of Pulmonary Function Tests by Using Fuzzy Logic Theory. Med System. 2010;34:241–250. doi: 10.1007/s10916-008-9235-8. [DOI] [PubMed] [Google Scholar]
  • 11.Phuong NH, Kawak YS. LDDS-A Fuzzy Rule Based Lung Disease Diagnostic System combining positive and negative knowledge. Institute of Information Technology, National Center for Natural Science and Technology. 2010:1653–1659. [Google Scholar]
  • 12.Lavanya K, Durai S. Fuzzy rule based inference system for detection and diagnosis of lung cancer. International Journal of Latest Trends in Computing. 2010;2:165–171. [Google Scholar]
  • 13.Landis JR, Koch GG. The Measurement of Observer Agreement for Categorical Data. Biometrics. 2010;33:159–174. [PubMed] [Google Scholar]
  • 14.David J, Robert J. A simple generalization of the area under the ROC curve to multiple class classification problems. Machine Learning. 2010;45:171–186. [Google Scholar]

Articles from Acta Informatica Medica are provided here courtesy of Academy of Medical Sciences of Bosnia and Herzegovina, Sarajevo, Bosnia and Herzegovina

RESOURCES