# Diagnosis of Chronic Diseases Based on Patients’ Health Records in IoT Healthcare Using the Recommender System

Authors: Y. A. Nanehkaran; Zhu Licai; Junde Chen; Qiu Zhongpan; Yuan Xiaofeng; Yahya Dorostkar Navaei; Sajad Einy
Journal: Wireless Communications and Mobile Computing
 (2022)

---

## Abstract

Due to the growth of IoT applications, especially health care, the information of patients’ health records using data collection from IoT-connected devices has been considered. Biological data of patients in the health record helps to monitor the patient’s status and identify various diseases. Chronic diseases are a type of silent disease that, if not diagnosed in time, can cause irreparable damage to patients. The use of patients’ medical record data for early diagnosis of chronic diseases has recently attracted the attention of many researchers. On the other hand, the application of machine learning methods in the form of recommender systems has taken an important step in improving medical services and health care. In this paper, a medical recommender system was presented to identify and treat chronic diseases using an IoT device. In the present method, the electronic patient health record dataset that is loaded in the PhysioNet data repository has been used. In the present dataset, patients’ health records have been recorded according to the identified diseases and the physician’s diagnosis. In the proposed method, theK-nearest neighbor classification method is used to identify the type of disease, and the collaborative filtering method is used to find the appropriate treatment for patients. The results of the implementation of the proposed method show that this approach, based on the use of symptom similarity among patients, has good accuracy in diagnosing and predicting chronic diseases and has provided higher results than previous methods.


---

## Body

## 1. Introduction

With the growth of advances in intelligent equipment, much attention has recently been paid to the expansion of healthcare monitoring systems in medical centers. Therefore, the development of telecommunication technology-based methods that are able to aggregate essential patient information without human intervention has been welcomed in research centers around the world. Recently, IoT-based technologies have been used for healthcare and patient monitoring, in which various medical devices, sensors, and diagnostic tools can be considered as smart devices or objects that make up the main body of IoT networks [1–4].With the abundant volume of IoT-related datasets, extracting useful information from this data is a challenging task. Especially in the healthcare sector, there is a huge amount of data related to patients’ tests, doctors’ opinions, types of diagnosed diseases, and medications needed by patients. Therefore, finding data on the treatment of a particular disease and specialists’ opinions about it has become a hard issue. Therefore, having guidelines for using this data can be useful. In IoT healthcare systems, recommenders play a guiding role. Recommendation systems have been developed to provide suggestions to users and companies or organizations to eliminate the challenge of data volume and the existence of similar information. Recommenders are adjusted based on the user’s preferences and try to provide useful information according to the experience of other users as well as the user’s goals [5–9].The Internet of Things has ushered in a new era in the healthcare industry by integrating medical equipment. Patient data can be collected based on sensors embedded in IoT-connected equipment. However, data manipulation and the effective use of patient information require a precise mechanism. In health care, effective diagnosis of the disease based on patient data and finding appropriate treatment remains an important challenge. Recommender systems are a critical step in promoting IoT benefits. Recommender systems generally include procedures that identify the user’s needs based on the information available and provide the best solution for the user. Given the vast amount of information available through the Internet of Things, patients are likely to receive a variety of recommendations for services or treatment of the disease. Therefore, choosing between these approaches requires a precise mechanism and effective recommending system [10–13].Over the past few years, we have seen some remarkable studies on recommendation systems. In [14], an IoT-based efficient community-based recommender system for diagnosing the types of cardiac disease and suggested recommendations related to the treatment has been proposed. In [15], an ontology-driven personalized food recommendation in IoT-based healthcare system has been proposed. In [16], a recommender system using software-defined networking in IoT-based smart healthcare ecosystem has been designed. In [17], a recommender system was introduced which was intended for patient’s behavior correction based on gathering various health state parameters and lifestyle-related data. In [18], an integrated recommendation system into connected health has a design that will expand on the opportunities for better data accessibility and use them for chronic diseases. In [19], a framework has been developed in which decision tree and support vector machine (SVM) techniques were used for predicting hypertension.Recommended systems have been increasingly used by many applications such as e-commerce and e-health due to their ability to automatically extract useful information and predict and recommend appropriate results to consumers [7, 8, 20]. Therefore, a referral system for chronic disease management is needed to minimize both the risk of such a disease and its cost [21–24].In recent years, a pattern of chronic diseases in the Middle East, like the rest of the world, has begun to emerge [25, 26]. These diseases appear in the form of obesity, heart disease, diabetes, and other chronic diseases. This increase in chronic illnesses, coupled with an increase in inactive lifestyles in the Middle East, has put a lot of pressure on healthcare providers, especially when trying to ensure patient follow-up that occurs after each treatment change [27]. The rapid development of information and communication technology has created a new era for researchers to play a number of e-health programs that play an important role in improving health services [28].Therefore, in this study, patients’ health records have been used in order to create a referral system for diagnosing and predicting chronic diseases. In the present study, the electronic patient health record dataset uploaded to the PhysioNet data repository will be used. In the present dataset, the patients’ health records have been recorded according to the identified diseases and the physician’s diagnosis. In the proposed method, symptoms related to various diseases are trained based on the type of disease extracted from the dataset by the nearest neighbor classification method. In the nearest neighbor classification method, patients are classified according to the symptoms of the disease, and the registered diagnosis for these patients is presented as a recommendation in the proposed medical advisor system. In order to evaluate the proposed method, the criteria of accuracy, sensitivity, and accuracy, the recommendations provided will be used, and eventually, the proposed method will be compared with other existing methods in this field. It is expected that the proposed method, based on the use of similarity of symptoms among patients, will have good accuracy in diagnosing and predicting chronic diseases.The purpose of this paper in the first step is to find the type of disease based on the symptoms of patients collected through their medical records. Then, the next step is to identify the stage of disease progression and the necessary treatment for it according to the medical records of other patients in this field as well as the opinions of experts. In fact, the recommending system in the proposed method first tries to diagnose the type of chronic disease and then, by finding similar patients with similar symptoms from the archives of medical records, uses the opinions of their treating physician and its specific drugs.The motivation of this article is that it is difficult to diagnose chronic diseases due to the fact that chronic diseases grow secretly, and most patients do not have any specific symptoms. On the other hand, the treatment of chronic diseases requires a lot of expertise and experience from the doctor. Patients with chronic diseases may be at risk based on misdiagnosis. Therefore, the existence of a platform to share the experience of physicians specializing in chronic diseases seems necessary. In this paper, this platform is introduced as a medical referral system. This recommender system consists of two stages. In the first stage, according to the patients’ health records, the type of chronic disease is diagnosed. Given that laboratory results vary in chronic diseases, the best way to diagnose the type of disease is to compare the patient’s laboratory data with the types of patients with chronic diseases. So we have a multiclass problem that every class is a kind of chronic disease. In the present article, the nearest neighbor method has been used to classify new patients. In this method, the characteristics of each patient’s medical record are compared with other patients in the dataset, and based on the similarity to patientK, the new patient class is determined. After determining the type of chronic disease, in the next step, we will determine the treatment required for chronic disease. At this stage, according to the treatment prescribed for similar patients based on the participatory filter method, we will recommend treatment for new patients to treating physicians. According to this method, each patient receives several treatment recommendations according to the previous similar patients, which will determine the majority vote in the appropriate treatment for the patient.The main contribution of the article is summarized as follows:(i)
Diagnosis of the type of chronic disease using the nearest neighbor classification method based on data collected from medical devices in the Internet of Things that are stored in patients’ health records(ii)
Examine the medical records of all patients for accurate diagnosis of the disease(iii)
Identify patients similar to the new patient in a specific type of chronic disease based on the patient’s symptoms and physicians’ supervision to determine the stage of disease progression(iv)
Recommendations for early treatment of chronic disease based on the health records of similar patients using the collaborative filtering methodIn the rest of this paper, in the second part, clustering methods based on collective intelligence in the wireless sensor network will be examined. In the third section, the proposed method will be described in detail. In the fourth section, the test results and evaluation of the proposed method will be presented. In the fifth section, conclusions and future work will be presented.


## 2. Related Works

