Code accuracy function.

Also improve comments in extract_training_data.R.