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"])
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"])
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"])
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'])
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 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'])