Published on in Vol 8, No 5 (2020): May

Preprints (earlier versions) of this paper are available at, first published .
Artificial Intelligence–Based Neural Network for the Diagnosis of Diabetes: Model Development

Artificial Intelligence–Based Neural Network for the Diagnosis of Diabetes: Model Development

Artificial Intelligence–Based Neural Network for the Diagnosis of Diabetes: Model Development

Authors of this article:

Yue Liu1 Author Orcid Image

Original Paper

The First People's Hospital of Fuyang, Hangzhou, Zhejiang Province China, Hangzhou, China

Corresponding Author:

Yue Liu, MA

The First People's Hospital of Fuyang

Zhejiang Province China

429 Beihuan Road

Fuyang District

Hangzhou, 311400


Phone: 86 13588381028


Background: The incidence of diabetes is increasing in China, and its impact on national health cannot be ignored. Smart medicine is a medical model that uses technology to assist the diagnosis and treatment of disease.

Objective: The aim of this paper was to apply artificial intelligence (AI) in the diagnosis of diabetes.

Methods: We established an AI diagnostic model in the MATLAB software platform based on a backpropagation neural network by collecting data for the cases of integration and extraction and selecting an input feature vector. Based on this diagnostic model, using an intelligent combination of the LabVIEW development platform and the MATLAB software-designed diabetes diagnosis system with user data, we called the neural network diagnostic module to correctly diagnose diabetes.

Results: Compared to conventional diagnostic procedures, the system can effectively improve diagnostic efficiency and save time for physicians.

Conclusions: The development of AI applications has utility to aid diabetes diagnosis.

JMIR Med Inform 2020;8(5):e18682



Artificial Intelligence and Smart Medicine

Artificial intelligence (AI) has meaningful benefits for human beings; its promotion in the development of medical technology can enable machines, algorithms, and big data to serve human health needs. In China, the incidence of diabetes is on the rise, and its impact on national health cannot be ignored. Diabetes is a disease in which the body metabolizes proteins, fats, sugars, and other substances in the blood, liver, and other organs because it does not properly produce or use insulin.

Smart medicine is a medical model that uses AI technology to assist diagnosis and treatment. In the future, smart medicine will be a core technology to fight disease and prolong human life. The advent of AI has increased the intelligence of computers, enabling them not only to “learn” expert medical knowledge but also to simulate the thinking and reasoning of physicians regarding patients. Therefore, computers can provide reliable diagnoses and treatment plans. AI can process huge amounts of data rapidly. Through the study of big data, AI can discover rules and summarizes their differences with regularity to diagnose diseases. Based on this background, in this paper, we introduced AI technology to an auxiliary diabetes diagnosis system. We used an AI neural network algorithm to establish an auxiliary diagnosis model and judge the type of diabetes based on physiological parameters input by a user. This may aid the diagnosis of diabetes in under-resourced areas or by inexperienced physicians.

Theoretical Basis

AI is an area of research and development involving the simulation, extension, and expansion of cutting-edge science and interdisciplinary intelligence theory, methods, techniques, and applications. The famous British scientist Alan Turing is known as the father of AI; in 1950, he published a famous paper [1], “Computing Machinery and Intelligence,” which provided the first definition of AI from a behaviorist point of view and proposed the concept of a “thinking machine” as well as the “Turing test” to determine whether a machine is intelligent. Many human activities, such as problem solving, riddle solving, online shopping, preparation of plans, writing computer programs, and even driving a car, require intelligence. If a machine can perform such tasks, the machine can be considered to possess artificial intelligence. Machine learning is a type of AI that uses algorithms to analyze data, learn from the analysis, and draw inferences or make predictions. As an important mathematical algorithm model in machine learning, neural networks have been successfully applied to many practical problems that are difficult for computers to solve in the fields of automatic control, pattern recognition, medicine, and economics. Neural networks have good intelligence characteristics and strong nonlinear processing ability. The application of neural networks in diabetes analysis and research has great significance. The relationship between neural networks, machine learning, and AI is shown in a Venn diagram in Figure 1 [2].

