Core logic for training and testing IO Detection.