Skip to Content

K-Fold Target Evaluation

Use K-fold cross-validation to estimate how well a learning algorithm predicts a Target Node on unseen records. BayesiaLab divides the dataset into kk folds. In each run, it learns a network from k−1k-1 folds and uses that network to predict the target for the remaining fold. Every record contributes one held-out prediction to the combined results.

Run K-Fold on a target

  1. Open a network with an associated dataset and a Target Node. If you have an existing learning/test split and want to use all records for cross-validation, save a copy of the network. On the copy, choose Menus > Data > Data Set > Remove Learning/Test Split.
  2. In Validation Mode, choose Menus > Tools > Resampling > Target Evaluation > K-Fold.
  3. Choose the Learning Algorithm you want to evaluate. Set Number of subsamples to the number of folds. Select Shuffle Samples to randomize the record order before forming folds. To repeat the split with the same data and settings, enable Fixed Seed and enter a seed.
  4. Run the evaluation. Open Synthesis Report to see the confusion matrix and Overall Precision across all folds. To inspect individual predictions, choose Save Values in the report.

Example with ten folds

In the Wisconsin breast cancer dataset, the target diagnosis\mathit{diagnosis} has two states, Benign\mathrm{Benign} and Malignant\mathrm{Malignant}. To reproduce the Chapter 6 example, use all 569 records. Choose Markov Blanket, Delete All Arcs and Evaluate All States. Leave Variable Selection and Maximum Size of Evidence off. Use ten folds with Shuffle Samples on, Stratify off and Fixed Seed set to 31. Select Show Intermediate Results to inspect the individual runs.

K-Fold settings for the Wisconsin example with Markov Blanket, ten subsamples, Shuffle Samples selected, and fixed seed 31

Read the diagonal of the pooled confusion matrix. BayesiaLab correctly classified 344 benign records and 195 malignant records. Together they account for 539 of the 569 held-out predictions, giving an Overall Precision of 94.7%. The off-diagonal cells show the two kinds of error. The model predicted Benign\mathrm{Benign} for 17 malignant records and Malignant\mathrm{Malignant} for 13 benign records.

See the Chapter 6 walkthrough and compare the networks learned across folds.