Figure 1. Venn diagram showing the relationship between neural networks, machine learning, and artificial intelligence.
View this figure

Overview of Artificial Neural Networks

Figure 2 shows a multilayer forward neural network. The computing nodes in this network are hidden layer and output layer neurons.

Hebb's learning rule adjusts the connection weight (wij) between neurons according to the principle that when neurons i and j are simultaneously excited, the connection between them must be strengthened:

wij = ηui(t)uj(t) (1)

Neurocytology has confirmed that this rule is consistent with conditioned reflex theory [a]. η(0<η<1) represents the proportionality constant of the learning rate and is also called the learning factor or learning step.

The δ learning rule adjusts the connection weight (wij) between neurons. When the output value of a neuron does not match the expected value, the weight of the neuron must be adjusted according to the difference between the expected value and the actual value [3]:

wij = η[diyi(t)]yi(t) (2)

This is the minimum mean square error learning rule. It is a special case of the δ learning rule. Its principle is adjustment of the mean square error between the actual output of the neuron and the expected output to the minimum, that is:


The principle is that “the winner is fully profitable,” that is, the neuron in a layer of neurons that produces the largest output value for the input is the “winner.” Then, the weights connected to the “winner” can simply be adjusted to bring it closer to the valuation of the input sample pattern:

wij = η[g(xi)wij(t)] (4)

A neural network simulates the structure of the human brain; the simplest model of a neural network is a perceptron, which consists of a set of interconnected nodes constituting a chain. Figure 3 shows the structure of a perceptron. It contains 2 types of nodes: several input nodes, consisting of attributes used to represent the input, and an output node that provides an output model. The nodes in a neural network structure are called neurons or units. In a perceptron, the input nodes and output node are connected by a weighted chain.

After the weighted summation of the input by the perceptron, the offset factor t is subtracted, and then the output value ŷ is obtained according to the sign of the result. For example, in a perceptron with 3 input nodes, the weight of each node to the output node is 0.3, the paranoid factor t is 0.4, and the output calculation formula of the model is as follows:


The difference between the input node and the output node of the perceptron is that the input node directly transmits the received value to the output chain without any conversion, while the output node performs a weighted summation on the input and then subtracts the bias term; the symbol then produces an output according to the result. Equation 6 is a mathematical representation of the output of the perceptron model:

ŷ = sign(w1x1 + w2x2 + ... + wnxn – t) (6)

where w1, w2, ... , wn is the weight of the input chain, x1, x2, ... , xn is the input attribute value, and sign is a symbolic function; when the parameter is positive, the activation function of the neuron is output +1, and when the parameter is negative, the activation function of the neuron is output –1 [4]. The perceptron model can also be expressed by Equation 7:

ŷ = sign(wxt) (7)

where w is the weight vector and x is the input vector.

Figure 2. Schematic of a multilayer forward neural network.
View this figure
Figure 3. Schematic of a perceptron.
View this figure

Principles of Data Mining

Data mining is also referred to as data collection or data gathering. The process of data mining involves finding and extracting information and knowledge with potential use value from a large amount of incomplete, noisy, and random practical application data. Data mining is an iterative process. In this process, information discovery is performed manually or intelligently. When exploring and researching an unknown database, it is impossible to predict the knowledge and information it contains. In contrast to traditional data analysis technology, data mining technology can describe the hidden features of many data categories, predict their development trends, and identify useful information with high decision-making value and guiding significance for work and life. As shown in Figure 4, data mining is universally applicable to various types of data [5].

Figure 4. Schematic of the data mining process.
View this figure

Diabetes Data Processing

Influencing Factors of Diabetes

At present, because the onset of diabetes is extremely complicated, its etiology and pathogenesis have not been fully elucidated. The recognized factors influencing the incidence of diabetes according to many medical report studies and data analyses of diabetic patients are shown in Figure 5.

Figure 5. Influencing factors of diabetes.
View this figure
Genetic Factors