Due to the importance of early diagnosis of chronic diseases, many researchers have tried to provide medical recommendation systems, whose studies will be briefly reviewed.In 2020, Mustaqeem et al. developed a common filtering method based on multistage clustering. This method is applied in the monitored dataset for four different types of cardiovascular disease. Patient data are categorized according to their respective disease classes based onk-means clustering. A query patient who is once directed to the correct division of the disease needs to obtain similarity scores from a reduced subcluster, thus improving system performance. Each disease partition has a separate recommendation process that modulates and helps improve system scalability [29].In 2020, Saha et al. provide an overview of the challenges associated with existing medical referral systems. By improving machine learning techniques, the referral system offers various opportunities for medical science. Systems can operate more efficiently through deep learning and solve complex problems, even when the dataset is diverse and unstructured [30].In 2018, Chen et al. introduced the DDTRS system to maximize the use of advanced medical technology in advanced hospitals and the rich medical knowledge of experienced physicians. First, to accurately identify the symptoms of the disease, the density-peaked clustering analysis (DPCA) algorithm for clustering the symptoms is introduced. In addition, communication analysis of disease diagnosis rules and disease treatment rules was performed separately by the Apriori algorithm [23].In 2018, Jabeen et al. developed an efficient IoT-based referral system that diagnoses heart disease and its type and provides physical and dietary advice. The first part intends to collect patient data remotely using biosensors. The cardiovascular prediction model is then implemented, which can diagnose cardiovascular disease and classify it into eight existing cardiovascular classes. The second part is to provide physical and diet plan recommendations to the heart patient according to gender and age groups [14].In 2015, Kamran et al. presented the classification of medical recommendation systems among content-based, participatory, demographic, knowledge-based, and hybrid techniques. The proposed work focuses on providing an overview of referral systems in health care [31].In 2012, Hussein et al. proposed a recommending system approach based on a hybrid method using multiple classifications and integrated shared filtration. The purpose of this article is to provide more accurate and effective recommendations to help patients control their chronic illness and to help healthcare providers to have a 24-hour remote patient monitoring system [1]. In 2014, they also introduced a chronic disease referral system that helps patients control their disease through medical advice and diagnosis. For system accuracy, which is critical in such an application, high-dimensional data must be handled [32].In [33], effective mechanism for the protection of digital library readers’ lending privacy under a cloud environment has been presented. In [34], a large number of research achievements relevant to user privacy protection in an untrusted network environment has been reviewed. In [35], a group of dummy query sequences, to cover up the query locations and query attributes of mobile users and thus protect users’ privacy in LBS has been constructed. In [36], a time-aware deep CF framework which contains dynamic user preference modeling based on attention mechanism and matching score prediction based on DL has been presented. In [37], a location privacy-preserving system for LBS by constructing “cover-up ranges” to protect the query ranges associated with a location has been proposed. In [38], a group of plausible fake queries for each user book query to cover up the sensitive subjects behind users’ queries has been constructed. In [38], a new shapelet discovery method, referred to as Pruning Shapelets with Key Points (PSKP), has been proposed. In [39], a group of fake preference profiles, to cover up the user-sensitive subjects and thus protect user personal privacy in personalized recommendation, has been generated. In [40], this approach to protect the preference privacy behind users’ book browsing behaviors in a digital library has been designed. In [41], a new classification approach based on Wikipedia matching has been proposed. In [42], a topic modeling-based approach to extractive automatic summarization has been presented. In [43], a client-based approach to address plausible but innocuous pseudoqueries together with a user query has been proposed. In [44], a new contextual advertising approach has been proposed, which uses Wikipedia thesaurus knowledge to enrich the semantic expression of a target page.


## 3. Methodology

In this section, we will first review the prerequisites of the proposed method. The details of the proposed method will then be described.


### 3.1. Preliminaries of the Proposed Method

#### 3.1.1.K-Nearest Neighbor (KNN)

TheK-nearest neighbor classification (KNN) method is a group of K records in the training suite that are close to the tested data and, based on the label assignment, find the specific class that dominates the neighborhood. This method demonstrates the fact that in many datasets, one record is unlikely to correspond exactly to another, as well as the fact that conflicting information about the class of a record can result from records close to it must be presented [45, 46]. There are several key elements to this approach:
(1)
A set of tagged records is used to evaluate the record class being tested(2)
To calculate the proximity of records, the criterion of distance or similarity can be used(3)
K value, the number of nearest neighbors, must be specified(4)
The method used to determine the target record class should be determined based on the classes and the distanceK of the nearest neighborIn its simplest form, KNN can assign a class record to its nearest neighbors or most of its nearest neighbors [46].Several key issues affect KNN performance, one of which is the choice ofk. Figures 1–3 show an exam record with an x tag and training records belonging to each of the “-” or “+” classes. If k is too small, the result can be sensitive to noise points. On the other hand, if k is too large, the neighborhood may contain many points from many other classes. The estimation of the best value for k can be obtained by cross-validation. In this method, the value of k starts from a small value, and a constant value is added to it for each iteration. The performance of the algorithm is compared in each iteration, and finally, the value of k, which leads to the best performance for the algorithm, is chosen as the principal value for k.Figure 1
Overall architecture of the proposed method.Figure 2
Flowchart of the proposed method.Figure 3
Average error rate per user.However, it is important to note thatk=1 may also have other values of k, especially for small datasets commonly used in research or classroom exercises. However, with sufficient records, values greater than k are more resistant to noise.Another issue is the approach of combining class labels. The easiest way is to pay attention to the majority vote, but this can be problematic if the nearest neighbors are very diverse in proximity, and the nearest neighbors are more confident of the target class. A more sophisticated method, which is usually less sensitive to the selection ofk, is to measure each record based on its distance. Various options are possible. For example, the weight coefficient is taken from the square of the mutual distance wi=1/dy,z2. This value replaces the last step of the basic KNN algorithm as follows [46]:
(1)Distance−WeightedVoting:cz=v∈Largmax∑y∈Nwi×Iv=classcy.Selecting the distance criterion is another important point to consider in this method. The Euclidean distance or Manhattan distance is usually used as the distance criterion in this method. For two points,x and y, with n properties, this distance is calculated by the following formulas:[46]:
(2)dx,y=∑k=1nxk−yk2Euclidandistance,dx,y=∑k=1nxk−ykManhattandistance,where xk and yk are the attributes k, x, and y, respectively.Although these and various other criteria can be used to calculate the distance between two points, conceptually, the most desirable measure is the distance that is less or more similar between two records, meaning that using this, the criteria probably have the same class tags between the two records, so, for example, if KNN is used to classify documents, it is better to use the cosine criterion instead of the Euclidean distance. Note that KNN can also use data and categories for data with classified or mixed properties until an appropriate distance criterion is defined.


#### 3.1.2. Collaborative Filter

