示例#1
0
    def test_netflix_predict_3(self):
        ANSWERS_LIST[:] = []
        RATINGS_LIST[:] = []

        movie_id = 1
        cust_id = 1283744

        write = StringIO()
        netflix_predict(movie_id, cust_id, write)
        out = write.getvalue()
        self.assertEqual(out, "3.7\n")
示例#2
0
def printLinRegFormat():
	top_mov_ids = createDictTopMovies()
	for mov_id, cust_arr in ANSWERS_CACHE.items():
		other_movies = {}
		if mov_id in top_mov_ids:
			# Contains dictionary of "related" movies and index
			other_movies = top_mov_ids[mov_id]
		for cust_id, rat in cust_arr.items():
			related_mov_error = [0,0,0]
			for mov , ind in other_movies.items():
				if cust_id in ANSWERS_CACHE[mov]:
					# Difference between predicted and actual rating
					related_mov_error[ind] = netflix_predict(mov, cust_id) - ANSWERS_CACHE[mov][cust_id]
			if related_mov_error != [0,0,0]:
				print(str(netflix_predict(mov_id, cust_id) - rat) + ":" + str(related_mov_error[0]) + "," + str(related_mov_error[1]) + "," + str(related_mov_error[2]))
示例#3
0
 def test_predict_2(self):
     """Giving None movie and customer to force a return of 0"""
     key_mov = "999999999"
     key_cus = "999999999"
     mov_cache = {"2043": 3.77}
     cus_cache = {"1417435": 3.5}
     self.assertEqual(
         netflix_predict(key_mov, key_cus, mov_cache, cus_cache), 0)
示例#4
0
 def test_predict_3(self):
     """Simply another test"""
     key_mov = "888"
     key_cus = "2312054"
     mov_cache = {"888": 3.77}
     cus_cache = {"2312054": 3.5}
     self.assertEqual(
         netflix_predict(key_mov, key_cus, mov_cache, cus_cache), 3.57)
示例#5
0
 def test_predict_1(self):
     """Our prediction based on movie and customer"""
     key_mov = "2043"
     key_cus = "1417435"
     mov_cache = {"2043": 3.77}
     cus_cache = {"1417435": 3.5}
     self.assertEqual(
         netflix_predict(key_mov, key_cus, mov_cache, cus_cache), 3.57)
 def test_predict_3(self):
     """
     test reading of our dict and the pickle dicts
     """
     movie = 10001
     customer = 262828
     predict_dict = {movie: {}}
     prediction = netflix_predict(predict_dict, movie, customer)
     self.assertEqual(prediction, 3.42)
 def test_predict_2(self):
     """
     test reading of our dict and the pickle dicts
     """
     movie = 10
     customer = 1952305
     predict_dict = {movie: {}}
     prediction = netflix_predict(predict_dict, movie, customer)
     self.assertEqual(prediction, 2.91)
 def test_predict_4(self):
     """
     test reading of our dict and the pickle dicts
     """
     movie = 10011
     customer = 1624701
     predict_dict = {movie: {}}
     prediction = netflix_predict(predict_dict, movie, customer)
     self.assertEqual(prediction, 4.42)
示例#9
0
 def test_netflix_predict_1(self):
     movie_id = 1
     customer_ids = [1, 2, 3]
     movie_data = {movie_id: {'year': -1, 'avgr': 3}}
     customer_data = {1: {'avgr': {2000: 3.0}, 'caby': {2000: 3.0}},
                      2: {'avgr': {2000: 3.0}, 'caby': {2000: 3.0}},
                      3: {'avgr': {2000: 3.0}, 'caby': {2000: 3.0}}}
     r = netflix_predict(movie_id, customer_ids, movie_data, customer_data)
     self.assertTrue(isinstance(r, list))
     self.assertEqual(len(r), 3)
     for x in r:
         self.assertTrue(isinstance(x, float))
 def test_predict_6 (self) :
     i = netflix_predict(5, 3, 3.67, 1)
     self.assertEqual(i, 4.1465)
示例#11
0
 def test_predict(self) :
   prediction = netflix_predict(3674, (1100257, 347434, 2472269))
   self.assertEqual(prediction.movie, 3674)
   self.assertEqual(prediction.predictions, [4.21234183018522, 3.377376155128011, 3.660141657622665])
示例#12
0
 def test_predict3(self) :
   prediction = netflix_predict(3674, (1100257, 347434, 2472269))
   self.assertTrue(type(prediction), Prediction)
 def test_predict_3(self):
     """
     test predictions
     """
     test_prediction = netflix_predict(845452, 2004, 4.1)
     self.assertTrue(abs(test_prediction - 4) < 1)
 def test_predict_1(self):
     dict1 = {1: [1, 2, 3]}
     dict2 = {1: 2}
     dict3 = {1: 4, 2: 3, 3: 5}
     r = netflix_predict(dict1, dict2, dict3)
     self.assertEqual(r, {(3, 1): 3, (1, 1): 2, (2, 1): 1})