The onset of diabetes has familial characteristics; if family members in the previous generation have diabetes, the probability of their offspring having diabetes is very high. The genetic factors of diabetes are clear. The prevalence of diabetes in people with a blood relationship to patients with diabetes is 5 times higher than that of people who do not have such a blood relationship [6]. Moreover, the risk of genetic factors in type 1 diabetes is 40% higher than in type 2 diabetes [7]. Medical research has identified a variety of genetic mutations that affect the onset of diabetes. For example, type 1 diabetes is closely related to the DQ site polymorphism in the human leukocyte antigen gene, and multiple DNA sites will affect the onset of the disease. Type 2 diabetes is also affected by mutations of genes such as the insulin-hormone gene and the glucokinase gene [8].

Dietary Factors

When the human body consumes more energy than it expends for a long time, obesity can result. Obesity is the most important risk factor for diabetes. Most patients with type 2 diabetes have other conditions, such as obesity, hypertension, and hyperlipidemia.

Environmental Factors

Environmental factors affecting diabetes mainly include population aging, reduced exercise volume, viral infection, and psychological stress. In populations susceptible to conditions caused by genetic factors, the onset of diabetes may also be affected by environmental factors. Lifestyle changes also greatly contribute to the increasing number of people with type 2 diabetes. In an American Indian tribe in Arizona, the incidence of obese and diabetic patients rose from 0% to 50% due to changes in the original lifestyle of the tribe members [9].

Psychological Factors

Psychological factors are often ignored by researchers; however, in recent years, many clinical medical studies have found that psychological factors have effects on the pathogenesis of diabetes [8]. Most scholars hold the view that when a person remains in a state of mental stress and depression for a long time, excessive stress and negative emotions will cause the body to respond to stress, quickly produce a large number of hormones that can increase blood sugar, and inhibit the production of insulin [3]. Studies have found that when a person's mood fluctuates, the blood glucose levels in their body will rise to varying degrees. If the person remains in this state for a long time, they have a high chance of developing diabetes [5].

Other Factors

There are various additional predisposing factors for diabetes. In addition to the 4 factors mentioned above, comprehensive influences include various physical indicators, such as age, gender, height and weight, blood pressure and blood lipids; adverse living habits, such as smoking and alcohol abuse; and taking estrogen [7].

Diagnostic Criteria of Diabetes

The blood glucose cutoff points for diabetic diagnosis are fasting blood glucose ≥7.0 millimoles per liter (126 milligrams per deciliter); 2 hour oral glucose tolerance test blood glucose ≥11.1 mmol/L (200 mg/dL); and random blood glucose ≥11.1 mmol/L (200 mg/dL) [10].

Patients with typical symptoms of diabetes (eg, frequent drinking, polyuria, polyphagia, weight loss) and who meet any of the above cutoff points can be diagnosed with diabetes. For those with no obvious symptoms, only the first or second cutoff point can be used as a diagnostic condition, and the patient’s blood glucose levels must be checked on another day. In impaired glucose regulation, the fasting blood glucose or glucose tolerance test 2 hours after taking glucose exceeds normal values but does not meet the diagnostic criteria for diabetes.

Collection and Preprocessing of Diabetes Data

We combined the theoretical knowledge of medical data mining to integrate and preprocess medical data from a Top 3 hospital in Lanzhou. The initial fasting blood glucose and 2 hour postprandial blood glucose levels of all patients with diabetes exceeded the standard values. More than 95% of the initial symptoms of patients with type 2 diabetes included thirst, dry mouth, excessive drinking, polyphagia, polyuria, and weight loss. The inheritance of diabetes was mainly manifested in type 1 diabetes. Type 2 diabetes was mostly caused by acquired habits or endocrine disorders. By comparing health data, it was found that people who smoke and drink perennially are at 50% higher risk for diabetes. Therefore, the above symptoms were used as important indicators for diagnosing patients with diabetes. In the data, 1 indicates yes and 0 indicates no.

Establishment of the Diagnosis Model and Analysis of the Results

Model Establishment Based on the Backpropagation Neural Network

There is currently no quantified standard for selecting the number of hidden layer units. is usually used to determine the number of hidden layer units. In this study, n was taken as 19, m as taken as 1, and the range of the numbers of hidden layer units in this model was initially determined.