Collaborative filtering (CF) is one of the technologies that has been used in many cases in the recommendation. This method calculates the similarity between users and uses this information to recommend products that have not yet been reviewed by the user. The similarity is based on past reviews of shared items. This similarity is used to generate recommendations for items that have already been reviewed by similar users but have not yet been specified by the user [47, 48].The first step of the CF system is to search for users with similar consumption habits, for example, to calculate the similarity between users. When analyzing users 1 and 5, for optionI1, the difference between their rankings is 1.0. In I2, there is no difference between them, and for I3, the difference is 0.5.If the difference between the two users’ ratings on the options is less than a threshold value, it can be said that the two users are similar. Hence, it can be said that users 1 and 5 are similar. By the same token, users 1 and 2 will not be the same. The similarity calculation can only occur for the options that both users have preferably stated. There are several techniques for calculating similarities between users. The most common methods are shown in Equation (3) [17]:
(3)pa,u=r¯a+∑u=1hru,i−r¯u∗wa,u∑u=1hwa,u.(i)
wa,u is the relationship of the target user to a given user U(ii)
ru,i is the target user score for an i option(iii)
r¯u: the average of all rankings is a target user (u)(iv)
Pa,u is the expected use of the option for user u(v)
h is the value of the best neighbors, and it is at the disposal of each of the systems that use common filterThe second step of CF-based systems is to select a subset of users with higher similarity. Then, the next step is to calculate the forecast. The prediction of inference is the amount of user evaluation of a product that it has not yet evaluated. According to Table1, an example of this calculation can be filled in the gap for user U3 on options I2 and I3 and user U4 for option I2. Therefore, the prediction is made independent of the method used, because it is generated by a weighted average weight of neighbors that has an acceptable coefficient of similarity [17].Table 1
Calculate the distance of a part of the test patients from the educational patients.
Test 1Test 2Test 3Test 4Test 5Test 6Test 7Test 8Test 8Test 9Test 100.40550.42740.36201.97250.35920.35690.85281.35591.35590.72250.34450.28800.32240.24451.98600.31900.31850.80941.33341.33340.89090.30020.59940.61480.55662.04250.50270.50000.97861.44251.44250.51300.49251.02761.03710.98212.21290.89420.89161.28471.66581.66580.25200.88900.55110.56950.50252.04250.45830.45600.94571.42131.42130.56470.44640.28990.32480.24411.99980.31890.31850.82891.34831.34830.89070.29980.31500.34430.27661.98600.32090.31960.84281.35541.35540.83080.30321.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.59571.56541.72060.98121.73761.73321.42021.68141.68142.00451.74431.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.38231.39001.18131.96141.02551.02441.59101.96211.96210.75751.03751.38201.38961.18131.95941.02541.02431.59101.96201.96200.75761.03751.38171.38921.18131.95741.02541.02421.59101.96201.96200.75761.03751.38211.38961.18141.95951.02551.02441.59111.96211.96210.75751.03761.43301.44031.39671.99311.42431.42441.01610.06900.06901.72131.40731.43511.44151.39911.95451.42641.42641.02040.01420.01421.72381.40991.43311.44021.39681.98441.42441.42441.01650.05150.05151.72151.40751.43491.44131.39891.95631.42621.42621.02000.01110.01111.72361.40971.43441.44101.39841.96091.42581.42571.01920.00790.00791.72311.4092


### 3.2. Proposed Method

As mentioned, efforts to predict disease in terms of providing medical services and making the best possible decision on disease samples are very important for hospitals and medical institutions. Failure to make the right decision and take timely action to treat some diseases can pose an irreparable risk to the patient or in some cases the patient may die due to lack of medical care. Chronic kidney disease is one of the diseases that, if not detected and treated in the early stages, can have irreparable consequences for the patient’s health, even if forgotten can lead to death. Therefore, predicting people with this type of kidney disease is an important issue that should be considered.Therefore, in order to solve this problem and predict patients with chronic diseases, a number of predictive models have been proposed. Recently, the data mining group has been used successfully in a variety of applications, including to assist in medical diagnosis and disease prediction. The data mining team can significantly improve the ability to generalize learning systems by training a limited number of samples and then combining their results.Therefore, in this study, we try to use the nearest neighbor to use standard data from the biological test results of some patients with chronic disease, to predict people at risk of chronic disease. The use of the nearest neighbor in disease prediction has been proven in many publications, so in this study, the use of this classification has been confirmed. Figure1 shows the overall architecture of the proposed method.In this study, we want to predict people with these diseases using the nearest neighbor model based on the medical consulting system. In this regard, the data obtained from the test results, which is a standard database in the standard PhysioNet data repository, are entered as artificial data into artificial neural networks and processed by zinc. These data predict the outcome of people at risk for chronic disease.Due to the different amounts of data and the variety of features in the experimental results used in this study as the nearest neighbor input, the number of features in the dataset or in other words the dimensions of the data is high. The large size of the data imposes more complexity on the system and may affect the performance accuracy of the classification model. Therefore, in this research, we first select the feature subset from the preprocessing step to reduce the data size. It is used to reduce the volume of calculations. After this preprocessing step, features that are less relevant to the class tag are removed, and the remaining features are important features that play a key role in teaching the model.Another step of preprocessing used in this research is to convert nonnumerical data to numerical data. Because the nearest neighbors perform better with numerical data, this preprocessing step is necessary to prepare the data for model training. In this preprocessing step, nonnumeric data are replaced with numbers that represent the original data using the variable change method and increase the ease of model training to classify the nearest neighbor. The output data from these preprocessing stages are model-ready data that is injected as input data to the nearest neighbor. The flow diagram of the proposed method is shown in Figure2.As shown in Figure2, the proposed method includes the following steps:Data extraction: in this step, information about the status of patients with chronic diseases is extracted from patients’ health records from the proposed method. This information includes biological tests of patients that were collected during the treatment process in the hospital and recorded in the patients’ health records. There are also ways to treat diseases in patients’ health records. Thus, patients with chronic diseases are used as input to the proposed referral system according to their symptoms.Data classification: due to the fact that the nearest neighbor classifier has been identified as a lazy and sample-based classification, the training process is delayed until the test data is entered. Therefore, in the proposed method, the training process will take place at the time of the new patient’s visit to the hospital. In the process of teaching the biological signs, characteristics of new patients are compared with all patients in the dataset. In comparison between properties, since the values of the properties have been converted to numerical values in the preprocessing step, the Euclidean distance relation is performed. At this stage, according to this value set for K, a number of similar patients are selected as close neighbors. Finally, according to the closest selected neighbor among the close neighbors based on the most similar symptoms, the type of disease of the new patient is determined.In the patient classification stage, we haveN patients in the dataset, each of whom may suffer from some type of disease. Given that in chronic patients the symptoms of patients with one type of disease may vary according to the patient’s progress, the best way to find the type of disease is to compare a new sample with all N previous patients. Given that the KNN classifier inherently compares a test sample with all training samples to find the most similar ones, this classifier is the best option for our work. It is assumed that we have L new patients and each of the patients has M feature that is stored in their electronic health record.Given that the values of features may be in different intervals and the direct use of this data may affect the calculation of similarity between new patients and old patients, the values of patient characteristics should be normalized. In this paper, the max-min normalization method is used [49], which is shown in
(4)NormilizedData=Xi−minXmaxX−minX.Xi represents the original data value, minx the lowest possible value for the data, and maxX the highest possible value for the data. So, the similarity of a new patient to other patients is obtained based on Equation (5).
(5)Simi,j=1−∑i=1L∑j=1N∑f=1Mxi,j−xf,j2,where x represents the value of the feature, f represents the feature index in the dataset, i represents the index of new patients, and j represents the index of previous patients. Based on Equation (4), N values have obtained for each new patient, which indicates the similarity with the N of the previous patient. Among these N patients, K patients with the most similarity to the new patient are selected as nearest neighbors. In this article, the value of k is considered equal to 7. Finally, the type of disease associated with a new patient is determined by voting between K nearest neighbors.Providing medical recommendation: at this stage of the proposed method, according to the type of disease determined for the new patient and according to the health records of neighbors close to the new patient, treatment advice is provided to the new patient. After diagnosing the type of chronic disease in a new patient, in order to provide medical recommendation, similar patients should be identified from all patients with the same type of chronic disease. Patients with a specific type of chronic disease may have different symptoms as the disease progresses. In addition, each symptom may have a different effect on the course of the disease. Therefore, physicians’ opinions on patients’ characteristics are added to the patients’ health records as a weight. Therefore, in order to find patients similar to the new patient, Equation (6) has been used.
(6)simi,j=∑r=1Mri+∑j=1hri,j−r¯j∗wi,j∑j=1hwj+wi,where ri represents value of feature for the new patient, h is the number of patients with a specific type of chronic disease, ri,j is the difference in the feature value for the new patient and the previous patients, r¯j is the average feature value for the whole patient, wi,j is the difference in weight of feature for the new patient and the previous patient, and wi is the weight of feature for new patient.Finally,simi,j which is the amount of similarity of the new patient to each of the previous patients is obtained based on the collaborative filter and the opinions of experts. Patients have the most similarity and are selected as target patients. Medical recommendation is provided to new patients based on the treatment method and medical instructions included in the medical bird of the target patients.Chronic patients are one of the most common patients, in which progress without pain in the body to eventually cause great harm to the patient. Chronic disease control requires accurate and early diagnosis. On the other hand, due to the different symptoms in different chronic diseases and even in a specific type of disease, in the diagnosis of chronic diseases, it is necessary to examine the symptoms related to different diseases. One of the significance of the proposed method is to use the KNN classifier to diagnose the type of disease. Due to its instance-based nature, this classification examines the symptoms of all diseases to obtain the most similar type of disease for a new patient. On the other hand, in chronic disease of a certain type, different symptoms in patients may be related to the stage of disease progression, while some novice physicians may diagnose them as different diseases. Therefore, it is necessary to examine similar patients in different stages of the patient. Another significance of the proposed method is to use a collaborative filter to find similar patients based on the patient’s characteristics and symptoms and the opinion of physicians, among all patients with a specific type of chronic disease.