示例#15
0
 def test_predict_2(self):
     r = netflix_predict(10, 1)
     self.assertEqual(r, 3.0)
 def test_predict_3 (self) :
     i = netflix_predict(False, 4, 3.67, 5)
     self.assertEqual(i,  3.9835)
 def test_netflix_predict_4(self):
     b = netflix_predict("1.8","3.8")
     self.assertEqual(b, 2.1)
示例#18
0
 def test_predict_4(self):
     r = netflix_predict(11, 2)
     self.assertEqual(r, 4.5)
 def test_netflix_predict_2(self):
     b = netflix_predict("2","4")
     self.assertEqual(b, 2.4)
 def test_netflix_predict_3(self):
     b = netflix_predict("1.5","4.5")
     self.assertEqual(b, 2.6)
 def test_netflix_predict(self):
     b = netflix_predict("3","3")
     self.assertEqual(b, 3.0)
 def test_predict_1 (self) :
     i = netflix_predict(5, 5, 3.67, 5)
     self.assertEqual(i,  5)
 def test_predict_2 (self) :
     i = netflix_predict(1, 1, 3.67, 5)
     self.assertEqual(i,  1)
 def test_predict_5 (self) :
     i = netflix_predict(5, False, 3.67, 5)
     self.assertEqual(i,  4.9335)
 def test_netflix_predict_2(self):
     m = 1.0
     c = 3.0
     ans = netflix_predict(m, c)
     self.assert_(ans == 1.50)
示例#26
0
 def test_predict_1(self):
     r = netflix_predict(10, 3)
     self.assertEqual(r, 4.0)
 def test_predict_1(self):
     """
     test predictions
     """
     test_prediction = netflix_predict(1916275, 2000, 3.51)
     self.assertTrue(abs(test_prediction - 3) < 1)
示例#28
0
 def test_predict_3(self):
     r = netflix_predict(10, 4)
     self.assertEqual(r, 4.5)
 def test_predict_9 (self) :
     i = netflix_predict(5, 3, 3.67, 335)
     self.assertEqual(i,  4.4401)
 def test_netflix_predict_1(self):
     m = 5.0
     c = 1.0
     ans = netflix_predict(m, c)
     self.assert_(ans == 2.0)
示例#31
0
 def test_predict_1(self):
     p = netflix_predict(2043, 1417435)
     assert 1 <= p <= 5
 def test_netflix_predict_3(self):
     m = 3.0
     c = 3.0
     ans = netflix_predict(m, c)
     self.assert_(ans == 3)
示例#33
0
 def test_predict_2(self):
     p = netflix_predict(10851, 1417435)
     assert 1 <= p <= 5
 def test_predict_2(self):
     """
     test predictions
     """
     test_prediction = netflix_predict(2338807, 2003, 3.53)
     self.assertTrue(abs(test_prediction - 4) < 1)
示例#35
0
 def test_predict_3(self):
     p = netflix_predict(2043, 462685)
     assert 1 <= p <= 5
 def test_predict_3(self):
     dict1 = {1: [1], 2: [1], 3: [1]}
     dict2 = {1: 1, 2: 1, 3: 1}
     dict3 = {1: 5}
     r = netflix_predict(dict1, dict2, dict3)
     self.assertEqual(r, {(1, 2): 1, (1, 3): 1, (1, 1): 1})
示例#37
0
 def test_predict_4(self):
     p = netflix_predict(10851, 462685)
     assert 1 <= p <= 5
 def test_predict_2(self):
     dict1 = {1: [1, 2], 2: [1, 2]}
     dict2 = {1: 2, 2: 4}
     dict3 = {1: 5, 2: 3}
     r = netflix_predict(dict1, dict2, dict3)
     self.assertEqual(r, {(1, 2): 5, (1, 1): 3, (2, 1): 1, (2, 2): 3})
示例#39
0
 def test_predict(self):
     rate = netflix_predict(10,70987)
     self.assertEqual(rate, 3)
示例#40
0
 def test_predict2(self) :
   prediction = netflix_predict(3675, (1982589, 1376081, 2309102))
   s = io.StringIO()
   self.assertEqual(prediction.movie, 3675)
   prediction.display(s)
   self.assertEqual(s.getvalue(), "3675:\n2.3\n3.1\n2.9\n")
示例#41
0
 def test_netflix_predict_2(self):
     m = 1.0
     c = 3.0
     ans = netflix_predict(m, c)
     self.assert_(ans == 1.50)
示例#42
0
 def test_netflix_predict_3(self):
     m = 3.0
     c = 3.0
     ans = netflix_predict(m, c)
     self.assert_(ans == 3)
示例#43
0
 def test_predict(self):
     rate = netflix_predict(10, 70987)
     self.assertEqual(rate, 3)
示例#44
0
 def test_netflix_predict_1(self):
     m = 5.0
     c = 1.0
     ans = netflix_predict(m, c)
     self.assert_(ans == 2.0)
 def test_predict_4 (self) :
     i = netflix_predict(False, False, 3.67, 5)
     self.assertEqual(i,  3.67)