End-to-End Machine Learning
Joshua Stapleton
Machine Learning Engineer
unittest
import unittest
class TestModelInference(unittest.TestCase):
def setUp(self): self.model = fitted_model self.X_test = X_test
def test_prediction_output_shape(self): y_pred = self.model.predict(self.X_test) self.assertEqual(y_pred.shape[0], self.X_test.shape[0])
if __name__ == '__main__': unittest.main()
def test_input_values(self):
print("Running test_input_values test case")
# Get inputs (each row in testing set)
for input in X_test:
for value in input:
# if value is cholestrol, for example:
self.assertIn(value, [0, 500])
Best-practices
Benefits of TDD
End-to-End Machine Learning