Example of CART® Classification

A team of researchers collects and publishes detailed information about factors that affect heart disease. Variables include age, sex, cholesterol levels, maximum heart rate, and more. This example is based on a public data set that gives detailed information about heart disease. The original data are from archive.ics.uci.edu.

The researchers want to create a classification tree that identifies important predictors to indicate whether a patient has heart disease.

  1. Open the sample data, HeartDiseaseBinary.mtw.
  2. Choose Stat > Predictive Analytics > CART® Classification.
  3. From the drop-down list, select Binary response.
  4. In Response, enter Heart Disease.
  5. In Response event, select Yes to indicate that heart disease has been identified in the patient.
  6. In Continuous predictors, enter Age, Rest Blood Pressure, Cholesterol, Max Heart Rate, and Old Peak.
  7. In Categorical predictors, enter Sex, Chest Pain Type, Fasting Blood Sugar, Rest ECG, Exercise Angina, Slope, Major Vessels, and Thal.
  8. Click OK.

Interpret the results

By default, Minitab displays the smallest tree with a misclassification cost within 1 standard error of the tree that minimizes the misclassification cost. This tree has 4 terminal nodes.

Before the researchers examine the tree, they look at the plot that shows the misclassification cost from the cross-validation and the number of terminal nodes. In this plot, the pattern where the misclassification cost decreases continues after the 4-node tree. In a case like this, the analysts choose to explore some of the other simple trees that have lower misclassification costs.

Select an alternative tree

  1. In the output, click Select an Alternative Tree
  2. In the plot, select the 7-node tree that has the least misclassification cost and the best ROC value.
  3. Click Create Tree.

Interpret the results

In the tree diagram, items that are blue are for the event level. Items that are red are for the nonevent level. In this output, the event level is "Yes" and indicates that someone has heart disease. The nonevent level is "No" and indicates that someone does not have heart disease.

At the root node, there are 139 counts of the Yes event and 164 counts of the No event. The root node is split using the variable, THAL. When THAL = Normal, go to the left node (Node 2). When THAL = Fixed or Reversible, go to the right node (Node 5).
  • Node 2: There are 167 cases when THAL was Normal. Of the 167 cases, 38 or 22.8% are Yes and 129 or 77.2% are No.
  • Node 5: There are 136 cases when THAL was Fixed or Reversible. Of the 136 cases, 101 or 74.3% are Yes and 35 or 25.7% are No.

The next splitter for both the left child node and the right child node is Chest Pain Type, where pain is rated as 1, 2, 3, or 4.

Explore other nodes to see which variables are most interesting. The nodes that are mostly blue indicate a strong proportion of the event level. The nodes that are mostly red indicate a strong proportion of the nonevent level.

The tree diagram uses the entire data set or the training data set. You can toggle views of the tree between the detailed view and the node split view.

This tree has a misclassification cost of about 0.391.

The most important predictor variable is Chest Pain Type. If the contribution of the top predictor variable, Chest Pain Type, is 100%, then the next important variable, Major Vessels, has a contribution of 86.5%. This means Major Vessels is 86.5% as important as Chest Pain Type in this classification tree.

The area under the ROC curve for the test data is 0.8200, which indicates reasonable classification performance, in many applications. For applications that require greater prediction accuracy, you can try to improve the performance with a TreeNet® Classification model or a Random Forests® Classification model.

In this example, the gain chart shows a sharp increase above the reference line, then a flattening. In this case, approximately 40% of the data account for approximately 70% of the true positives.

In this example, the lift chart shows an increase above the reference line that gradually drops off.

7 Node CART® Classification: Heart Disease versus Age, Rest Blood Pressure, Cholesterol, Max Heart Rate, Old Peak, Sex, Fasting Blood Sugar, Exercise Angina, Rest ECG, Slope, Thal, Chest Pain Type, Major Vessels

Method

Prior probabilitiesSame for all classes
Node splittingGini
Optimal treeMinimum misclassification cost
Model validation10-fold cross-validation
Rows used303

Binary Response Information

VariableClassCount%
Heart DiseaseYes (Event)13945.87
  No16454.13
  All303100.00

Model Summary

Total predictors13
Important predictors13
Number of terminal nodes7
Minimum terminal node size5
StatisticsTrainingTest
Average -loglikelihood0.39710.5094
Area under ROC curve0.88610.8200
        95% CI(0.5590, 1)(0.7702, 0.8697)
Lift1.93761.8165
Misclassification cost0.29240.3909

Confusion Matrix



Predicted Class
(Training)





Predicted Class (Test)
Actual ClassCountYesNo% CorrectYesNo% Correct
Yes (Event)1391172284.21053475.5
No1642214286.62414085.4
All30313916485.512917480.9
StatisticsTraining (%)Test (%)
True positive rate (sensitivity or power)84.275.5
False positive rate (type I error)13.414.6
False negative rate (type II error)15.824.5
True negative rate (specificity)86.685.4

Misclassification

Input
Misclassification
Cost
Predicted
Class
Actual ClassYesNo
Yes  1.00
No1.00 


TrainingTest
Actual ClassCountMisclassed% ErrorCostMisclassed% ErrorCost
Yes (Event)1392215.80.15833424.50.2446
No1642213.40.13412414.60.1463
All3034414.50.14625819.10.1955