BME5150 Chap.6 Cross Validation and Decision Trees
Cross Validation and Decision Trees
Cross-validation rotates a development boundary
In k-fold cross-validation, development data are divided into parts. The pipeline fits on all but one part and validates on the remaining part, rotating until each part has served as validation.
The average summarises development performance, while the variation across folds reveals sensitivity to the partition.
The whole pipeline belongs inside each fold
Imputation, scaling, feature reduction, class resampling and model tuning must be refitted in the training portion of every fold. Selecting features once before cross-validation lets validation outcomes influence the retained columns.
Grouped folds keep all records from one patient together, and stratification helps preserve outcome proportions.
Decision trees partition recursively
A tree tests candidate predictors and thresholds, chooses a split that reduces impurity and repeats the process in child nodes. Leaves return a class or value.
The resulting rules can be read directly when the tree is small, but a deep tree follows development peculiarities and becomes hard to audit.
Entropy and Gini quantify node mixture
Entropy is zero in a pure node and highest for an even binary split. Information gain subtracts the size-weighted child entropy from the parent entropy. Gain ratio reduces the preference for highly fragmenting predictors.
Gini impurity offers another measure of class mixture and often gives similar split choices.
Pruning protects generalisation
Pre-pruning limits depth, minimum leaf size or required improvement. Post-pruning removes weak branches after growth. Both trade some development fit for a simpler structure that may perform better on new cases.
Depth, split criterion and pruning strength are hyperparameters chosen inside development resampling.
What this chapter covers
- 01
Five-fold rotation and repeated validation
- 02
Grouped and stratified folds
- 03
Nested preprocessing and tuning
- 04
Recursive decision-tree splits
- 05
Entropy, information gain and Gini
- 06
Gain ratio and pruning
Worked example · free
Calculate a Gini impurity reduction
- 3Compute the parent impurity.
- 4Compute and weight both child impurities.
- 2Subtract and interpret the reduction.
Key terms
- Validation Fold
- A validation fold is the temporarily held-out development subset used to compare model choices.
- Grouped Fold
- A grouped fold keeps related records, such as images from one patient, on the same side.
- Decision Tree
- A decision tree recursively partitions cases through learned predictor conditions into terminal predictions.
- Information Gain
- Information gain is parent entropy minus the sample-weighted entropy of child nodes.
- Gini Impurity
- Gini impurity measures class mixture as one minus the sum of squared class proportions.
- Pruning
- Pruning restricts or removes tree branches to control complexity and variance.
Cross Validation and Decision Trees FAQ
Is cross-validation a replacement for a final test set?
Not when it is used to choose algorithms, preprocessing or hyperparameters. Cross-validation is then part of development. Preserve an untouched evaluation set, refit the selected pipeline on development data and apply it once for the final estimate.
Why must all images from one patient stay in the same fold?
Images from one patient share anatomy, acquisition and other patient-specific information. Splitting them across folds lets the model meet close relatives of its validation cases during training, creating an optimistic estimate of performance on new patients.
Why can a perfectly pure tree split still be invalid?
A patient identifier or site code can create pure training nodes by memorising records or institutional patterns. Candidate predictors need intended-use and availability checks before impurity optimisation. Purity is a mathematical property, not proof of clinical validity.
Assessment move
Draw five fold rows and shade a different validation block in each. Under every row, write that preprocessing is refitted on the training blocks. Add a grouping mark around all records from one patient. For trees, compute entropy or Gini from class counts, then practise weighting child impurities before subtraction.
Compare two candidate splits and explain why a high-cardinality identifier can look mathematically attractive but fail transport. Finish by listing the tree hyperparameters that require development tuning and writing the final sequence: tune in folds, prune or limit complexity, refit development data and evaluate once on untouched cases. Redraw an overgrown tree after pruning and state what training detail was sacrificed.
Link that sacrifice to the variance reduction the held-out design is intended to measure.
Working through Cross Validation and Decision Trees in BME5150? Sia is AskSia’s AI Computer Science tutor — ask any BME5150 Cross Validation and Decision Trees question and get a clear, step-by-step explanation grounded in how BME5150 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.