def test_eval3 (self) :
     user = "******"
     movie = "5050"
     guessmia = 4.091953522781671
     w = StringIO()
     netflix_eval(user, movie, w, guessmia)
     self.assertEqual(w.getvalue(), "4.2\n")
 def test_eval5 (self) :    
     user = "******"
     movie = "11545"
     guessmia = 2.7410714285714284
     w = StringIO()
     netflix_eval(user, movie, w, guessmia)
     self.assertEqual(w.getvalue(), "3.7\n")
 def test_eval4 (self) :
     user = "******"
     movie = "505"
     guessmia = 3.1397894736842105
     w = StringIO()
     netflix_eval(user, movie, w, guessmia)
     self.assertEqual(w.getvalue(), "3.5\n")
 def test_eval6 (self) :    
     user = "******"
     movie = "3435"
     guessmia = 1.989247311827957
     w = StringIO()
     netflix_eval(user, movie, w, guessmia)
     self.assertEqual(w.getvalue(), "2.4\n")
 def test_eval7 (self) :    
     user = "******"
     movie = "436"
     guessmia = 3.8146341463414632
     w = StringIO()
     netflix_eval(user, movie, w, guessmia)
     self.assertEqual(w.getvalue(), "3.0\n")
 def test_eval1 (self) :
     user = "******"
     movie = "5044"
     guessmia = 3.164285714285714
     w = StringIO()
     netflix_eval(user, movie, w, guessmia)
     self.assertEqual(w.getvalue(), "3.5\n")
 def test_eval2 (self) :
     user = "******"
     movie = "5048"
     guessmia = 3.9432624113475176
     w = StringIO()
     netflix_eval(user, movie, w, guessmia)
     self.assertEqual(w.getvalue(), "4.5\n")
	def test_eval_1(self):
		r = ["1:\n","20"]
		avg = 3.0
		user_cache = {}
		user_cache[20] = 5.0
		movie_cache = {}
		movie_cache["1"] = 4.0
		w = StringIO.StringIO()
		netflix_eval(r, w, avg, user_cache, movie_cache)
		self.assert_(w.getvalue() == "1:\n20,6.0\n")
	def test_eval_2(self):
		r = ["1:\n","20\n","2:\n","30"]
		avg = 1.0
		user_cache = {}
		user_cache[20] = 3.0
		user_cache[30] = 5.0
		movie_cache = {}
		movie_cache["1"] = 1.0
		movie_cache["2"] = 2.0
		w = StringIO.StringIO()
		netflix_eval(r, w, avg, user_cache, movie_cache)
		self.assert_(w.getvalue() == "1:\n20,3.0\n2:\n30,6.0\n")
Пример #10
0
    def test_eval_3 (self):
        movie_number = 0
        customer_list = [1417435,2312054] #two customers
        customer_data = {"1417435" : 2.65, "2312054" : 4.65}
        movie_data = {"7464": [2.65, 1.0, 200]}
        actual_ratings = {"7464-1417435": 4, "7464-2312054": 4 }
        rmse_data = [0.0, 0]
        print_data = []

        netflix_eval(movie_number, customer_list, customer_data, movie_data, actual_ratings, rmse_data, print_data)
    
        self.assertEqual(print_data[0], "0:") #movie number
        self.assertEqual(rmse_data[1], 0) #customer count for rmse
Пример #11
0
    def test_eval_1 (self) :
        movie_number = 7464
        customer_list = [1417435,2312054] #two customers
        customer_data = {"1417435" : 2.65, "2312054" : 4.65}
        movie_data = {"7464": [2.65, 1.0, 200]}
        actual_ratings = {"7464-1417435": 4, "7464-2312054": 4 }
        rmse_data = [0.0, 0]
        print_data = []

        netflix_eval(movie_number, customer_list, customer_data, movie_data, actual_ratings, rmse_data, print_data)
    
        self.assertEqual(print_data[0], "7464:") #movie number
        self.assertEqual(print_data[1], 1.6) #first prediction
        self.assertEqual(print_data[2], 3.7) #second prediction
        self.assertEqual(rmse_data[1], 2) #customer count for rmse
	def test_eval_3(self):
		r = ["15000:\n","342\n","23233:\n","1\n","17770:\n","2500000"]
		avg = 0.5
		user_cache = {}
		user_cache[342] = 4.323
		user_cache[1] = 2.332
		user_cache[2500000] = 3.111		
		movie_cache = {}
		movie_cache["15000"] = 4.9
		movie_cache["23233"] = 3.4433
		movie_cache["17770"] = 1.1112
		w = StringIO.StringIO()
		netflix_eval(r, w, avg, user_cache, movie_cache)
		answer = avg + (5.0 - avg) + (4.0 - avg)
		self.assert_(w.getvalue() == "15000:\n342,8.723\n23233:\n1,5.2753\n17770:\n2500000,3.7222\n")