As can be seen in Figure 6, when the number of hidden layer units is 12, the network and the number of iterations of the training effects are the best. Therefore, in this paper, we selected the number of hidden layer units as 12 to model the backpropagation neural network.

Figure 6. Establishment of the model based on the BP neural network.
View this figure

The sample regression coefficients are shown in Figure 7.

The 650 screened groups of patients with diabetes included 395 groups (60.8%) of patients with type 2 diabetes and 255 groups (39.2%) of patients with type 1 diabetes. The training set contained 590 groups in total, including 343 groups (58.1%) of patients with type 2 diabetes and 247 groups (41.9%) of patients with type 1 diabetes. The test set used 60 groups of data, including 39 groups (65%) of patients with type 2 diabetes and 21 groups (35%) of patients with type 1 diabetes.

The outputs of the test set were obtained after training the backpropagation neural network. The results showed that of the 41 type 2 diabetes groups, 38 (93%) were accurately diagnosed, while 3 (7%) were misdiagnosed. For the 19 type 1 diabetes groups, 17 (89%) were accurately diagnosed, while 2 (11%) were misdiagnosed.

Among the test data of the 60 groups, 5 groups of data were misdiagnosed, and the average correct diagnosis rate was 55/60 (92%). This percentage is feasible for diabetic diagnosis.

Figure 7. Sample regression with 12 hidden layer units.
View this figure

Implementation of a Diabetes Diagnosis System

The MATLAB platform (MathWorks, Inc) has a long history of use in research and application of neural networks; a variety of its implementation technologies and methods are now quite mature, especially since the emergence of the neural network toolbox. However, MATLAB has many limitations in practical applications, such as a poor user interface. Therefore, in this paper, we combined LabVIEW software (National Instruments Corporation) with MATLAB; we used the LabVIEW platform to design a graphical user interface while calling MATLAB script nodes and using their functional characteristics to diagnose diabetes.

System Design User Interface

The user login interface was mainly constructed using the while loop, event structure, Boolean function, string control, and conditional structure in LabVIEW. At the same time, the username subvirtual instrument (SubVI) and password decision SubVI were set in the main program of the login system.

When the Boolean space of the front panel account login value changes, the block diagram will check whether the account and password match the data stored in the user VI. A conditional structure is used. When the account and password are correct, the judgment condition is true; thus, the attribute node opens and the user can enter the main program, as shown in Figure 8. When the account and password data are not found in the user VI, the judgment condition is false, and an account or password error occurs. The program was written using both local variables and attribute nodes; thus, it is simple and functional. The password decision SubVI is shown in Figure 9.

In order to adapt to the situation where the user forgets their account name and password when using the diabetes diagnosis system, a password modification VI was designed in the main program. When the user forgets the account name and password, the password can be retrieved through the password recovery interface; Figure 10 shows a block diagram of the password modification function, which includes the conditional structure, Boolean function, and string control.

In the main program, the diabetes diagnosis system is constructed with a tiled sequential structure. There is no sequential structure in text programming; a text programming language can ​​execute statements in order, but the order of sequential execution is changed by loops and conditional structures. In contrast, LabVIEW uses a data flow method involving a multi-threaded parallel structure that drives the programming direction through the data flow. At the same time, we can implement multi-threading without any additional programming, which is an additional advantage of multi-threaded operation. In this operation mode, whether the node can run normally in LabVIEW depends entirely on whether the data are flowing into all the required inputs of the node. LabVIEW data is free to “swim.” It does not necessarily follow the default direction of data flow from left to right. Therefore, the sequence in which the block diagrams run is somewhat random, and the sequence of the LabVIEW block diagrams cannot be decided with complete accuracy.

Figure 8. The main program of the login system.
View this figure
Figure 9. The password decision SubVI.
View this figure
Figure 10. The password modification VI.
View this figure

Call of the MATLAB Neural Network Diagnostic Module