## 3.1. Preliminaries of the Proposed Method

### 3.1.1.K-Nearest Neighbor (KNN)

TheK-nearest neighbor classification (KNN) method is a group of K records in the training suite that are close to the tested data and, based on the label assignment, find the specific class that dominates the neighborhood. This method demonstrates the fact that in many datasets, one record is unlikely to correspond exactly to another, as well as the fact that conflicting information about the class of a record can result from records close to it must be presented [45, 46]. There are several key elements to this approach:
(1)
A set of tagged records is used to evaluate the record class being tested(2)
To calculate the proximity of records, the criterion of distance or similarity can be used(3)
K value, the number of nearest neighbors, must be specified(4)
The method used to determine the target record class should be determined based on the classes and the distanceK of the nearest neighborIn its simplest form, KNN can assign a class record to its nearest neighbors or most of its nearest neighbors [46].Several key issues affect KNN performance, one of which is the choice ofk. Figures 1–3 show an exam record with an x tag and training records belonging to each of the “-” or “+” classes. If k is too small, the result can be sensitive to noise points. On the other hand, if k is too large, the neighborhood may contain many points from many other classes. The estimation of the best value for k can be obtained by cross-validation. In this method, the value of k starts from a small value, and a constant value is added to it for each iteration. The performance of the algorithm is compared in each iteration, and finally, the value of k, which leads to the best performance for the algorithm, is chosen as the principal value for k.Figure 1
Overall architecture of the proposed method.Figure 2
Flowchart of the proposed method.Figure 3
Average error rate per user.However, it is important to note thatk=1 may also have other values of k, especially for small datasets commonly used in research or classroom exercises. However, with sufficient records, values greater than k are more resistant to noise.Another issue is the approach of combining class labels. The easiest way is to pay attention to the majority vote, but this can be problematic if the nearest neighbors are very diverse in proximity, and the nearest neighbors are more confident of the target class. A more sophisticated method, which is usually less sensitive to the selection ofk, is to measure each record based on its distance. Various options are possible. For example, the weight coefficient is taken from the square of the mutual distance wi=1/dy,z2. This value replaces the last step of the basic KNN algorithm as follows [46]:
(1)Distance−WeightedVoting:cz=v∈Largmax∑y∈Nwi×Iv=classcy.Selecting the distance criterion is another important point to consider in this method. The Euclidean distance or Manhattan distance is usually used as the distance criterion in this method. For two points,x and y, with n properties, this distance is calculated by the following formulas:[46]:
(2)dx,y=∑k=1nxk−yk2Euclidandistance,dx,y=∑k=1nxk−ykManhattandistance,where xk and yk are the attributes k, x, and y, respectively.Although these and various other criteria can be used to calculate the distance between two points, conceptually, the most desirable measure is the distance that is less or more similar between two records, meaning that using this, the criteria probably have the same class tags between the two records, so, for example, if KNN is used to classify documents, it is better to use the cosine criterion instead of the Euclidean distance. Note that KNN can also use data and categories for data with classified or mixed properties until an appropriate distance criterion is defined.


### 3.1.2. Collaborative Filter

Collaborative filtering (CF) is one of the technologies that has been used in many cases in the recommendation. This method calculates the similarity between users and uses this information to recommend products that have not yet been reviewed by the user. The similarity is based on past reviews of shared items. This similarity is used to generate recommendations for items that have already been reviewed by similar users but have not yet been specified by the user [47, 48].The first step of the CF system is to search for users with similar consumption habits, for example, to calculate the similarity between users. When analyzing users 1 and 5, for optionI1, the difference between their rankings is 1.0. In I2, there is no difference between them, and for I3, the difference is 0.5.If the difference between the two users’ ratings on the options is less than a threshold value, it can be said that the two users are similar. Hence, it can be said that users 1 and 5 are similar. By the same token, users 1 and 2 will not be the same. The similarity calculation can only occur for the options that both users have preferably stated. There are several techniques for calculating similarities between users. The most common methods are shown in Equation (3) [17]:
(3)pa,u=r¯a+∑u=1hru,i−r¯u∗wa,u∑u=1hwa,u.(i)
wa,u is the relationship of the target user to a given user U(ii)
ru,i is the target user score for an i option(iii)
r¯u: the average of all rankings is a target user (u)(iv)
Pa,u is the expected use of the option for user u(v)
h is the value of the best neighbors, and it is at the disposal of each of the systems that use common filterThe second step of CF-based systems is to select a subset of users with higher similarity. Then, the next step is to calculate the forecast. The prediction of inference is the amount of user evaluation of a product that it has not yet evaluated. According to Table1, an example of this calculation can be filled in the gap for user U3 on options I2 and I3 and user U4 for option I2. Therefore, the prediction is made independent of the method used, because it is generated by a weighted average weight of neighbors that has an acceptable coefficient of similarity [17].Table 1
Calculate the distance of a part of the test patients from the educational patients.
Test 1Test 2Test 3Test 4Test 5Test 6Test 7Test 8Test 8Test 9Test 100.40550.42740.36201.97250.35920.35690.85281.35591.35590.72250.34450.28800.32240.24451.98600.31900.31850.80941.33341.33340.89090.30020.59940.61480.55662.04250.50270.50000.97861.44251.44250.51300.49251.02761.03710.98212.21290.89420.89161.28471.66581.66580.25200.88900.55110.56950.50252.04250.45830.45600.94571.42131.42130.56470.44640.28990.32480.24411.99980.31890.31850.82891.34831.34830.89070.29980.31500.34430.27661.98600.32090.31960.84281.35541.35540.83080.30321.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.59571.56541.72060.98121.73761.73321.42021.68141.68142.00451.74431.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.38231.39001.18131.96141.02551.02441.59101.96211.96210.75751.03751.38201.38961.18131.95941.02541.02431.59101.96201.96200.75761.03751.38171.38921.18131.95741.02541.02421.59101.96201.96200.75761.03751.38211.38961.18141.95951.02551.02441.59111.96211.96210.75751.03761.43301.44031.39671.99311.42431.42441.01610.06900.06901.72131.40731.43511.44151.39911.95451.42641.42641.02040.01420.01421.72381.40991.43311.44021.39681.98441.42441.42441.01650.05150.05151.72151.40751.43491.44131.39891.95631.42621.42621.02000.01110.01111.72361.40971.43441.44101.39841.96091.42581.42571.01920.00790.00791.72311.4092


## 3.1.1.K-Nearest Neighbor (KNN)

