Caesarean dataset classification using matlab

Published by sandesh on

A pregnant woman can give birth to younger ones with or without a caesarean operation. They depend upon many factors like the age of the woman, what is the delivery number, delivery time (if the pregnant is brought to the hospital at the correct time or not), blood pressure of the patient and if she has a heart problem or not. The dataset is downloaded from here.

Key concepts:

  1. Training data: data which will be used for training the model.
  2. Validation data: data which will be used for validating the trained data (checking if the trained model is correct or not).
  3. Testing data: data which is used for testing the model.
  4. Hidden neurons: Initially,random weights are given to each sample. Then classification is done, and based on the result obtained, weight is adjusted and classified again. Hidden neurons are the number of times the process should run to adjust weights.

Installing project in your pc:

  1. You need to first have matlab in your pc. Download matlab from this link if you don’t have matlab.
  2. Then, clone the project from here.
  1. After cloning, unzip the file. Run “ maincode.m ” in the matlab.

Code explanation:

  1. In the beginning, the file (maindata.txt) in which data is stored is loaded into matlab. The file has 80 rows, that is for 80 different conditions, and has 6 columns in which the first 5 are attributes (age, delivery number, delivery time, blood pressure and heart problem) and the last column is the target column. Target means the expected output, that is 1 if caesarean is required and 0 if not required. Then each column is kept in an array, and the target column is stored in “colyn”.
  1. After that, data with target 1 are stored in class1data and with target 0 are stored in class2data.
  1. They both are appended one by one into Z1 vector. Then 46 (length of class1 data) “1” values are appended with 34(length of class1 data) “-1” values and are stored in “TargetVector1”. This is appended to Z1 and are stored in “z”.
  1. You use these variables for classification according to the requirement.

How to run the code in matlab (for classification learners) :

1.First, run maincode.m in your pc. Then in the apps section click on the dropdown present to the extreme right and then click on classification learner, that is present under “machine learning”.

2.After that, click on new session -> from workspace.

3. In the workspace variable, select ‘z’, and click on start session which is present on the bottom right.

4.Click on the dropdown to select the required classifier and click on “train”. You can also run all classifiers by clicking on “all”. Then click on “Train”. The given dataset will be classified according to the given classifier.

How to run the code in matlab (for neural networking) :

  1. First, run maincode.m in your pc. Then in the apps section click on the dropdown present to the extreme right and then click on neural network pattern recognition, that is present under “machine learning”.
  2. Then this appears, click on next, present on bottom right.
  3. Then, enter “z” as input and “colyn” as target. Don’t forget to change samples as matrix rows from matrix columns. Click on next.
  1. Adjust Training, Validation and Testing data according to your convenience, or leave it as it is. Click on next.
  2. Adjust hidden neurons’ value according to your convenience or use the default value. Higher the value, higher the expected accuracy. Click on next.
  1. Click on train, to train the model. After that, click on plot confusion and plot ROC to plot confusion matrix (matrix which states true and false positives and negatives for the classifications) and ROC curve (curve which illustrates diagnostic ability of a binary classifier, obtained by plotting True positives and False positives bychanging thresholds ). Click on next.
  1. You can evaluate your network by changing inputs given. Click on next.
  1. You can deploy the solution in various forms. Click on next.
  1. You can save the obtained results according to your convenience. Click on finish to close.

Conclusion :

Using the given process, we can assess if a pregnant woman requires caesarean for delivery or not. This saves time, especially in case of an emergency. You can always try to classify various problems using this process.


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.