Urinary inflammation diagnosis

End-to-end machine learning examples

The goal of this example is to design a model that can diagnose the disease of the acute inflammations/nephritises of urinary bladder.

This is a medical diagnosis application.

The data was created by a medical expert as a data set to test the expert system, which will perform the presumptive diagnosis of two diseases of urinary system. Each instance represents an potential patient.

The main idea of this data set is to prepare the algorithm of the expert system, which will perform the presumptive diagnosis of two diseases of urinary system. It will be the example of diagnosing of the acute inflammations of urinary bladder and acute nephritises. For better understanding of the problem let us consider definitions of both diseases given by medics. Acute inflammation of urinary bladder is characterised by sudden occurrence of pains in the abdomen region and the urination in form of constant urine pushing, micturition pains and sometimes lack of urine keeping. Temperature of the body is rising, however most often not above 38C. The excreted urine is turbid and sometimes bloody. At proper treatment, symptoms decay usually within several days. However, there is inclination to returns. At persons with acute inflammation of urinary bladder, we should expect that the illness will turn into protracted form.

Acute nephritis of renal pelvis origin occurs considerably more often at women than at men. It begins with sudden fever, which reaches, and sometimes exceeds 40C. The fever is accompanied by shivers and one- or both-side lumbar pains, which are sometimes very strong. Symptoms of acute inflammation of urinary bladder appear very often. Quite not infrequently there are nausea and vomiting and spread pains of whole abdomen.

Contents:

  1. Application type
  2. Data set
  3. Neural network
  4. Training strategy
  5. Model selection
  6. Testing analysis
  7. Model deployment

1. Application type

This is a classification project, since the variable to be predicted is binary (nephritises of urinary bladder or not).

The goal here is to model the probability of nephritises of urinary bladder, conditioned on the patient sympthoms.

2. Data set

The data file urinary_inflammation.csv contains 120 rows and 8 columns.

This data set contains the follwoing variables:

As the objective is to get a model that can diagnose the first of the diseases, the variable of acute nephritises diagnosis will be set as unused.

The instances are divided into a training, a selection and a testing subsets. They represent 60%(72) , 20% (24) and 20% (24) of the original instances, respectively, and are splitted at random.

3. Neural network

The second step is to choose a network architecture to represent the classification function. For classification problems, it is composed by:

The next figure is a diagram for the neural network used in this example.

4. Training strategy

The fourth step is to set the training strategy, which is composed by:

The loss index chosen for this application is the normalized squared error with L2 regularization.

The learning problem can be stated as to find a neural network which minimizes the loss index, i.e., a neural network that fits the data set (error term) and that does not oscillate (regularization term).

The next step in solving this problem is to assign the training strategy.

The neural network is trained to obtain the best possible performance.

We can see that the training and selection errors are small.

5. Model selection

The objective of model selection is to improve the generalization capabilities of the neural network or, in other words, to reduce the selection error.

Since the selection error that we have achieved so far is very small (XXX), we neither apply order selection nor inputs selection here.

6. Testing analysis

An exhaustive testing analysis is performed to validate the generalization performance of the trained neural network. To validate a classification model, we need to compare the values provided by this technique to the actually observed values.

A standard testing method for classification problem is the ROC curve. The ROC curve is computed by plotting in the x-axis the 1-specificity and in the y-axis the sensitivity for different thresholds. For a perfect classifier, the ROC curve passes through the upper left corner, i.e., the point (0,1), which has 100% sensitivity and 100% specificity. In consequence, the closer to upper left corner ROC curve, the better the discrimination capacity. This can be also measured with the area under curve (AUC) parameter. For a perfect classifier the AUC is 1. The next figure shows the results of this analysis in this case.

The area under curve is AUC = 1. These results illustrate a perfect perfomance of the model.

The following table contains the elements of the confusion matrix. It contains the true positives, the false positives, the false negatives, the true negatives for the variable diagnose.

Predicted positive Predicted negative
Real positive 11 0
Real negative 0 13

The number of correctly classified instances is 24, and the number of misclassified instances is 0.

7. Model deployment

The neural network is now ready to predict outputs for inputs that it has never seen.

We calculate the neural network outputs to diagnose inflammation of urinary bladder from the features of a new patient. The next table shows the inputs and the corresponding output for that patient.

  • Temperature: 38.7
  • Occurrence of nausea:
  • Lumbar pain:
  • Urine purshing:
  • Micturition pains:
  • Burning of urethra:
  • Inflammation of urinay bladder:

We can export the mathematical expression of the neural network. That expression is listed below.

        

References:

Related examples:

Related solutions: