Esempio n. 1
0
    def setUp(self):
        #SIMILARITY BY RATES.
        movies = {
            'Marcel Caraciolo': {
                'Lady in the Water': 2.5,
                'Snakes on a Plane': 3.5,
                'Just My Luck': 3.0,
                'Superman Returns': 3.5,
                'You, Me and Dupree': 2.5,
                'The Night Listener': 3.0
            },
            'Luciana Nunes': {
                'Lady in the Water': 3.0,
                'Snakes on a Plane': 3.5,
                'Just My Luck': 1.5,
                'Superman Returns': 5.0,
                'The Night Listener': 3.0,
                'You, Me and Dupree': 3.5
            },
            'Leopoldo Pires': {
                'Lady in the Water': 2.5,
                'Snakes on a Plane': 3.0,
                'Superman Returns': 3.5,
                'The Night Listener': 4.0
            },
            'Lorena Abreu': {
                'Snakes on a Plane': 3.5,
                'Just My Luck': 3.0,
                'The Night Listener': 4.5,
                'Superman Returns': 4.0,
                'You, Me and Dupree': 2.5
            },
            'Steve Gates': {
                'Lady in the Water': 3.0,
                'Snakes on a Plane': 4.0,
                'Just My Luck': 2.0,
                'Superman Returns': 3.0,
                'The Night Listener': 3.0,
                'You, Me and Dupree': 2.0
            },
            'Sheldom': {
                'Lady in the Water': 3.0,
                'Snakes on a Plane': 4.0,
                'The Night Listener': 3.0,
                'Superman Returns': 5.0,
                'You, Me and Dupree': 3.5
            },
            'Penny Frewman': {
                'Snakes on a Plane': 4.5,
                'You, Me and Dupree': 1.0,
                'Superman Returns': 4.0
            },
            'Maria Gabriela': {}
        }

        self.model = DictDataModel(movies)
        self.similarity = ItemSimilarity(self.model, sim_euclidian)
        self.strategy = PreferredItemsNeighborhoodStrategy()
Esempio n. 2
0
	def test_full_candidateItems(self):
		userID = 'Marcel Caraciolo'
		strategy = PreferredItemsNeighborhoodStrategy()
		self.assertEquals([],strategy.candidateItems(userID,self.model))
Esempio n. 3
0
	def test_semi_candidateItems(self):
		userID = 'Leopoldo Pires'
		strategy = PreferredItemsNeighborhoodStrategy()
		self.assertEquals(['Just My Luck', 'You, Me and Dupree'],strategy.candidateItems(userID,self.model))
Esempio n. 4
0
	def test_empty_candidateItems(self):
		userID = 'Maria Gabriela'
		strategy = PreferredItemsNeighborhoodStrategy()
		self.assertEquals([],strategy.candidateItems(userID,self.model))
Esempio n. 5
0
 for i in range(0, 10):
     if (len(df) > 100000):
         test = df.sample(100000).groupby('userId')
     else:
         test = df.groupby('userId')
     data = {}
     for key, grp in test:
         Test = grp.drop('userId', axis=1)
         data[key] = Test.set_index('movieId').T.to_dict('records')[0]
     model = DictDataModel(data)
     similarity = ItemSimilarity(
         model,
         topicSimilarityCache,
         topicDistribution=joblib.load('cache/JSD.pkl'),
         movieIndex=movieId)
     items_strategy = PreferredItemsNeighborhoodStrategy()
     recSys = ItemRecommender(model, similarity, items_strategy)
     evaluator = AverageAbsoluteDifferenceRecommenderEvaluator()
     temp = Parallel(n_jobs=3)(
         delayed(parallel)(evaluator, recSys, model, i)
         for i in range(6, 10))
     for a in range(0, 4):
         dummy[a] += temp[a]
     similarity = ItemSimilarity(model, sim_euclidian)
     items_strategy = PreferredItemsNeighborhoodStrategy()
     recSys = ItemRecommender(model, similarity, items_strategy)
     evaluator = AverageAbsoluteDifferenceRecommenderEvaluator()
     temp = Parallel(n_jobs=3)(
         delayed(parallel)(evaluator, recSys, model, i)
         for i in range(6, 10))
     for a in range(0, 4):
Esempio n. 6
0
 def test_semi_candidateItems(self):
     userID = 'Leopoldo Pires'
     strategy = PreferredItemsNeighborhoodStrategy()
     self.assertEquals(['Just My Luck', 'You, Me and Dupree'],
                       strategy.candidateItems(userID, self.model))
Esempio n. 7
0
 def test_full_candidateItems(self):
     userID = 'Marcel Caraciolo'
     strategy = PreferredItemsNeighborhoodStrategy()
     self.assertEquals([], strategy.candidateItems(userID, self.model))
Esempio n. 8
0
 def test_empty_candidateItems(self):
     userID = 'Maria Gabriela'
     strategy = PreferredItemsNeighborhoodStrategy()
     self.assertEquals([], strategy.candidateItems(userID, self.model))