Example #1
0
 def test_predict_3(self):
     """
     Predicts a customer id
     """
     arg1 = 2488120
     arg2 = 1
     result = predict_rating(arg1, arg2)
     self.assertEqual(result, 4.2)
Example #2
0
 def test_predict_2(self):
     """
     Predicts a customer id
     """
     arg1 = 2647871
     arg2 = 1
     result = predict_rating(arg1, arg2)
     self.assertEqual(result, 3.4)
Example #3
0
 def test_predict_1(self):
     """
     Predicts a customer id
     """
     arg1 = 30878
     arg2 = 1
     result = predict_rating(arg1, arg2)
     self.assertEqual(result, 3.6)
    def test_predict_rating_2(self):
        """Test 2 of predict_rating() tests for expected rating prediction"""

        # load all caches necessary for testing
        with open('/u/downing/public_html/netflix-cs373/cat3238-years.p',
                  'rb') as year_cache:
            movie_years = pickle.load(year_cache)
        with open('/u/downing/public_html/netflix-cs373/cat3238-customer.p',
                  'rb') as cust_cache:
            customer_year_ratings = pickle.load(cust_cache)
        with open('/u/downing/public_html/netflix-cs373/cat3238-movie.p',
                  'rb') as movie_cache:
            movie_ratings = pickle.load(movie_cache)

        movie_id, customer_id = 1, 30878
        rating = predict_rating(movie_id, customer_id, movie_years,
                                movie_ratings, customer_year_ratings)
        self.assertEqual(rating, 4.2)
    def test_predict_rating_3(self):
        """Test 3 of predict_rating() tests for another user of previously tested movie"""

        # load all caches necessary for testing
        with open('/u/downing/public_html/netflix-cs373/cat3238-years.p',
                  'rb') as year_cache:
            movie_years = pickle.load(year_cache)
        with open('/u/downing/public_html/netflix-cs373/cat3238-customer.p',
                  'rb') as cust_cache:
            customer_year_ratings = pickle.load(cust_cache)
        with open('/u/downing/public_html/netflix-cs373/cat3238-movie.p',
                  'rb') as movie_cache:
            movie_ratings = pickle.load(movie_cache)

        movie_id, customer_id = 9150, 599993
        rating = predict_rating(movie_id, customer_id, movie_years,
                                movie_ratings, customer_year_ratings)
        self.assertEqual(rating, 3.9)
    def test_predict_3(self):
        """ test predict_rating """
        d_path = "http://www.cs.utexas.edu/users/downing/netflix-cs373/"

        cust_avg_url = d_path + "aji272-CustAverage.pickle"
        movie_avg_url = d_path + "aji272-MovieAverage.pickle"
        year_avg_url = d_path + "aji272-YearAverage.pickle"
        actual_probe_url = d_path + "aji272-Actual.pickle"

        customer_ave = pickle.load(urllib.request.urlopen(cust_avg_url))
        movie_ave = pickle.load(urllib.request.urlopen(movie_avg_url))
        year_ave = pickle.load(urllib.request.urlopen(year_avg_url))

        # with open('ActualRatings.p', 'rb') as actual_file:
        #     actual_averages = pickle.load(actual_file)
        actual_averages = pickle.load(urllib.request.urlopen(actual_probe_url))

        self.assertEqual(
            predict_rating(1892654, 10005, movie_ave, customer_ave, year_ave,
                           actual_averages), 3.9747000000000003)
Example #7
0
 def test_predict_rating_3(self):
     rating = predict_rating(3, 6, 3)
     self.assertEqual(rating, 4)
Example #8
0
 def test_predict_rating_2(self):
     rating = predict_rating(10, 1, 1)
     self.assertEqual(rating, 4)
Example #9
0
 def test_predict_rating_1(self):
     rating = predict_rating(1, 4, 4)
     self.assertEqual(rating, 3)