Пример #13
0
 def test_eval_3(self):
     r = ["15000:\n", "342\n", "23233:\n", "1\n", "17770:\n", "2500000"]
     avg = 0.5
     user_cache = {}
     user_cache[342] = 4.323
     user_cache[1] = 2.332
     user_cache[2500000] = 3.111
     movie_cache = {}
     movie_cache["15000"] = 4.9
     movie_cache["23233"] = 3.4433
     movie_cache["17770"] = 1.1112
     w = StringIO.StringIO()
     netflix_eval(r, w, avg, user_cache, movie_cache)
     answer = avg + (5.0 - avg) + (4.0 - avg)
     self.assert_(w.getvalue(
     ) == "15000:\n342,8.723\n23233:\n1,5.2753\n17770:\n2500000,3.7222\n")
Пример #14
0
    def test_eval_1(self):
        input_dict = netflix_read(self.input1, [])
        predictions_dict = netflix_eval(input_dict)
        self.assertEqual(list(predictions_dict.keys())[0], 1000)

        prediction = float(str(predictions_dict[1000][2326571])[:4])
        self.assertEqual(prediction, 3.22)
Пример #15
0
 def test_eval_1(self):
     """
         Tests the predictions of the customer's rating of movie
     """
     cache = Caches()
     prediction = netflix_eval(864647, 3196, cache)
     self.assertEqual(prediction, 3.628994439391601)
Пример #16
0
 def test_eval_1(self):
     """
     Evaluates a movie id
     """
     temp1, temp2 = netflix_eval(1, 1, 1)
     self.assertEqual(temp1, 1)
     self.assertEqual(temp2, -1)
Пример #17
0
 def test_eval_2(self):
     """
     Evaluates a customer id
     """
     temp1, temp2 = netflix_eval(30878, 0, 1)
     self.assertEqual(temp1, 3.6)
     self.assertEqual(temp2, -0.3999999999999999)
Пример #18
0
 def test_eval_3(self):
     """
     Evaluates a customer id
     """
     temp1, temp2 = netflix_eval(2647871, 0, 1)
     self.assertEqual(temp1, 3.4)
     self.assertEqual(temp2, -0.6000000000000001)
 def test_netflix_eval_2(self):
     f = StringIO.StringIO("")
     m = [0]
     c = [0]
     ans = {}
     b = netflix_eval(f, m, c, ans, [])
     self.assert_(b == False)
     self.assert_(ans == {})
Пример #20
0
 def test_eval_3(self):
     """
         Tests the predictions of the customer's rating of movie
         where prediction was greater than 5
     """
     cache = Caches()
     prediction = netflix_eval(1007965, 4522, cache)
     self.assertEqual(prediction, 5.0)
Пример #21
0
 def test_netflix_eval_2(self):
     f = StringIO.StringIO("")
     m = [0]
     c = [0]
     ans = {}
     b = netflix_eval(f, m, c, ans, [])
     self.assert_(b == False)
     self.assert_(ans == {})
Пример #22
0
 def test_eval_2(self):
     """
         Tests the predictions of the customer's rating of movie
         where prediction was less than 1
     """
     cache = Caches()
     prediction = netflix_eval(420915, 7120, cache)
     self.assertEqual(prediction, 1.0)
Пример #23
0
 def test_eval_3(self):
     movie_id = 1130
     customer_id = []
     customer_cache = netflix_get_cache(
         'snm2235-jml4759-averageCustomerRating')
     movie_cache = netflix_get_cache('snm2235-jml4759-averageMovieRating')
     ratings = netflix_eval(movie_id, customer_id, movie_cache,
                            customer_cache)
     self.assertEqual(len(ratings), 0)
 def test_eval1(self):
     """
     testing netflix_eval
     """
     cust_average = 3.2
     movie_average = 3.4
     average_for_year = -.2
     result = netflix_eval(cust_average, movie_average, average_for_year)
     self.assertEqual(round(result, 1), 3.1)
 def test_eval3(self):
     """
     testing netflix_eval
     """
     cust_average = 2.6
     movie_average = 1.7
     average_for_year = .6
     result = netflix_eval(cust_average, movie_average, average_for_year)
     self.assertEqual(round(result, 1), 2.8)
 def test_eval2(self):
     """
     testing netflix_eval
     """
     cust_average = 4.1
     movie_average = 2.9
     average_for_year = .4
     result = netflix_eval(cust_average, movie_average, average_for_year)
     self.assertEqual(round(result, 1), 3.9)