LabVIEW can relate to other languages ​​and software through interfaces; it can also be extended to multiple target platforms and operating systems to achieve user requirements for different numerical calculations and analyses. By running programs with MATLAB scripts in LabVIEW and communicating with MATLAB script nodes in MATLAB through LabVIEW, MATLAB’s powerful numerical calculation functions can be used in LabVIEW. Based on the above background, in this paper, we used LabVIEW to build a diabetes diagnosis system while modeling neural networks with MATLAB. The locations of the MATLAB script nodes in LabVIEW are shown in Figure 11.

Figure 11. Locations of the MATLAB script nodes in LabVIEW.
View this figure


In recent years, the development of smart medicine has been increasing in China as well as in other countries. Breakthroughs in key technologies such as image recognition, depth of learning, and neural networks have resulted in a new round of developments in AI. On the other hand, with the continuous improvement of human living standards, the incidence of diabetes in our country has also continued to rise; in reality, medical resources are unevenly distributed, with insufficient numbers of physicians, less experienced community physicians, and other issues. More efficient allocation of medical resources reduces misdiagnosis due to lack of experience; this paper proposes combining AI technology with diabetes diagnosis to build a diagnostic system that helps physicians diagnose diabetes.

Conflicts of Interest

None declared.

  1. Turing AM. Computing Machinery and Intelligence. Mind 1950 Oct;59(236):433-460. [CrossRef]
  2. Lawrence DR, Palacios-González C, Harris J. Artificial Intelligence. Camb Q Healthc Ethics 2016 Mar 09;25(2):250-261. [CrossRef]
  3. Johnson KW, Torres Soto J, Glicksberg BS, Shameer K, Miotto R, Ali M, et al. Artificial Intelligence in Cardiology. J Am Coll Cardiol 2018 Jun;71(23):2668-2679. [CrossRef]
  4. Shaofei W, Mingqing W, Yuntao Z. Research on internet information mining based on agent algorithm. Future Gener Comp Sy 2018;86:598-602. [CrossRef]
  5. Lopes BT, Eliasy A, Ambrosio R. Artificial Intelligence in Corneal Diagnosis: Where Are We? Curr Ophthalmol Rep 2019 Jul 9;7(3):204-211. [CrossRef]
  6. Kontoangelos K, Papageorgiou CC, Raptis AE, Tsiotra P, Boutati E, Papadimitriou GN, et al. The role of oxytocin, cortizol, homocysteine and cytokines in diabetes mellitus and their association with psychological factors. Arch Hellen Med 2014;31(1):7-22 [FREE Full text]
  7. Dong G, Qu L, Gong X, Pang B, Yan W, Wei J. Effect of Social Factors and the Natural Environment on the Etiology and Pathogenesis of Diabetes Mellitus. Int J Endocrinol 2019;2019:8749291 [FREE Full text] [CrossRef] [Medline]
  8. Martinez-Millana A, Bayo-Monton JL, Argente-Pla M, Fernandez-Llatas C, Merino-Torres JF, Traver-Salcedo V. Integration of Distributed Services and Hybrid Models Based on Process Choreography to Predict and Detect Type 2 Diabetes. Sensors (Basel) 2017 Dec 29;18(1) [FREE Full text] [CrossRef] [Medline]
  9. Ravussin E, Valencia ME, Esparza J, Bennett PH, Schulz LO. Effects of a traditional lifestyle on obesity in Pima Indians. Diabetes Care 1994 Sep;17(9):1067-1074. [CrossRef] [Medline]
  10. Mathur P, Burns ML. Artificial Intelligence in Critical Care. Int Anesthesiol Clin 2019;57(2):89-102. [CrossRef] [Medline]

AI: artificial intelligence
SubVI: subvirtual instrument
VI: virtual instrument

Edited by K Kalemaki; submitted 12.03.20; peer-reviewed by И Иванова, D Yang, L Huang; comments to author 19.03.20; revised version received 21.03.20; accepted 22.03.20; published 27.05.20


©Yue Liu. Originally published in JMIR Medical Informatics (, 27.05.2020.

This is an open-access article distributed under the terms of the Creative Commons Attribution License (, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work, first published in JMIR Medical Informatics, is properly cited. The complete bibliographic information, a link to the original publication on, as well as this copyright and license information must be included.