An Application of Machine Learning and Statistics to Defect Detection