See discussions, stats, and author profiles for this publication at: [Link]
net/publication/353487060
Diabetes Detection Using Machine Learning Classification Methods
Conference Paper · July 2021
DOI: 10.1109/ICIT52682.2021.9491788
CITATIONS READS
20 779
2 authors, including:
Amjed Almousa
Princess Sumaya University for Technology
41 PUBLICATIONS 355 CITATIONS
SEE PROFILE
All content following this page was uploaded by Amjed Almousa on 27 July 2022.
The user has requested enhancement of the downloaded file.
Diabetes Detection Using Machine Learning
Classification Methods
Nour Abdulhadi Amjed Al-Mousa
Computer Engineering Department Computer Engineering Department
Princess Sumaya University for Technology Princess Sumaya University for Technology
Amman, Jordan Amman, Jordan
nou20180738@[Link] [Link]@[Link]
Abstract— The main objective of this research is to predict the conducted on this specific group to generate this dataset. It
possible presence of diabetes -specifically in females- at an early consists of 8 medical predictor variables (attributes), and a
stage using different machine learning techniques. Early single target, outcome. The outcome is the variable that
detection of diabetes can significantly prevent the progression of
the disease and reduce the risk of serious complications such as specifies if a patient has been diagnosed with type 2
heart and kidney diseases, making the proper lifestyle changes at diabetes or not. The dataset contains 768 instances.
the right time can help avoid diabetes and all the illnesses
associated with it. So, there is a crucial need for a tool that can The remaining part of the paper is organized as follows:
better assist doctors to detect this deadly disease at an early stage Section II includes previous work that addressed the same
and consequently stop its progression. Finally, this model problem. Section III introduces the complex details of the
produced an accuracy of 82% based on the random forest
classifier model.
used dataset, the process of preparing the data and making
it suitable for a machine learning model, and the machine
Keywords—Machine learning; diabetes; mellitus; Pima learning algorithms used. Moreover, the results of every
Indians dataset; classification; technique used and the associated accuracy of it are
presented in Section IV. At last, a conclusion is outlined in
section V.
I. INTRODUCTION
II. RELATED WORK
Diabetes is a disease where glucose, or blood sugar, is not
metabolized by the body which increases the glucose rate Machine learning has been used successfully for the
to alarmingly high levels. Normally, a hormone called prediction of many outcomes, ranging from the likelihood
insulin helps control the amount of glucose in one’s of being admitted to a university [7], predicting what books
bloodstream, people with diabetes either don’t produce you might like based on your history [8], or even predicting
insulin (type 1 diabetes) or don’t respond to insulin the way who tweeted a certain tweet [9]. But a more relevant case
they should (type 2 diabetes). Approximately, 90% of all is the use of machine learning in the detection of heart
diagnosed cases of diabetes are that of type 2. [1] disease using majority ensemble methods [10]. In addition,
multiple algorithms and models have been trained in the
According to [2], the number of people living with diabetes field of diabetes detection, and several methods have been
more than tripled between 1990 and 2010, and the number used to perform data pre-processing. In [11], a dataset
of new cases doubled every year. Why are the numbers consisting of 178131 instances has been used to train a
rising so fast? Obesity is believed to account for 80-85% of model that reached an accuracy of 80.8%. The model used
the risk of developing type 2 diabetes [3] and the World the Random Forest Classifier method when using all 14
Health Organization (WHO) studies have shown that physical examination features that included: age, pulse rate,
worldwide obesity has nearly tripled since 1975 [4], this height, weight, fasting glucose, etc.
leads to the belief that the escalating rates of obesity and A model using the Pima Indians Dataset used the k-nearest
type 2 diabetes are directly linked to each other. One of the neighbor (KNN) algorithm and tried different k-values
reasons for the global rise in obesity is that people are ranging from 1 to 100 to reach a maximum receiver
eating more high-calorie, high-fat foods and are less operating characteristic accuracy of 74% when k was set to
physically active [5] because new technological 0. [12]
advancements provide entertainment, education, Moreover, the paper in [13] is a study to build an effective
communication, and all type of purchases right on the spot. prediction model to identify Canadian patients at risk of
having Diabetes Mellitus based on patient demographic
This model focuses on the early detection of type 2 diabetes data and the laboratory results during their visits to medical
because it is more common. [1] To carry out the training facilities, it has been trained on a dataset that contains
and testing of the machine learning model, the Pima 13309 Canadian patients with their ages ranging between
Indians dataset from the National Institute of Diabetes and 18 and 90 years. The Gradient Boosting Machine (GBM)
Digestive and Kidney Diseases was used. All patients in technique performed best according to the evaluation of
this dataset are females that are at least 21 years old and area under the receiver operating characteristic curve
with Pima Indian Heritage, Pima Indians in the United (AROC), the AROC for this model is 84.7% with a
States have the world’s highest recorded prevalence and sensitivity of 71.6%.
incidence of type 2 diabetes [6] which is why the study was
Table 1: PIMA Indian Dataset Attributes Description
Attributes Range Description
Pregnancies 0-17 Number of times pregnant
Glucose 0-199 Plasma glucose concentration a 2 hours in an oral glucose tolerance test
Blood Pressure 0-122 Diastolic blood pressure (mm Hg)
BMI 0-67.1 Body mass index = (weight in kg/(height in m)^2)
Skin Thickness 0-99 Triceps skin fold thickness (mm)
Diabetes Pedigree Function 0.078-2.42 A function that scores the likelihood of diabetes based on family history
Age 21-81 Age in years
Insulin 0-846 2-Hour serum insulin (mu U/ml)
Outcome 0-1 Class variable, diagnoses classes: 0 = healthy, 1 = diagnosed with diabetes
Table 2: Correlation with Outcome (Target)
Finally, the research in [14] used multiple techniques on
different datasets. The algorithms used included Naïve Attribute Correlation Value
Bayesian, Random Forest (RF), KNN and used evaluation
techniques like K-fold Cross-Validation. The highest Pregnancies 0.22
accuracy achieved on the Pima Indian dataset (which was
used as an example of a numeric-only dataset in the Glucose 0.49
research) was 64.47% using the k-fold cross-validation
Blood Pressure 0.17
technique.
BMI 0.22
III. EXPERIMENTAL SETUP
Skin Thickness 0.21
The main purpose of this paper is to build a model that Diabetes Pedigree Function 0.31
predicts diabetes at an early stage using the previously
Age 0.17
mentioned dataset. It is a real-world dataset taken from a
specific group in a specific area as previously mentioned. Insulin 0.24
Part of the data will be used to train the model, and the other
to test it making it able to adapt to new unknown data to
predict the outcome. The heat map of the calculated correlation values is shown
in Figure 1 below.
A. Dataset Attribute Information
Each of the 768 instances in the dataset has 9 attributes, one
of them being the target variable. A description of each
attribute is present in Table 1.
To get a further insight into the data, correlation values
were calculated to know how much an attribute affects the
target attribute (Outcome) or if other attributes are affected
by it. Correlation values were calculated using the Pearson
(product-moment) correlation coefficient equation. It
computes the ratio of the covariance of both features to the
product of their standard deviations consequently finding
the measure of the linear relationship between those two
features. Correlation values are shown in Table 2.
Figure 1: Heat map to show the correlation between features
Figure 2: Histograms of the different attributes
It can be observed that glucose has the highest positive feature contributes approximately proportionately to the
correlation with the outcome variable, followed by final decision. The dataset was standardized using a
Diabetes Pedigree Function. standard scaler.
Moreover, histograms were generated to have a better IV. MACHINE LEARNING ALGORITHM
visual interpretation of the data, shown in Figure 2. In
addition to the better visualization histograms provide, the After analyzing the data and filling in all the missing values
figures can make it easier to detect possible outliers that in attributes such as blood pressure, skin thickness, and
may negatively affect the proposed model. BMI, the data was split into two parts: test set and training
set. The training set will be used to test the model, while
B. Data Preprocessing the test set will be used to validate the ability of the model
to generalize to new data. The classifier models that have
The quality of the data used to train the model significantly been tested are:
affects the results, especially when exposed to new data.
Real-world data can contain errors or missing values, as A. Logistic Regression Classifier
well as outliers. Preprocessing of data helps minimize the
effect of such errors, increasing the success rate of the
The first model that was used is the Logistic Regression
project at hand.
Classifier, it is similar to the linear regression model that
computes a weighted sum of the input features, but instead
In the Pima Indian Dataset, multiple values were missing
of outputting the result as the Linear Regression does, it
from a couple of instances. Having zero blood pressure, for
outputs the logistic of the result. [15] It models the chance
example, does not make any sense. Since the number of
of a certain outcome based on individual characteristics.
instances present (768) was quite low, instead of dropping
instances with zeros, the values were filled with the mean.
Please note that Figure 1 was generated after the missing B. Linear Discriminant Analysis (LDA)
values were filled in.
Linear Discriminant Analysis projects the features in
Also, the dataset had different scales, so it had to be higher dimension space onto a lower-dimensional space.
standardized. Skipping this step could lead to the [16] A series of steps are performed starting by calculating
contribution of a feature more than the other to the target, the between-class variance, followed by the within-class
whereas when the range of all features is normalized each variance, and finally constructing a lower-dimensional
space that minimizes the within-class variance calculated The second model was trained using the Linear
and maximizes the between-class variance. Discriminant Analysis classifier. The accuracy of the
model, when run on the unseen test set, was 79%. Figure 4
C. Linear Support Vector Machine (SVC) shows the confusion matrix obtained from this model.
Linear SVC is one of the algorithms that is commonly used
when the data is likely to be linearly separable. According
to [17], “the objective of a Linear SVC (Support Vector
Classifier) is to fit the data you provide, returning a "best
fit" hyperplane that divides, or categorizes your data. From
there, after getting the hyperplane, you can then feed some
features to your classifier to see what the "predicted" class
is.”
D. Polynomial Kernel with SVC
The polynomial kernel method with SVC is similar to
Linear SVC mentioned above, but it allows the learning of
non-linear models instead of only linear. The kernel simply Figure 4: Linear Discriminant Analysis Confusion Matrix
adds more features to the data by making combinations of
the features already present, and since increasing the Next, the model was trained using the Linear Support
number of features increases the possibility of the data Vector Machine. The parameters were set as C=1, kernel =
being linearly separable it may result in a higher accuracy ‘Linear’ as the nonlinear one will be tested next. The
compared to a model that only uses linear SVC. accuracy obtained from this model was also 79%. Figure 5
shows its confusion matrix.
E. Random Forest Classifier
This method is one of the simplest and most diverse
algorithms used for both classification and regression tasks,
it uses multiple individual decision trees to operate as a
single one. Each tree classifies the class to which an
instance belongs, and the class with the highest votes is the
predicted class.
F. Voting Classifier
A voting classifier makes predictions using multiple
classifiers and predicts the output based on the predicted Figure 5: Linear SVM Confusion Matrix
probabilities for each classifier, since the model uses soft
voting the outcome chosen depends on the calculated Moving on to the fourth model, it was trained using
weighted probabilities. The three models I used in this polynomial SVM of degree 2, and C was set to 5. This
classifier are LDA, Logistic Regression, and Random model had an accuracy of 79%. Figure 6 shows the
Forest Classifier. confusion matrix of its results.
V. RESULTS
Beginning with the logistic regression classifier, the
accuracy of the trained model on the unseen dataset was
80%. Figure 3 shows the confusion matrix of this model.
Figure 6: Polynomial SVM Confusion Matrix
Reaching the highest-scoring classifier, the model was
trained using the Random forest technique obtaining the
highest accuracy among the mentioned classifiers. The
Figure 3: Logistic Regression Confusion Matrix accuracy, when run on unseen data, was 82%. Figure 7
shows the confusion matrix of its results.
ACKNOWLEDGMENTS
The authors would like to thank PSUT for supporting the
publication of this research, which is based on a machine
learning class project.
REFERENCES
[1] "Diabetes Fast Facts," [Online]. Available:
[Link]
[2] "Statistics and facts about type 2 diabetes," Medical news today,
[Online]. Available:
Figure 7: Random Forest Classifier Confusion Matrix [Link]
[3] "Diabetes and Obesity," The global diabetes community, [Online].
Reaching the final classifier, the model was trained using Available: [Link]
the voting classifier. The three models LDA, Logistic [4] "Obesity and overweight," World Health Organization, [Online].
Regression, and Random Forest Classifier had accuracies Available: [Link]
of 79%, 80%, and 82% respectively. The voting classifier sheets/detail/obesity-and-overweight.
that combined all of them had an accuracy of 80%. Figure [5] "Obesity Rising: Can We Do Anything to Reverse This Deadly
8 below shows the confusion matrix of this classifier. Trend?," healthline, [Online]. Available:
[Link]
reverse-this-deadly-trend#Complex-factors-behind-obesity.
[6] L. O. Schulz, P. H. Bennett, E. Ravussin, J. R. Kidd, K. K. Kidd,
J. Esparza and M. E. Valencia, "Effects of Traditional and
Western Environments on Prevalence of Type 2 Diabetes in Pima
Indians in Mexico and the U.S.," Diabetes Care, vol. 29, no. 8, pp.
1866--1871, 2006.
[7] Z. Bitar and A. A. Al-Mousa, "Prediction of Graduate Admission
using Multiple Supervised Machine Learning Models," in IEEE
SoutheastCon, Raleigh, 2020.
[8] S. Khalifeh and A. A. Al-Mousa, "A Book Recommender System
Using Collaborative Filtering," in Data'21, Petra, 2021.
[9] L. Ahmad and A. A. Al-Mousa, "Identification of Donald
Trump’s Tweets Using Machine Learning," in Multi-Conference
on Systems, Signals & Devices, Monastir, 2021.
Figure 8: Voting Classifier Confusion Matrix
[10] R. Atallah and A. A. Al-Mousa, "Heart Disease Detection Using
Machine Learning Majority Voting Ensemble Method," in 2nd
Table 3 shows the accuracy scores of the 6 models International Conference on new Trends in Computing Sciences
trained. (ICTCS), Amman, 2019.
[11] Q. Zou, K. Qu, Y. Luo, D. Yin, Y. Ju and H. Tang, "Predicting
Table 3: Accuracy of Trained Models Diabetes Mellitus With Machine Learning Techniques," Front
Genet, vol. 9, no. 515, 2018.
Model Name Accuracy
[12] H. Deshmukh, "Pima Indians Diabetes - Prediction & KNN
Visualization," towards data science, [Online]. Available:
Logistic Regression 80% [Link]
knn-visualization-5527c154afff.
LDA 79% [13] H. Lai, H. Huang, K. Keshavjee, A. Guergachi and X. Gao,
Linear SVC 79% "Predictive models for diabetes mellitus using machine learning
techniques," BMC Endocr Disord, vol. 19, no. 101, 2019.
Polynomial kernel SVC 79% [14] M. N. H. R. L. Asmita Singh, "Impact of Different Data Types on
Classifier," Melbourne, 2017.
Random Forest Classifier 82%
[15] J. Zheng, "Resume of Logistic & Softmax Regression," 16 April
Voting Classifier 80% 2019. [Online]. Available: [Link]
logistic-softmax-regression/.
[16] J. Brownlee, "Linear Discriminant Analysis for Dimensionality
Reduction in Python," Machine Learning Mastery, 2020. [Online].
VI. CONCLUSION Available: [Link]
discriminant-analysis-for-dimensionality-reduction-in-python/.
In a nutshell, this project’s main goal was to build a model [17] "Linear SVC Machine learning SVM example with Python,"
using supervised learning methods that could help assist PythonProgramming, [Online]. Available:
doctors in the early detection of diabetes to improve the [Link]
svm-python/.
quality of patient’s lives. The paper presented multiple
techniques that were used to train multiple models,
Random Forest Classifier achieved the highest accuracy of
82%.
View publication stats