TheK-nearest neighbor classification (KNN) method is a group of K records in the training suite that are close to the tested data and, based on the label assignment, find the specific class that dominates the neighborhood. This method demonstrates the fact that in many datasets, one record is unlikely to correspond exactly to another, as well as the fact that conflicting information about the class of a record can result from records close to it must be presented [45, 46]. There are several key elements to this approach:
(1)
A set of tagged records is used to evaluate the record class being tested(2)
To calculate the proximity of records, the criterion of distance or similarity can be used(3)
K value, the number of nearest neighbors, must be specified(4)
The method used to determine the target record class should be determined based on the classes and the distanceK of the nearest neighborIn its simplest form, KNN can assign a class record to its nearest neighbors or most of its nearest neighbors [46].Several key issues affect KNN performance, one of which is the choice ofk. Figures 1–3 show an exam record with an x tag and training records belonging to each of the “-” or “+” classes. If k is too small, the result can be sensitive to noise points. On the other hand, if k is too large, the neighborhood may contain many points from many other classes. The estimation of the best value for k can be obtained by cross-validation. In this method, the value of k starts from a small value, and a constant value is added to it for each iteration. The performance of the algorithm is compared in each iteration, and finally, the value of k, which leads to the best performance for the algorithm, is chosen as the principal value for k.Figure 1
Overall architecture of the proposed method.Figure 2
Flowchart of the proposed method.Figure 3
Average error rate per user.However, it is important to note thatk=1 may also have other values of k, especially for small datasets commonly used in research or classroom exercises. However, with sufficient records, values greater than k are more resistant to noise.Another issue is the approach of combining class labels. The easiest way is to pay attention to the majority vote, but this can be problematic if the nearest neighbors are very diverse in proximity, and the nearest neighbors are more confident of the target class. A more sophisticated method, which is usually less sensitive to the selection ofk, is to measure each record based on its distance. Various options are possible. For example, the weight coefficient is taken from the square of the mutual distance wi=1/dy,z2. This value replaces the last step of the basic KNN algorithm as follows [46]:
(1)Distance−WeightedVoting:cz=v∈Largmax∑y∈Nwi×Iv=classcy.Selecting the distance criterion is another important point to consider in this method. The Euclidean distance or Manhattan distance is usually used as the distance criterion in this method. For two points,x and y, with n properties, this distance is calculated by the following formulas:[46]:
(2)dx,y=∑k=1nxk−yk2Euclidandistance,dx,y=∑k=1nxk−ykManhattandistance,where xk and yk are the attributes k, x, and y, respectively.Although these and various other criteria can be used to calculate the distance between two points, conceptually, the most desirable measure is the distance that is less or more similar between two records, meaning that using this, the criteria probably have the same class tags between the two records, so, for example, if KNN is used to classify documents, it is better to use the cosine criterion instead of the Euclidean distance. Note that KNN can also use data and categories for data with classified or mixed properties until an appropriate distance criterion is defined.


## 3.1.2. Collaborative Filter

Collaborative filtering (CF) is one of the technologies that has been used in many cases in the recommendation. This method calculates the similarity between users and uses this information to recommend products that have not yet been reviewed by the user. The similarity is based on past reviews of shared items. This similarity is used to generate recommendations for items that have already been reviewed by similar users but have not yet been specified by the user [47, 48].The first step of the CF system is to search for users with similar consumption habits, for example, to calculate the similarity between users. When analyzing users 1 and 5, for optionI1, the difference between their rankings is 1.0. In I2, there is no difference between them, and for I3, the difference is 0.5.If the difference between the two users’ ratings on the options is less than a threshold value, it can be said that the two users are similar. Hence, it can be said that users 1 and 5 are similar. By the same token, users 1 and 2 will not be the same. The similarity calculation can only occur for the options that both users have preferably stated. There are several techniques for calculating similarities between users. The most common methods are shown in Equation (3) [17]:
(3)pa,u=r¯a+∑u=1hru,i−r¯u∗wa,u∑u=1hwa,u.(i)
wa,u is the relationship of the target user to a given user U(ii)
ru,i is the target user score for an i option(iii)
r¯u: the average of all rankings is a target user (u)(iv)
Pa,u is the expected use of the option for user u(v)
h is the value of the best neighbors, and it is at the disposal of each of the systems that use common filterThe second step of CF-based systems is to select a subset of users with higher similarity. Then, the next step is to calculate the forecast. The prediction of inference is the amount of user evaluation of a product that it has not yet evaluated. According to Table1, an example of this calculation can be filled in the gap for user U3 on options I2 and I3 and user U4 for option I2. Therefore, the prediction is made independent of the method used, because it is generated by a weighted average weight of neighbors that has an acceptable coefficient of similarity [17].Table 1
Calculate the distance of a part of the test patients from the educational patients.
Test 1Test 2Test 3Test 4Test 5Test 6Test 7Test 8Test 8Test 9Test 100.40550.42740.36201.97250.35920.35690.85281.35591.35590.72250.34450.28800.32240.24451.98600.31900.31850.80941.33341.33340.89090.30020.59940.61480.55662.04250.50270.50000.97861.44251.44250.51300.49251.02761.03710.98212.21290.89420.89161.28471.66581.66580.25200.88900.55110.56950.50252.04250.45830.45600.94571.42131.42130.56470.44640.28990.32480.24411.99980.31890.31850.82891.34831.34830.89070.29980.31500.34430.27661.98600.32090.31960.84281.35541.35540.83080.30321.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.59571.56541.72060.98121.73761.73321.42021.68141.68142.00451.74431.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.60001.56971.72510.98121.74201.73761.42571.68581.68582.00841.74881.38231.39001.18131.96141.02551.02441.59101.96211.96210.75751.03751.38201.38961.18131.95941.02541.02431.59101.96201.96200.75761.03751.38171.38921.18131.95741.02541.02421.59101.96201.96200.75761.03751.38211.38961.18141.95951.02551.02441.59111.96211.96210.75751.03761.43301.44031.39671.99311.42431.42441.01610.06900.06901.72131.40731.43511.44151.39911.95451.42641.42641.02040.01420.01421.72381.40991.43311.44021.39681.98441.42441.42441.01650.05150.05151.72151.40751.43491.44131.39891.95631.42621.42621.02000.01110.01111.72361.40971.43441.44101.39841.96091.42581.42571.01920.00790.00791.72311.4092


## 3.2. Proposed Method

