A statistical learning approach to failure diagnosis