IT0089 TB391 Decision Tree - Coyohan
IT0089 TB391 Decision Tree - Coyohan
Objectives: To exercise the last discussion we had with classification algorithms via R
language, we will perform an activity where you study the data and create a classification
model to detect if someone has a diabetes based on the attributes.
Outcome Age
BMI
Glucose
BloodPressure
# Splitting the dataset into the Training set and Test set
# install.packages('caTools')
library(caTools)
set.seed(123)
split = sample.split(dataset$Outcome, SplitRatio = 0.70)
head(split)
training_set = subset(dataset, split == TRUE)
test_set = subset(dataset, split == FALSE)
# Feature Scaling
training_set[-3] = scale(training_set[-3])
test_set[-3] = scale(test_set[-3])
classifier
# Predicting the Test set results
y_pred = predict(classifier, newdata = test_set[-3], type = 'class')
-If Outcome is less than the value of Glucose of 144 and if Glucose is less than 102
then the person has a 6 percent of having no diabetes
-If outcome is less than the value of Glucose of 144 and if Glucose is greater than 102
and BMI is less than 26 then the person has a 8 percent of having no diabetes
-If outcome is less than the value of Glucose of 144 and if Glucose is less than 102 and
if BMI is less than 26 then the person has a 26 percent of having no diabetes
-If Outcome is less than the value of glucose of 144 and if Glucose is less than 102 and
BMI is greater than 26 and age is greater than 29 and age is less than to 55 then the
person has a 18 percent chance of having no diabetes
-If Outcome is less than the value of glucose of 144 and if Glucose is less than 102 and
BMI is greater than 26 and age is greater than 29 and age is greater than or equal to 55
and blood pressure is less than 89 then the person has a 25 percent chance of having
no diabetes
-If Outcome is less than the value of glucose of 144 and if Glucose is less than 102 and
BMI is greater than 26 and age is greater than 29 and age is greater than or equal to 55
and blood pressure is greater than or equal to 89 and age is less than 33 and BMI is
less than 32 then the person has a chance of 33 percent of having no diabetes
-If Outcome is less than the value of glucose of 144 and if Glucose is less than 102 and
BMI is greater than 26 and age is greater than 29 and age is greater than or equal to 55
and blood pressure is greater than or equal to 89 and age is less than 33 and BMI is
greater than 32 then the person has a chance of 67 percent of having diabetes
-If Outcome is less than the value of glucose of 144 and if Glucose is less than 102 and
BMI is greater than 26 and age is greater than 29 and age is greater than or equal to 55
and blood pressure is greater than or equal to 89 and age is greater than 33 and
glucose is less than 107 then the person has 38 percent chance of having no diabetes
If Outcome is less than the value of glucose of 144 and if Glucose is less than 102 and
BMI is greater than 26 and age is greater than 29 and age is greater than or equal to 55
and blood pressure is greater than or equal to 89 and age is greater than 33 and
glucose is greater than 107 then the person has 71 percent chance of having diabetes
-If Outcome is greater than the value of Glucose of 144 and if Glucose is less than 162
and age is less than 41 and BMI is less than 30 then the person has a 25 percent of
having no diabetes
-If Outcome is greater than the value of Glucose of 144 and if Glucose is less than 162
and age is less than 41 and BMI is greater than 30 and age is less than 33 then the
person has a 43 percent of having no diabetes
-If Outcome is greater than the value of Glucose of 144 and if Glucose is less than 162
and age is less than 41 and BMI is greater than 30 and age is greater than 33 then the
person has a 73 percent of having diabetes
If Outcome is greater than the value of Glucose of 144 and if Glucose is less than 162
and age is greater than 41 then the person has 81 percent of having diabetes
-If Outcome is less than the value of Glucose of 144 and if Glucose is greater than 102
then the person has a 87 percent of having diabetes