As mentioned, efforts to predict disease in terms of providing medical services and making the best possible decision on disease samples are very important for hospitals and medical institutions. Failure to make the right decision and take timely action to treat some diseases can pose an irreparable risk to the patient or in some cases the patient may die due to lack of medical care. Chronic kidney disease is one of the diseases that, if not detected and treated in the early stages, can have irreparable consequences for the patient’s health, even if forgotten can lead to death. Therefore, predicting people with this type of kidney disease is an important issue that should be considered.Therefore, in order to solve this problem and predict patients with chronic diseases, a number of predictive models have been proposed. Recently, the data mining group has been used successfully in a variety of applications, including to assist in medical diagnosis and disease prediction. The data mining team can significantly improve the ability to generalize learning systems by training a limited number of samples and then combining their results.Therefore, in this study, we try to use the nearest neighbor to use standard data from the biological test results of some patients with chronic disease, to predict people at risk of chronic disease. The use of the nearest neighbor in disease prediction has been proven in many publications, so in this study, the use of this classification has been confirmed. Figure1 shows the overall architecture of the proposed method.In this study, we want to predict people with these diseases using the nearest neighbor model based on the medical consulting system. In this regard, the data obtained from the test results, which is a standard database in the standard PhysioNet data repository, are entered as artificial data into artificial neural networks and processed by zinc. These data predict the outcome of people at risk for chronic disease.Due to the different amounts of data and the variety of features in the experimental results used in this study as the nearest neighbor input, the number of features in the dataset or in other words the dimensions of the data is high. The large size of the data imposes more complexity on the system and may affect the performance accuracy of the classification model. Therefore, in this research, we first select the feature subset from the preprocessing step to reduce the data size. It is used to reduce the volume of calculations. After this preprocessing step, features that are less relevant to the class tag are removed, and the remaining features are important features that play a key role in teaching the model.Another step of preprocessing used in this research is to convert nonnumerical data to numerical data. Because the nearest neighbors perform better with numerical data, this preprocessing step is necessary to prepare the data for model training. In this preprocessing step, nonnumeric data are replaced with numbers that represent the original data using the variable change method and increase the ease of model training to classify the nearest neighbor. The output data from these preprocessing stages are model-ready data that is injected as input data to the nearest neighbor. The flow diagram of the proposed method is shown in Figure2.As shown in Figure2, the proposed method includes the following steps:Data extraction: in this step, information about the status of patients with chronic diseases is extracted from patients’ health records from the proposed method. This information includes biological tests of patients that were collected during the treatment process in the hospital and recorded in the patients’ health records. There are also ways to treat diseases in patients’ health records. Thus, patients with chronic diseases are used as input to the proposed referral system according to their symptoms.Data classification: due to the fact that the nearest neighbor classifier has been identified as a lazy and sample-based classification, the training process is delayed until the test data is entered. Therefore, in the proposed method, the training process will take place at the time of the new patient’s visit to the hospital. In the process of teaching the biological signs, characteristics of new patients are compared with all patients in the dataset. In comparison between properties, since the values of the properties have been converted to numerical values in the preprocessing step, the Euclidean distance relation is performed. At this stage, according to this value set for K, a number of similar patients are selected as close neighbors. Finally, according to the closest selected neighbor among the close neighbors based on the most similar symptoms, the type of disease of the new patient is determined.In the patient classification stage, we haveN patients in the dataset, each of whom may suffer from some type of disease. Given that in chronic patients the symptoms of patients with one type of disease may vary according to the patient’s progress, the best way to find the type of disease is to compare a new sample with all N previous patients. Given that the KNN classifier inherently compares a test sample with all training samples to find the most similar ones, this classifier is the best option for our work. It is assumed that we have L new patients and each of the patients has M feature that is stored in their electronic health record.Given that the values of features may be in different intervals and the direct use of this data may affect the calculation of similarity between new patients and old patients, the values of patient characteristics should be normalized. In this paper, the max-min normalization method is used [49], which is shown in
(4)NormilizedData=Xi−minXmaxX−minX.Xi represents the original data value, minx the lowest possible value for the data, and maxX the highest possible value for the data. So, the similarity of a new patient to other patients is obtained based on Equation (5).
(5)Simi,j=1−∑i=1L∑j=1N∑f=1Mxi,j−xf,j2,where x represents the value of the feature, f represents the feature index in the dataset, i represents the index of new patients, and j represents the index of previous patients. Based on Equation (4), N values have obtained for each new patient, which indicates the similarity with the N of the previous patient. Among these N patients, K patients with the most similarity to the new patient are selected as nearest neighbors. In this article, the value of k is considered equal to 7. Finally, the type of disease associated with a new patient is determined by voting between K nearest neighbors.Providing medical recommendation: at this stage of the proposed method, according to the type of disease determined for the new patient and according to the health records of neighbors close to the new patient, treatment advice is provided to the new patient. After diagnosing the type of chronic disease in a new patient, in order to provide medical recommendation, similar patients should be identified from all patients with the same type of chronic disease. Patients with a specific type of chronic disease may have different symptoms as the disease progresses. In addition, each symptom may have a different effect on the course of the disease. Therefore, physicians’ opinions on patients’ characteristics are added to the patients’ health records as a weight. Therefore, in order to find patients similar to the new patient, Equation (6) has been used.
(6)simi,j=∑r=1Mri+∑j=1hri,j−r¯j∗wi,j∑j=1hwj+wi,where ri represents value of feature for the new patient, h is the number of patients with a specific type of chronic disease, ri,j is the difference in the feature value for the new patient and the previous patients, r¯j is the average feature value for the whole patient, wi,j is the difference in weight of feature for the new patient and the previous patient, and wi is the weight of feature for new patient.Finally,simi,j which is the amount of similarity of the new patient to each of the previous patients is obtained based on the collaborative filter and the opinions of experts. Patients have the most similarity and are selected as target patients. Medical recommendation is provided to new patients based on the treatment method and medical instructions included in the medical bird of the target patients.Chronic patients are one of the most common patients, in which progress without pain in the body to eventually cause great harm to the patient. Chronic disease control requires accurate and early diagnosis. On the other hand, due to the different symptoms in different chronic diseases and even in a specific type of disease, in the diagnosis of chronic diseases, it is necessary to examine the symptoms related to different diseases. One of the significance of the proposed method is to use the KNN classifier to diagnose the type of disease. Due to its instance-based nature, this classification examines the symptoms of all diseases to obtain the most similar type of disease for a new patient. On the other hand, in chronic disease of a certain type, different symptoms in patients may be related to the stage of disease progression, while some novice physicians may diagnose them as different diseases. Therefore, it is necessary to examine similar patients in different stages of the patient. Another significance of the proposed method is to use a collaborative filter to find similar patients based on the patient’s characteristics and symptoms and the opinion of physicians, among all patients with a specific type of chronic disease.


## 4. Implementing the Proposed Method

To implement theK-NN classification model, we must first normalize the data from the training and test datasets and then calculate the distance of the tested patients in terms of similarity criteria to the training patients. As mentioned earlier, the Euclidean distance criterion is used to calculate the similarity interval between patient education and testing in the K-NN classification model. This distance criterion will be applied in this study to the features that were identified in the previous section as similarity criteria between patients. The similarity criterion is actually the characteristics that are directly related to the class label and can determine the group of each patient individually or in combination with some other characteristics. As mentioned earlier, the Euclidean distance criterion deals with numerical data, and the required similarity criteria must be in the form of numerical data in order to obtain accurate results. In this study, all values related to the properties have numerical values.By determining the distance of experimental patients from educational patients,K educational patients who are less distant from the experimental patient in terms of similarity criteria, in other words, educational patients who are more similar to the experimental patient, are selected as close neighbors. The value of k is a criterion for selecting the number of neighbors that must be voted on to determine the patient class, which is selected by default for the user. If k has a small value, for example 1 or 2, the test patient class may not be determined correctly, and if k has a large value such as 9 or 10, the test patient class may be affected by noise and unrelated information in the neighborhood. Be impressed. Therefore, k should have an optimal value between 3 and 7, and in this study, the value of k should be considered equal to 5.By selectingk as the nearest neighbor of the tested patients, the class label of this neighbor k is checked. Any class that has more representation among these close neighbors is considered the dominant class, and the patient class label is easily determined in the test. Table 1 shows the process of calculating the distance of experimental patients from patient education for 200 experimental patients.As shown in Table1, the distance between the tested patients and the trained patients was calculated in terms of similarity criteria for 10 experimental patients compared to 20 trained patients. The columns in Table 1 include the tested patients, and the rows include the patients under training. The last column of Table 1 contains the label of the educational class of educational patients, which is determined by determining the distance, the label of the patient’s medical class, which is considered a close neighbor.According to Table1, it can be seen that the educational patients are italicized with the shortest distance compared to the tested patients. In each column, 5 patients are identified, representing 5 neighbors close to the experimental patient in that column. The class label of these tested patients is determined by determining the class label of the nearest neighboring educational patients and voting among these educational patients. In such a way that the representative of each class that is more among these 5 neighbors is recognized as the dominant class, and that class is selected as the experimental patient class. In some patients, it is observed that all the neighbors are from the same class where the class label is easily marked, but in some other patients, other members of the class are seen among the neighbors. In this case, determining the patient’s class label is a bit difficult. Table 2 shows the trend of assigning experimental patients to chronic diseases in close neighbors.Table 2
Applying the allocation of test patients to nearest neighbors.
TestKDistanceProbPredicted classTestKDistanceProbPredicted class110.29980.84770610.3180.84250120.30020.84730620.31910.84230130.30330.84420630.32100.84050140.34460.79880640.35930.80010150.44650.66220650.45840.67460210.25210.96350710.98120.87451220.51310.84890720.98120.87451230.56470.81690730.98120.87451240.72250.70030740.98120.87451250.75760.67050751.95460.50201310.080.99191810.24420.89711320.01120.98411820.24460.89681330.01420.97401830.27660.86801340.05150.66031840.36210.77381350.0690.38971850.50260.56431410.80950.82170910.32240.87551420.82900.81300920.32480.87371430.84280.80670930.34440.85801440.85280.80210940.42750.78121450.94570.75660950.56950.61161510.31850.841601010.28800.88701520.31860.841501020.28990.88561530.31960.840501030.31510.86491540.35690.801101040.40550.77611550.45610.675201050.55120.58641As shown in Table2, the patient distance applies to all close neighbors of the tested patients, and the closer distance for the patient test has a higher membership rate. This degree of membership is in fact the probability of an experimental patient belonging to a chronic disease according to the educational patient under study. The higher the degree of membership of an educational patient, it means that the experimental patient, due to the similarity of the symptoms with the educational patient, most likely (equal to the degree of membership of the educational patient) belongs to a chronic disease.


