Exemple #1
0
 def setUp(self):
     self.lsi = LSIModel("title")
     self.df = pd.read_csv(
         resource_filename(testfm.__name__, "data/movielenshead.dat"),
         sep="::",
         header=None,
         names=["user", "item", "rating", "date", "title"])
Exemple #2
0
class TestLSI(unittest.TestCase):
    def setUp(self):
        self.lsi = LSIModel("title")
        self.df = pd.read_csv(
            resource_filename(testfm.__name__, "data/movielenshead.dat"),
            sep="::",
            header=None,
            names=["user", "item", "rating", "date", "title"])

    def test_fit(self):
        self.lsi.fit(self.df)
        self.assertEqual(len(self.lsi._user_representation),
                         len(self.df.user.unique()))
        self.assertEqual(len(self.lsi._item_representation),
                         len(self.df.item.unique()))

    def test_score(self):
        self.lsi.fit(self.df)
        #item in the user profile (Booberang) should have higher prediction than movie not in the profile Rob Roy
        self.assertTrue(
            self.lsi.get_score(1, 122) > self.lsi.get_score(1, 151))

    def test_user_model(self):
        um = self.lsi._get_user_models(self.df)
        self.assertEqual(um[93], ["collateral", "man", "fire"])

    def test_item_model(self):
        im = self.lsi._get_item_models(self.df)
        self.assertEqual(im[122], ["boomerang"])
        self.assertEqual(im[329], ["star", "trek", "generations"])
Exemple #3
0
class TestLSI(unittest.TestCase):

    def setUp(self):
        self.lsi = LSIModel("title")
        self.df = pd.read_csv(resource_filename(testfm.__name__,"data/movielenshead.dat"), sep="::", header=None,
                              names=["user", "item", "rating", "date", "title"])

    def test_fit(self):
        self.lsi.fit(self.df)
        self.assertEqual(len(self.lsi._user_representation), len(self.df.user.unique()))
        self.assertEqual(len(self.lsi._item_representation), len(self.df.item.unique()))

    def test_score(self):
        self.lsi.fit(self.df)
        #item in the user profile (Booberang) should have higher prediction than movie not in the profile Rob Roy
        self.assertTrue(self.lsi.get_score(1, 122) > self.lsi.get_score(1, 151))

    def test_user_model(self):
        um = self.lsi._get_user_models(self.df)
        self.assertEqual(um[93], ["collateral", "man", "fire"])

    def test_item_model(self):
        im = self.lsi._get_item_models(self.df)
        self.assertEqual(im[122], ["boomerang"])
        self.assertEqual(im[329], ["star", "trek", "generations"])
Exemple #4
0
class TestLSI(unittest.TestCase):

    def setUp(self):
        self.lsi = LSIModel("title")
        self.df = pd.read_csv(resource_filename(testfm.__name__,'data/movielenshead.dat'), sep="::", header=None, names=['user', 'item', 'rating', 'date', 'title'])

    def test_fit(self):
        self.lsi.fit(self.df)
        self.assertEqual(len(self.lsi._user_representation), len(self.df.user.unique()))
        self.assertEqual(len(self.lsi._item_representation), len(self.df.item.unique()))

    def test_score(self):
        self.lsi.fit(self.df)
        #item in the user profile (Booberang) should have higher prediction than movie not in the profile Rob Roy
        self.assertTrue(self.lsi.getScore(1, 122) > self.lsi.getScore(1, 151))

    def test_user_model(self):
        um = self.lsi._get_user_models(self.df)
        self.assertEqual(um[93], ['collateral', 'man', 'fire'])

    def test_item_model(self):
        im = self.lsi._get_item_models(self.df)
        self.assertEqual(im[122], ['boomerang'])
        self.assertEqual(im[329], ['star', 'trek', 'generations'])
Exemple #5
0
 def setUp(self):
     self.lsi = LSIModel("title")
     self.df = pd.read_csv(resource_filename(testfm.__name__,"data/movielenshead.dat"), sep="::", header=None,
                           names=["user", "item", "rating", "date", "title"])
Exemple #6
0
 def setUp(self):
     self.lsi = LSIModel("title")
     self.df = pd.read_csv(resource_filename(testfm.__name__,'data/movielenshead.dat'), sep="::", header=None, names=['user', 'item', 'rating', 'date', 'title'])