Added function to prepare training data. Ready for deployment.