def test_math_predictor_no_movie(self): """ Tests handling invalid movie """ predictor = Netflix.MathPredictor( {1: 2.5}, {1: 1.0}, {1: 0, 2: 1, 3: -1}) with self.assertRaises(KeyError): predictor.predict(1, 2)
def test_run_math_predictor(self): """ Tests run() using the MathPredictor """ reader = StringIO("1:\n1\n2\n3\n") writer = StringIO() predictor = Netflix.MathPredictor( {1: 2.5}, {1: 1.0}, {1: 0, 2: 1, 3: -1}) answer = ConstantPredictor(3) Netflix.run(reader, writer, predictor, answer) self.assertEqual(writer.getvalue(), "1:\n2.5\n3.5\n1.5\nRMSE: 0.96\n")
def test_math_predictor_2(self): """ Tests that the MathPredictor does the correct math with adjustments """ predictor = Netflix.MathPredictor( {1: 2.5}, {1: 1.0}, {1: 0, 2: 1, 3: -1}) self.assertEqual(predictor.predict(2, 1), 3.5)
def test_math_predictor_1(self): """ Tests that the MathPredictor does the correct math """ predictor = Netflix.MathPredictor( {1: 2.5}, {1: 1.0}, {1: 0, 2: 1, 3: -1}) self.assertEqual(predictor.predict(1, 1), 2.5)