Пример #27
0
 def test_eval_1(self):
     movie_id = 1130
     customer_id = [630317]
     customer_cache = netflix_get_cache(
         'snm2235-jml4759-averageCustomerRating')
     movie_cache = netflix_get_cache('snm2235-jml4759-averageMovieRating')
     ratings = netflix_eval(movie_id, customer_id, movie_cache,
                            customer_cache)
     self.assertEqual(ratings[0], round(3.7 - 0.312 + 0.133, 1))
Пример #28
0
 def test_eval_1 (self) :
     to_predict_dict = OrderedDict([(1234, [1585790, 654988])])
     predictions_dict = netflix_eval(self.caches, to_predict_dict)
     self.assertEqual(1, len(predictions_dict))
     movie_ratings = predictions_dict[1234]
     self.assertEqual(2, len(movie_ratings))
     self.assertTrue(movie_ratings[0] >= 1)
     self.assertTrue(movie_ratings[0] <= 5)
     self.assertTrue(movie_ratings[1] >= 1)
     self.assertTrue(movie_ratings[1] <= 5)
Пример #29
0
 def test_eval_1(self):
     """
     Movie id: 10
     customer: 1952305 rating: 3
     customer: 1531863 rating: 3
     """
     movie_id = 10
     customer_ids = [1952305, 1531863]
     predicted = netflix_eval(movie_id, customer_ids)
     expected = {1952305: 3.0, 1531863: 3.0}
     self.assertEqual(predicted, expected)
 def test_netflix_eval_1(self):
     """
     Test 1 netflix_eval to see if it
     makes the correct prediction
     """
     movie_cache = {'1': 3.7, '2': 1, '3': 1}
     movie_year_cache = {1: 2000, 2: 1999, 3: 1995}
     cust_year_cache = {1: {1999: 1}, 2: {2000: 3.7}, 3: {1995: 1}}
     self.assertEqual(
         netflix_eval(1, movie_cache, 2, movie_year_cache, cust_year_cache),
         3.7)
 def test_netflix_eval_2(self):
     """
     Test 2 netflix_eval to see if it
     makes the correct prediction
     """
     movie_cache = {'1': 4.0, '2': 1, '3': 1}
     movie_year_cache = {1: 2005, 2: 1999, 3: 1995}
     cust_year_cache = {1: {2010: 1.5}, 2: {2005: 5}, 3: {1995: 4}}
     self.assertEqual(
         netflix_eval(1, movie_cache, 2, movie_year_cache, cust_year_cache),
         5)
 def test_netflix_eval_3(self):
     """
     Test 3 netflix_eval to see if it
     makes the correct prediction
     """
     movie_cache = {'1': 5, '2': 1.9, '3': 3.2}
     movie_year_cache = {1: 2005, 2: 1999, 3: 1995}
     cust_year_cache = {1: {2010: 1.5}, 2: {2005: 5}, 3: {1995: 4}}
     self.assertEqual(
         netflix_eval(3, movie_cache, 3, movie_year_cache, cust_year_cache),
         3.5)
 def test_netflix_eval_6(self):
     """
     Test 6 netflix_eval to see if it
     makes the correct prediction
     """
     movie_cache = {'1': 3.7, '2': 3.5, '3': 4}
     movie_year_cache = {1: 2005, 2: 1999, 3: 1995}
     cust_year_cache = {1: {2010: 1.5}, 2: {1999: 1.9}, 3: {2005: 2.0}}
     self.assertEqual(
         netflix_eval(1, movie_cache, 3, movie_year_cache, cust_year_cache),
         2.0)
Пример #34
0
    def test_eval_3(self):
        input_dict = netflix_read(self.input1, [])
        predictions_dict = netflix_eval(input_dict)

        prediction = float(str(predictions_dict[1000][977808])[:4])
        self.assertEqual(prediction, 2.77)

        prediction = float(str(predictions_dict[1000][1960212])[:4])
        self.assertEqual(prediction, 3.2)

        prediction = float(str(predictions_dict[1000][79755])[:4])
        self.assertEqual(prediction, 3.77)
