liveBook · Manning

Validation

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

Validation is the evaluation of a trained model on examples held apart from the data used to adjust its parameters.

Validation evaluates a trained model on examples held apart from the data used to adjust its parameters. For classification, it measures how well the network handles unseen samples. section 7.6

A practical validation procedure is:

  • Reserve part of the shuffled dataset before training. section 7.6
  • Train repeatedly on only the training subset. section 7.6
  • Run validate on the held-out inputs, compare interpreted outputs with expected labels, and report correct predictions and percentage. section 7.6

Iris and wine classification

An iris network trains on 140 samples and validates on the final 10, producing 9 correct predictions, or 90%. A wine network trains on 150 samples and validates on 28, producing 27 correct predictions, or 96.43%. section 7.6

// test over the last 10 of the irises in the data set
let irisTesters = Array(irisParameters[140..<150])
let irisTestersCorrects = Array(irisSpecies[140..<150])
let irisResults = irisNetwork.validate(inputs: irisTesters, expecteds:
 irisTestersCorrects, interpretOutput: irisInterpretOutput)
print("\(irisResults.correct) correct of \(irisResults.total) =
 \(irisResults.percentage * 100)%")

Inspect the complete iris validation call, including held-out slices, expected labels, output interpretation, and accuracy reporting. section 7.6

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Demonstrates dataset splitting, repeated training, output interpretation, and accuracy reporting without explaining validation internals.
Examples
Uses iris and wine datasets with held-out subsets, interpreted class outputs, and reported correct counts and percentages.
What it assumes
Assumes a trained classification network, labeled data, and an output interpretation function.
What you can do after
Evaluate a trained Swift neural network with validate and quantify classification accuracy on held-out samples.
How it connects
Connects validation with neural networks, classification, training, output interpretation, learning rate, and hidden-layer size.

Also explained in

Compare how 30 books explain validation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.