### 4.1. Provide Medical Recommendations

According to the results of the nearest neighbor classification to provide medical advice to the Bibmaren test according to the health records of patients, the medical advice provided in the proposed method includes the same patient, according to which the new patient can be treated according to the patient’s medical record. The difference between the predicted value and the actual rating value is recognized by the user patient as a proven error, which is used as one of the evaluation criteria of the proposed systems. Table3 shows a sample of results for similar patients with respect to similarity options and the type of disease diagnosed for that patient, as well as the amount of error associated with predicting one patient for other educational patients similarly shown.Table 3
New and similar patients and predicted ranking amount and error.
Patient numberSimilar to patient numberFeatureAverage error143{4,6,7,8,11,12,14}0.0742648{13,29,31,36, 42, 45, 50}0.1313739{1,4,11,13,14,17,19}0.0725045{5,10,12,13, 21,24,27}0.12As shown in Table3, similar patients were calculated according to the common characteristics for each patient extracted from the educational dataset and the error related to each user. In the continuation of this chapter, we will evaluate the proposed method.


### 4.2. Evaluate the Proposed Method

The performance quality of a medical consulting system can be measured by many criteria. The type of criteria used depends on the method used. The performance of the medical counseling system is determined by the accuracy of the recommendations provided to patients. In this study, considering the similar method of close neighbors, two criteria have been used to measure the performance accuracy of the proposed method. The first criterion is statistical accuracy to measure the accuracy of the predicted disease for patients, and the second criterion is the accuracy in providing counseling to patients. Finally, the performance accuracy of the proposed method is compared with previous methods.


### 4.3. Performance Evaluation of the Proposed Method Based on Statistical Accuracy

As mentioned, statistical accuracy measures examine the direct comparison of patients’ predictions for patients with their actual disease type. Mean absolute error (MAE) and root mean square error (RMSE) are commonly used as the measures of statistical accuracy. MAE is one of the most common methods used among most methods. Naturally, the lower the value of this criterion for each patient, the higher the accuracy of the recommended method. The relationship of this criterion is calculated as follows:(7)MAE=1N∑u,ipu,i−ru,i,where Pu,i is defined as the predicted disease for patient u based on the symptoms i, ru,i is the actual disease of the patient u based on the symptoms i, and N is the total number of patients in the dataset. Figure 3 shows the average error rate for 50 patients.As shown in Figure3, the average error in ranking prediction for each user is calculated for all products. Now, based on Equation (4), we calculate the MAE criterion, which is the average error of all users for all recommendations. The MAE criterion in this research is equal to:
(8)MAE=0.2620%.This criterion shows the extent of the predicted ranking deviation from the actual ranking of users. Therefore, the accuracy value of the proposed method is as follows:(9)Accuracy=1−MAE∗100=99.7380%.


### 4.4. Performance Evaluation of the Proposed Method Based on Product Recommendations

Recommendation criteria in medical advice methods help physicians to select the highest quality treatment options available outside the collection. These criteria are defined as the ratio of useful advice given to patients among all recommendations. Popular criteria in this area include inverse rate, weight errors, receiver-operating characteristics (ROC) and precise reminder curve (PRC), accuracy, sensitivity, andF-criteria. The most well-known criteria used in most research are accuracy and sensitivity. These two criteria are defined as follows [50]:
(10)Accuracy=CorrectlyrecommendeditemsTotalrecommendeditems,Recall=CorrectlyrecommendeditemsTotalusefulrecommendeditems,Precision=CorrectlyrecommendeditemsTotalrecommendeditems.In general, the criterion of accuracy is defined as the ratio of items related to real items, and the criterion of sensitivity is defined as the ratio of appropriate items among all relevant items. However, in this study, the accuracy criterion is defined as the ratio of the number of correct recommendations to the total number of recommendations, and the sensitivity criterion is defined as the ratio of the number of correct recommendations to the total number of useful recommendations. Performance evaluation criteria of theF-criterion is defined to help simplify the accuracy and reminder criteria in a single criterion. The value obtained makes the comparison between algorithms and the whole data very simple and easy. The measurement relationship of F-measure is defined as follows:
(11)F‐measure=2∗Precision∗RecallPrecision+Recall.Accordingly, according to the relationships, Table4 shows the values related to the evaluation criteria.Table 4
Evaluation criteria values.
MethodAccuracyPrecisionRecallF-measureKNN-CF96.588.1891.9890.04NN-CF78.1976.9868.9375.52SVM-CF84.0383.2489.3268.9NB-CF78.4979.2278.978.89As shown in Table4, the proposed method, which is a combination of the nearest neighbor algorithm to classify the type of chronic disease and a participatory filter to provide the necessary treatment recommendations for the disease, in terms of evaluation criteria, good performance relative to the class, it has NN, SVM, and NB clauses. The high accuracy of the proposed method indicates the high ability of this method in teaching the model based on the nearest neighbor method in the proposed method. Accordingly, the accuracy diagram of the proposed method for 450 test samples using classification methods is shown in Figure 4.Figure 4
Accuracy chart of recommendations provided for test patients.As shown in Figure4, the proposed method, using a combination of the nearest neighbor method and the participatory filter, has performed well in terms of accuracy in the chronic patient dataset. Another criterion that has been evaluated in the proposed method is the criterion of sensitivity, which is useful as a percentage of the correct recommendations provided to the total recommendations provided in the proposed method. Figure 5 shows the diagram of the sensitivity criterion in the proposed method.Figure 5
Sensitivity diagram of the recommendations provided.As shown in Figure5, in the combination of the nearest neighbor method and the participatory filter, more than 90% of the recommendations given to patients are correct, and this shows the high capability of the proposed recommender method. Another criterion used in the proposed method is accuracy, which is the percentage of correct recommendations given to the total recommended recommendations. Figure 6 shows the correctness diagram of the proposed method.Figure 6
Diagram of the accuracy of the proposed method for test samples.As shown in Figure6, in the combination of the nearest neighbor method and the participatory filter, about 89% of the recommendations given are correct. Another criterion used in the proposed method is F-measure, which is a combination of two criteria of accuracy and sensitivity. Figure 7 shows the F-measure diagram of the proposed method.Figure 7
F-measure diagram of the proposed method for test samples.As shown in Figure7, the F-measure criterion in the combination of the nearest neighbor method and the participatory filter is high and is about 90%.


### 4.5. Comparison of the Proposed Method with Previous Methods

After evaluating the proposed method, to evaluate the validity of the proposed method, we compare it with previous methods in this field. As shown in Tables2–4, the performance accuracy of the proposed method is determined on the dataset of patients with chronic diseases and related charts and evaluation criteria. The proposed method can now be compared with previous methods [51, 52] in the same dataset. Therefore, Figure 8 shows a comparison of the proposed method with previous methods in predicting the class label of chronic diseases.Figure 8
Comparison of the proposed method with previous methods.As shown in Figure8, the proposed method has a higher accuracy in diagnosing patients than other previous methods due to the use of the method of close neighbors.


## 4.1. Provide Medical Recommendations

According to the results of the nearest neighbor classification to provide medical advice to the Bibmaren test according to the health records of patients, the medical advice provided in the proposed method includes the same patient, according to which the new patient can be treated according to the patient’s medical record. The difference between the predicted value and the actual rating value is recognized by the user patient as a proven error, which is used as one of the evaluation criteria of the proposed systems. Table3 shows a sample of results for similar patients with respect to similarity options and the type of disease diagnosed for that patient, as well as the amount of error associated with predicting one patient for other educational patients similarly shown.Table 3
New and similar patients and predicted ranking amount and error.
Patient numberSimilar to patient numberFeatureAverage error143{4,6,7,8,11,12,14}0.0742648{13,29,31,36, 42, 45, 50}0.1313739{1,4,11,13,14,17,19}0.0725045{5,10,12,13, 21,24,27}0.12As shown in Table3, similar patients were calculated according to the common characteristics for each patient extracted from the educational dataset and the error related to each user. In the continuation of this chapter, we will evaluate the proposed method.


