UNSW Sydney · FACULTY OF COMPUTER SCIENCE

INFS3822 Chap.7 Trees, Ensembles and Model Evaluation

- one subject, every graph, every model, every mark
8 Chapters4-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 7 of 10 · INFS3822

Trees, Ensembles and Model Evaluation

Decision trees learn readable rules but can be unstable and prone to overfitting. Random forests reduce variance by combining bootstrap trees, while boosting learns sequentially from earlier errors. This chapter then computes accuracy, precision, recall and F1 from a confusion matrix, explains ROC/AUC, and connects metric choice to false-positive and false-negative consequences rather than treating one score as a verdict.

In this chapter

What this chapter covers

  • 01

    Decision-tree rules

  • 02

    Tree instability and overfitting

  • 03

    Random-forest bagging

  • 04

    Sequential boosting

  • 05

    Training and unseen testing

  • 06

    Confusion-matrix cells

  • 07

    Precision, recall and F1

  • 08

    ROC curves and AUC

Worked example · free

Recompute four metrics

Q [4 marks]. A test set has TP 36, FP 12, FN 9 and TN 63. Compute accuracy, precision, recall and F1. (4 AskSia practice marks) This four-part weighting is not an official university assessment scheme.
The rows hold actual outcomes and the columns hold model decisions.The rows hold actual outcomes and the columns hold model decisions. Precision reads down the predicted-positive column, recall reads across the actual-positive row, and accuracy uses both diagonal cells. PredictedActualPositiveNegativePositiveNegative TP = 36caught positivesFN = 9missed positivesFP = 12false alarmsTN = 63correct negatives
The rows hold actual outcomes and the columns hold model decisions. Precision reads down the predicted-positive column, recall reads across the actual-positive row, and accuracy uses both diagonal cells.
  • +1Accuracy = (36 + 63) / 120 = 99 / 120 = 0.825, or 82.5%.
  • +1Precision = 36 / (36 + 12) = 36 / 48 = 0.75, or 75.0%.
  • +1Recall = 36 / (36 + 9) = 36 / 45 = 0.80, or 80.0%.
  • +1F1 = 2 x 0.75 x 0.80 / (0.75 + 0.80) = 1.20 / 1.55 = 0.774, or about 77.4%.
Accuracy is 82.5%, precision 75.0%, recall 80.0%, and F1 about 77.4%.
Sia tip — Precision divides by predicted positives; recall divides by actual positives.
Glossary

Key terms

Decision tree
A predictive model that applies learned feature splits from a root to terminal leaves.
Random forest
A bagged ensemble that combines many diverse decision trees.
Boosting
Sequential ensemble learning in which later models focus on errors left by earlier models.
ROC curve
A plot of classifier performance across thresholds using true-positive and false-positive rates.
FAQ

Trees, Ensembles and Model Evaluation FAQ

Why can accuracy be misleading?

When one class dominates, a model can predict only the majority class and still report high accuracy. Inspect the confusion matrix and class-specific precision, recall and F1. Compare with a simple majority baseline and connect the missed cases and false alarms to operational consequences.

How does a random forest differ from one tree?

A single tree exposes one set of splits but can change sharply with the training sample. A random forest trains many trees on bootstrap samples and combines their predictions. The ensemble often generalises better, although its combined reasoning is harder to explain.

Does a higher AUC choose the deployment threshold?

No. AUC summarises ranking across thresholds and can support model comparison. Deployment still needs a specific threshold chosen from false-positive and false-negative costs, class prevalence, calibration and operational capacity. Inspect the confusion matrix at the proposed operating point.

Why should metric rates be converted to case counts?

Operations handle cases rather than percentages. Apply the proposed threshold to expected volume and prevalence, then estimate true interventions, false alarms and missed positives. Compare those counts with review capacity and error harm. This can reject a seemingly strong operating point whose workload is infeasible or whose missed cases remain unacceptable.

Study strategy

Assessment move

Redraw a confusion matrix from memory and calculate each metric from named cells before using a formula. Pair every score with the question its denominator answers. When comparing trees and ensembles, write one benefit and one cost, then check whether the performance difference is reliable enough to justify the cost. Trace a small decision tree from root to leaf and describe each split in plain language.

Then perturb one training case and ask why the learned structure may change. Use that instability to motivate bagging rather than treating a random forest as simply a larger tree. Explain that bootstrap samples and varied candidate features create diverse trees whose errors can average out. Contrast boosting as a sequential process that focuses later learners on earlier errors and can chase noise if complexity is uncontrolled.

Keep construction and evaluation separate. A readable tree can overfit; an opaque ensemble can generalise; neither property follows from the diagram alone. Build metric drills from counts. Start with total cases and prevalence, fill true and false cells, compute rates, and convert the rates back into expected weekly volumes. Move the threshold and predict the direction of recall, precision and workload before calculating.

When comparing two models, use the same test evidence, target and operating constraint. Inspect variation across validation folds and class-specific errors rather than declaring victory from a small aggregate difference. Add a governance column with explanation needs, maintenance and subgroup behaviour.

Practise three recommendation endings: choose the tree because its performance is close and its rules enable meaningful review; choose the forest because its improvement is stable and explanation controls are sufficient; or choose neither because the available threshold cannot meet both harm and capacity constraints. For ROC/AUC, remember that ranking across many thresholds does not select the deployed point.

Pair the curve with a confusion matrix at the proposed cut-off and the class prevalence in the use population. This makes evaluation a decision argument rather than a scoreboard.

Working through Trees, Ensembles and Model Evaluation in INFS3822? Sia is AskSia’s AI Computer Science tutor — ask any INFS3822 Trees, Ensembles and Model Evaluation question and get a clear, step-by-step explanation grounded in how INFS3822 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 103 of your UNSW Sydney subjects - and 1,000+ Bibles across every Australian university.
Sia - your INFS3822 tutor, unlimited, worked the way the exam marks it
The full 4-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works
INFS3822 · Artificial Intelligence for Business Analytics - independent study guide on the AskSia Library. More UNSW Sydney subjects · Microeconomics across all universities