Machine learning: Making a sample and fixing the api so it's easier to use