Python code for Kaggle digit classification challenge