Пример #35
0
    def test_eval_2(self):
        input_dict = netflix_read(self.input1, [])
        predictions_dict = netflix_eval(input_dict)

        prediction = float(str(predictions_dict[1000][2251189])[:4])
        self.assertEqual(prediction, 3.06)

        prediction = float(str(predictions_dict[1000][2368043])[:4])
        self.assertEqual(prediction, 2.87)

        prediction = float(str(predictions_dict[1000][929584])[:4])
        self.assertEqual(prediction, 3.93)
Пример #36
0
 def test_netflix_eval_1(self):
     f = StringIO.StringIO("1:\n1\n2\n2:\n1\n2\n")
     m = [0, 2.5, 1.9]
     c = [0, 4.8, 3.3]
     ans = {}
     b = netflix_eval(f, m, c, ans, [])
     self.assert_(b == False)
     for key in ans:
         for i in range(len(ans[key])):
             ans[key][i] = "%.2f" % ans[key][i]
     self.assert_(ans[1] == ["4.22", "2.90"])
     self.assert_(ans[2] == ["4.07", "2.25"])
 def test_netflix_eval_1(self):
     f = StringIO.StringIO("1:\n1\n2\n2:\n1\n2\n")
     m = [0, 2.5, 1.9]
     c = [0, 4.8, 3.3]
     ans = {}
     b = netflix_eval(f, m, c, ans, [])
     self.assert_(b == False)
     for key in ans:
         for i in range(len(ans[key])):
             ans[key][i] = "%.2f" % ans[key][i]
     self.assert_(ans[1] == ["4.22", "2.90"])
     self.assert_(ans[2] == ["4.07", "2.25"])
Пример #38
0
 def test_eval_2 (self) :
     to_predict_dict = OrderedDict([(4335, [1585790, 2484454, 756299])])
     predictions_dict = netflix_eval(self.caches, to_predict_dict)
     self.assertEqual(1, len(predictions_dict))
     movie_ratings = predictions_dict[4335]
     self.assertEqual(3, len(movie_ratings))
     self.assertTrue(movie_ratings[0] >= 1)
     self.assertTrue(movie_ratings[0] <= 5)
     self.assertTrue(movie_ratings[1] >= 1)
     self.assertTrue(movie_ratings[1] <= 5)
     self.assertTrue(movie_ratings[2] >= 1)
     self.assertTrue(movie_ratings[2] <= 5)
Пример #39
0
 def test_netflix_eval_3(self):
     f = StringIO.StringIO("1:\n1\n2\n3\n3:\n3\n2\n4:\n2\n3\n1\n")
     m = [0, 4.5, 3.3, 5, 2.6]
     c = [0, 3, 4.99, 2.78]
     ans = {}
     b = netflix_eval(f, m, c, ans, [])
     self.assert_(b == False)
     for key in ans:
         for i in range(len(ans[key])):
             ans[key][i] = "%.2f" % ans[key][i]
     self.assert_(ans[1] == ["4.12", "4.87", "4.07"])
     self.assert_(ans[3] == ["4.45", "4.99"])
     self.assert_(ans[4] == ["4.39", "2.69", "2.80"])
 def test_netflix_eval_3(self):
     f = StringIO.StringIO("1:\n1\n2\n3\n3:\n3\n2\n4:\n2\n3\n1\n")
     m = [0, 4.5, 3.3, 5, 2.6]
     c = [0, 3, 4.99, 2.78]
     ans = {}
     b = netflix_eval(f, m, c, ans, [])
     self.assert_(b == False)
     for key in ans:
         for i in range(len(ans[key])):
             ans[key][i] = "%.2f" % ans[key][i]
     self.assert_(ans[1] == ["4.12", "4.87", "4.07"])
     self.assert_(ans[3] == ["4.45", "4.99"])
     self.assert_(ans[4] == ["4.39", "2.69", "2.80"])
Пример #41
0
 def test_eval_2(self):
     """
     Movie id: 1000
     customer: 2326571 rating: 3
     customer: 977808 rating: 3
     customer: 1010534 rating: 2
     customer: 1861759 rating: 5
     customer: 79755 rating: 5
     customer: 98259 rating: 5
     customer: 1960212 rating: 2
     """
     movie_id = 1000
     customer_ids = [2326571, 977808, 1010534, 1861759, 79755, 1960212]
     predicted = netflix_eval(movie_id, customer_ids)
     expected = {
         2326571: 3.6,
         977808: 2.4,
         1010534: 2.0,
         1861759: 5.1,
         79755: 3.9,
         1960212: 2.0
     }
     self.assertEqual(predicted, expected)
