Example of Fit Model with TreeNet® Classification

Note

This command is available with the Predictive Analytics Module. Click here for more information about how to activate the module.

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.

After initial exploration with CART® Classification to identify the important predictors, the researchers use both TreeNet® Classification and Random Forests® Classification to create more intensive models from the same data set. The researchers compare the model summary table and the ROC plot from the results to evaluate which model provides a better prediction outcome. For results from the other analyses, go to Example of CART® Classification and Example of Random Forests® Classification.

  1. Open the sample data, HeartDiseaseBinary.mtw.
  2. Choose Predictive Analytics Module > TreeNet® Classification > Fit Model.
  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

For this analysis, Minitab grows 300 trees and the optimal number of trees is 298. Because the optimal number of trees is close to the maximum number of trees that the model grows, the researchers repeat the analysis with more trees.

Model Summary

Total predictors13
Important predictors13
Number of trees grown300
Optimal number of trees298
StatisticsTrainingTest
Average -loglikelihood0.25560.3881
Area under ROC curve0.97960.9089
        95% CI(0.9664, 0.9929)(0.8759, 0.9419)
Lift2.17992.1087
Misclassification rate0.08910.1617

Example with 500 trees

  1. Select Tune Hyperparameters in the results.
  2. In Number of trees, enter 500.
  3. Click Display Results.

Interpret the results

For this analysis, there were 500 trees grown and the optimal number of trees is 351. The best model uses a learning rate of 0.01, uses a subsample fraction of 0.5, and uses 6 as the maximum number of terminal nodes.

Method

Criterion for selecting optimal number of treesMaximum loglikelihood
Model validation5-fold cross-validation
Learning rate0.01
Subsample selection methodCompletely random
    Subsample fraction0.5
Maximum terminal nodes per tree6
Minimum terminal node size3
Number of predictors selected for node splittingTotal number of predictors = 13
Rows used303

Binary Response Information

VariableClassCount%
Heart DiseaseYes (Event)13945.87
  No16454.13
  All303100.00
TreeNet® Classification with Hyperparameter Tuning: Heart Disease vs Age, Rest Blood Pressure, Cholesterol, Max Heart Rate, Old Peak, Sex, Chest Pain Type, Fasting Blood Sugar, Rest ECG, Exercise Angina, Slope, Major Vessels, Thal

Method

Criterion for selecting optimal number of treesMaximum loglikelihood
Model validation5-fold cross-validation
Learning rate0.001, 0.01, 0.1
Subsample fraction0.5, 0.7
Maximum terminal nodes per tree6
Minimum terminal node size3
Number of predictors selected for node splittingTotal number of predictors = 13
Rows used303

Binary Response Information

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

Optimization of Hyperparameters

Test
ModelOptimal
Number
of Trees
Average
-Loglikelihood
Area Under
ROC Curve
Misclassification
Rate
Learning
Rate
Subsample
Fraction
Maximum
Terminal
Nodes
15000.5429020.9029560.1717490.0010.56
2*3510.3865360.9089200.1750270.0100.56
3330.3965550.9007820.1616940.1000.56
45000.5432920.8941780.1781420.0010.76
53740.3896070.9066200.1650820.0100.76
6390.3933820.9013990.1749730.1000.76
* Optimal model has minimum average -loglikelihood. Output for the optimal model follows.

The Average –Loglikelihood vs Number of Trees Plot shows the entire curve over the number of trees grown. The optimal value for the test data is 0.3865 when the number of trees is 351.

Model Summary

Total predictors13
Important predictors13
Number of trees grown500
Optimal number of trees351
StatisticsTrainingTest
Average -loglikelihood0.23410.3865
Area under ROC curve0.98250.9089
        95% CI(0.9706, 0.9945)(0.8757, 0.9421)
Lift2.17992.1087
Misclassification rate0.07590.1750

Model Summary

Total predictors13
Important predictors13
StatisticsOut-of-Bag
Average -loglikelihood0.4004
Area under ROC curve0.9028
        95% CI(0.8693, 0.9363)
Lift2.1079
Misclassification rate0.1848

The Model summary table shows that the average negative loglikelihood when the number of trees is 351 is approximately 0.23 for the training data and is approximately 0.39 for the test data. These statistics indicate a similar model to what Minitab Random Forests® creates. Also, the misclassification rates are similar.

The Relative Variable Importance graph plots the predictors in order of their effect on model improvement when splits are made on a predictor over the sequence of trees. The most important predictor variable is Thal. If the contribution of the top predictor variable, Thal, is 100%, then the next important variable, Major Vessels, has a contribution of 97.8%. This means Major Vessels is 97.8% as important as Thal in this classification model.

Confusion Matrix



Predicted Class
(Training)





Predicted Class (Test)
Actual ClassCountYesNo% CorrectYesNo% Correct
Yes (Event)1391241589.211102979.14
No164815695.122414085.37
All30313217192.4113416982.51
Assign a row to the event class if the event probability for the row exceeds 0.5.
     
StatisticsTraining (%)Test (%)
True positive rate (sensitivity or power)89.2179.14
False positive rate (type I error)4.8814.63
False negative rate (type II error)10.7920.86
True negative rate (specificity)95.1285.37

The confusion matrix shows how well the model separates the classes correctly. In this example, the probability that an event is predicted correctly is 79.14%. The probability that a nonevent is predicted correctly is 85.37%.

Misclassification



TrainingTest
Actual ClassCountMisclassed% ErrorMisclassed% Error
Yes (Event)1391510.792920.86
No16484.882414.63
All303237.595317.49
Assign a row to the event class if the event probability for the row exceeds 0.5.

The misclassification rate helps indicate whether the model will predict new observations accurately. For prediction of events, the test misclassification error is 20.86%. For the prediction of nonevents, the misclassification error is 14.63% and for overall, the misclassification error is 17.49%.

The area under the ROC curve when the number of trees is 351 is approximately 0.98 for the training data and is approximately 0.91 for the test data. This shows a nice improvement over the CART® Classification model. The Random Forests® Classification model has a test AUROC of 0.9028, so these 2 methods give similar results.

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 80% of the true positives. This difference is the extra gain from using the model.

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

Use the partial dependency plots to gain insight into how the important variables or pairs of variables affect the fitted response values. The fitted response values are on the 1/2 log scale. The partial dependence plots show whether the relationship between the response and a variable is linear, monotonic, or more complex.

For example, in the partial dependence plot of the chest pain type, the 1/2 log odds varies, and then increases steeply. When the chest pain type is 4, the 1/2 log odds of heart disease incidence increases from approximately −0.04 to 0.03. Select One-Predictor Plots or Two-Predictor Plots to produce plots for other variables