## 4.2. Evaluate the Proposed Method

The performance quality of a medical consulting system can be measured by many criteria. The type of criteria used depends on the method used. The performance of the medical counseling system is determined by the accuracy of the recommendations provided to patients. In this study, considering the similar method of close neighbors, two criteria have been used to measure the performance accuracy of the proposed method. The first criterion is statistical accuracy to measure the accuracy of the predicted disease for patients, and the second criterion is the accuracy in providing counseling to patients. Finally, the performance accuracy of the proposed method is compared with previous methods.


## 4.3. Performance Evaluation of the Proposed Method Based on Statistical Accuracy

As mentioned, statistical accuracy measures examine the direct comparison of patients’ predictions for patients with their actual disease type. Mean absolute error (MAE) and root mean square error (RMSE) are commonly used as the measures of statistical accuracy. MAE is one of the most common methods used among most methods. Naturally, the lower the value of this criterion for each patient, the higher the accuracy of the recommended method. The relationship of this criterion is calculated as follows:(7)MAE=1N∑u,ipu,i−ru,i,where Pu,i is defined as the predicted disease for patient u based on the symptoms i, ru,i is the actual disease of the patient u based on the symptoms i, and N is the total number of patients in the dataset. Figure 3 shows the average error rate for 50 patients.As shown in Figure3, the average error in ranking prediction for each user is calculated for all products. Now, based on Equation (4), we calculate the MAE criterion, which is the average error of all users for all recommendations. The MAE criterion in this research is equal to:
(8)MAE=0.2620%.This criterion shows the extent of the predicted ranking deviation from the actual ranking of users. Therefore, the accuracy value of the proposed method is as follows:(9)Accuracy=1−MAE∗100=99.7380%.


## 4.4. Performance Evaluation of the Proposed Method Based on Product Recommendations

Recommendation criteria in medical advice methods help physicians to select the highest quality treatment options available outside the collection. These criteria are defined as the ratio of useful advice given to patients among all recommendations. Popular criteria in this area include inverse rate, weight errors, receiver-operating characteristics (ROC) and precise reminder curve (PRC), accuracy, sensitivity, andF-criteria. The most well-known criteria used in most research are accuracy and sensitivity. These two criteria are defined as follows [50]:
(10)Accuracy=CorrectlyrecommendeditemsTotalrecommendeditems,Recall=CorrectlyrecommendeditemsTotalusefulrecommendeditems,Precision=CorrectlyrecommendeditemsTotalrecommendeditems.In general, the criterion of accuracy is defined as the ratio of items related to real items, and the criterion of sensitivity is defined as the ratio of appropriate items among all relevant items. However, in this study, the accuracy criterion is defined as the ratio of the number of correct recommendations to the total number of recommendations, and the sensitivity criterion is defined as the ratio of the number of correct recommendations to the total number of useful recommendations. Performance evaluation criteria of theF-criterion is defined to help simplify the accuracy and reminder criteria in a single criterion. The value obtained makes the comparison between algorithms and the whole data very simple and easy. The measurement relationship of F-measure is defined as follows:
(11)F‐measure=2∗Precision∗RecallPrecision+Recall.Accordingly, according to the relationships, Table4 shows the values related to the evaluation criteria.Table 4
Evaluation criteria values.
MethodAccuracyPrecisionRecallF-measureKNN-CF96.588.1891.9890.04NN-CF78.1976.9868.9375.52SVM-CF84.0383.2489.3268.9NB-CF78.4979.2278.978.89As shown in Table4, the proposed method, which is a combination of the nearest neighbor algorithm to classify the type of chronic disease and a participatory filter to provide the necessary treatment recommendations for the disease, in terms of evaluation criteria, good performance relative to the class, it has NN, SVM, and NB clauses. The high accuracy of the proposed method indicates the high ability of this method in teaching the model based on the nearest neighbor method in the proposed method. Accordingly, the accuracy diagram of the proposed method for 450 test samples using classification methods is shown in Figure 4.Figure 4
Accuracy chart of recommendations provided for test patients.As shown in Figure4, the proposed method, using a combination of the nearest neighbor method and the participatory filter, has performed well in terms of accuracy in the chronic patient dataset. Another criterion that has been evaluated in the proposed method is the criterion of sensitivity, which is useful as a percentage of the correct recommendations provided to the total recommendations provided in the proposed method. Figure 5 shows the diagram of the sensitivity criterion in the proposed method.Figure 5
Sensitivity diagram of the recommendations provided.As shown in Figure5, in the combination of the nearest neighbor method and the participatory filter, more than 90% of the recommendations given to patients are correct, and this shows the high capability of the proposed recommender method. Another criterion used in the proposed method is accuracy, which is the percentage of correct recommendations given to the total recommended recommendations. Figure 6 shows the correctness diagram of the proposed method.Figure 6
Diagram of the accuracy of the proposed method for test samples.As shown in Figure6, in the combination of the nearest neighbor method and the participatory filter, about 89% of the recommendations given are correct. Another criterion used in the proposed method is F-measure, which is a combination of two criteria of accuracy and sensitivity. Figure 7 shows the F-measure diagram of the proposed method.Figure 7
F-measure diagram of the proposed method for test samples.As shown in Figure7, the F-measure criterion in the combination of the nearest neighbor method and the participatory filter is high and is about 90%.


## 4.5. Comparison of the Proposed Method with Previous Methods

After evaluating the proposed method, to evaluate the validity of the proposed method, we compare it with previous methods in this field. As shown in Tables2–4, the performance accuracy of the proposed method is determined on the dataset of patients with chronic diseases and related charts and evaluation criteria. The proposed method can now be compared with previous methods [51, 52] in the same dataset. Therefore, Figure 8 shows a comparison of the proposed method with previous methods in predicting the class label of chronic diseases.Figure 8
Comparison of the proposed method with previous methods.As shown in Figure8, the proposed method has a higher accuracy in diagnosing patients than other previous methods due to the use of the method of close neighbors.


## 5. Conclusion

Chronic disease prediction systems are very useful as an aid to the health and care of the sick community and thus reduce mortality even in young and middle-aged people. The chronic disease prognosis system can be an important issue in medicine, helping ordinary people to be aware of their health status, because normal people are late for health check-ups. People who do this periodically do not have the necessary information about their health status. By having the results of the chronic disease prediction system, if you have these diseases, you can be aware of the progression of the disease and prevent the progression of the disease in the early stages. Then, based on different parameters, appropriate treatment recommendations can be provided to patients. The accuracy of the diagnosis of chronic disease prediction systems depends on the accuracy of the proposed model in determining diagnostic patterns. Therefore, the more accurate the model, the greater the ability to predict patients at risk for chronic disease. In this study, a method for diagnosing chronic diseases based on patients’ health records using a referral system is presented. In this research, after extracting the basic features, the nearest neighbor method has been used. Experimental results show that the proposed method has a good performance in terms of evaluation criteria. The high accuracy of the proposed method indicates the high ability of this method to provide appropriate treatment recommendations in the proposed method. The results of the experiments in the proposed method show that, firstly, this method is 96.5% accurate in diagnosing the type of chronic patient, which is a very good value, and compared to the best available methods that were implemented based on neural networks, about 9% has improved. Second, the MAE rate of the proposed method in finding similar patients in the community of specific chronic patients was only 0.25%. The proposed method owes these appropriate values for accurate diagnosis of disease type and error of identification of similar patients to the proper use of machine learning methods. A major limitation of the proposed method is the lack of access to real hospital data. Due to patients’ privacy concerns, medical centers do not easily provide real information to researchers, and therefore, the proposed method uses the open access data in the data repository. However, despite the real data, the improvement of the proposed method can be seen in practice.In order to provide suggestions for future work, a combination of supervised or unsupervised learning methods with metaheuristics feature selection methods in order to finding useful features of patients to increase disease diagnosis accuracy can be advised. On the other hand, due to the fact that labeling in real data is a difficult task and most of the data related to patients in healthcare systems are unlabeled, the use of semisupervised methods to diagnose the type of disease in recommender systems can be helpful.



---

*Source: 5663001-2022-05-21.xml*