Пример #42
0
 def test_eval_2 (self) :
     w = StringIO()
     v = netflix_eval(w, "1", {0: '30878', 1: '2647871', 2: '1283744'})
     self.assertEqual(v, True)
Пример #43
0
 def test_eval_3 (self) :
     w = StringIO()
     v = netflix_eval(w, "10", {0: '1952305', 1: '1531863'})
     self.assertEqual(v, True)
Пример #44
0
 def test_eval_3 (self) :
     v = netflix_eval("1283744", "1")
     self.assertEqual(v, '3.6')
Пример #45
0
 def test_eval_1 (self) :
     w = StringIO()
     v = netflix_eval(w, "1", {0: '30878'})
     self.assertEqual(v, True)
Пример #46
0
 def test_eval_3(self):
     r = StringIO("1000:\n2326571\n977808\n1010534\n")
     w = StringIO()
     netflix_eval(r, w)
     self.assertEqual(w.getvalue(), "1000:\n3.9\n3.4\n2.0\nRMSE: 0.56\n")
Пример #47
0
 def test_eval_4 (self) :
     v = netflix_eval("2488120", "1")
     self.assertEqual(v, '4.7')
Пример #48
0
 def test_eval_2(self):
     r = StringIO("1:\n30878\n2647871\n1283744\n")
     w = StringIO()
     netflix_eval(r, w)
     self.assertEqual(w.getvalue(), "1:\n3.9\n3.5\n3.7\nRMSE: 0.5\n")
 def test_netflix_eval_1():
     """ makes sure an exception is raised if not initialized """
     reset()
     netflix_eval(2, 456)
Пример #50
0
 def test_eval_3 (self) :
     v = netflix_eval(16262, 91166)
     self.assertEqual(v, 2.389508247681013)
 def test_eval_3 (self) :
     input_dictionary  = {}
     output_dictionary = netflix_eval(input_dictionary)
     self.assertEqual({}, output_dictionary)
Пример #52
0
 def test_eval_4 (self) :
     v = netflix_eval(12127, 559906)
     self.assertEqual(v, 2.6017255309394556)
Пример #53
0
 def test_eval_6(self):
     movie_map = {1: 4.0}
     user_map = {111: 3.4}
     rating = netflix_eval(1, 111, movie_map, user_map)
     self.assertEqual(round(rating, 1), 3.7)
 def test_netflix_eval6(self):
     """ tests netflix_eval on test data """
     init(self.actual_ratings, self.movie_averages, self.customer_averages,
          self.customer_year_averages, self.movie_years)
     prediction = netflix_eval(2, 789)
     self.assertEqual(prediction, 3.8)
Пример #55
0
 def test_eval_2 (self) :
     v = netflix_eval("2647871", "1")
     self.assertEqual(v, '3.3')
Пример #56
0
 def test_eval_1 (self) :
     v = netflix_eval(8209, 2000622)
     self.assertEqual(v, 4.279008432960954)
Пример #57
0
 def test_eval_2 (self) :
     v = netflix_eval(8038, 147141)
     self.assertEqual(v, 4.718157156289632)
 def test_eval_2 (self) :
     input_dictionary  = {1 : (30878, 2647871, 1283744), 10 : (1952305, 1531863)}
     output_dictionary = netflix_eval(input_dictionary)
     self.assertEqual({1 : (3.6503057739484501, 3.3045105104107062, 3.6865857791323067), 10: (3.3265579801724381, 3.172787956336625)}, output_dictionary)
 def test_eval_1 (self) :
     input_dictionary  = {1 : (30878, 2647871, 1283744)}
     output_dictionary = netflix_eval(input_dictionary)
     self.assertEqual({1 : (3.6503057739484501, 3.3045105104107062, 3.6865857791323067)}, output_dictionary)
Пример #60
0
 def test_eval_1(self):
     r = StringIO("10040:\n2417853\n1207062\n2487973\n")
     w = StringIO()
     netflix_eval(r, w)
     self.assertEqual(w.getvalue(), "10040:\n3.9\n2.9\n3.8\nRMSE: 0.53\n")