recommendation/basic_reco.py
def recommended_tweets(self, main_user, k_best=5):
		"""
		Use the cosine similarity between the main user thematic vector and all the tweets vectors
		:param main_user: str, name of the user
		:param k_best: number of results to return
		:return: list of recommended tweets
		"""

		# Add cosine similarity between main_user and all others tweets to DataFrame
		cosine_sim = cosine_similarity(np.matrix([np.array(t.vector) for t in self.tweets]),
									   np.array(main_user.vector).reshape(1, -1))

		results = []
		for i in range(len(cosine_sim)):
			results.append({'cosine_sim': cosine_sim[i], 'tweet': self.tweets[i]})

		# Sort the DataFrame by cosine_sim
		results = sorted(results, key=lambda k: k['cosine_sim'], reverse=True)
		# self.corpus = self.corpus.sort_values(by=['cosine_sim'], ascending=False)

		# Remove tweets from the main_user
		results = list(filter(lambda x: x['tweet'].user_id != main_user.id, results))

		return [t['tweet'] for t in results[:k_best]]

		Use the cosine similarity between the main user thematic vector and all the tweets vectors
		:param main_user: str, name of the user
		:param k_best: number of results to return
		:return: list of recommended tweets
		
Use the cosine similarity between the main user thematic vector and all the tweets vectors
Use the cosine similarity between the main user thematic vector and all the tweets vectors
def recommended_tweets(self, main_user, k_best=5):
		cosine_sim = cosine_similarity(np.matrix([np.array(t.vector) for t in self.tweets]),
									   np.array(main_user.vector).reshape(1, -1))
		results = []
		for i in range(len(cosine_sim)):
			results.append({'cosine_sim': cosine_sim[i], 'tweet': self.tweets[i]})
		results = sorted(results, key=lambda k: k['cosine_sim'], reverse=True)
		results = list(filter(lambda x: x['tweet'].user_id != main_user.id, results))
		return [t['tweet'] for t in results[:k_best]]
def recommended_tweets ( self , main_user , k_best = 5 ) : cosine_sim = cosine_similarity ( np . matrix ( [ np . array ( t . vector ) for t in self . tweets ] ) , np . array ( main_user . vector ) . reshape ( 1 , - 1 ) ) results = [ ] for i in range ( len ( cosine_sim ) ) : results . append ( { 'cosine_sim' : cosine_sim [ i ] , 'tweet' : self . tweets [ i ] } ) results = sorted ( results , key = lambda k : k [ 'cosine_sim' ] , reverse = True ) results = list ( filter ( lambda x : x [ 'tweet' ] . user_id != main_user . id , results ) ) return [ t [ 'tweet' ] for t in results [ : k_best ] ]
Use the cosine similarity between the main user thematic vector and all the tweets vectors
Use the cosine similarity between the main user thematic vector and all the tweets vectors
"""
		Use the cosine similarity between the main user thematic vector and all the tweets vectors
		:param main_user: str, name of the user
		:param k_best: number of results to return
		:return: list of recommended tweets
		""" # Add cosine similarity between main_user and all others tweets to DataFrame # Sort the DataFrame by cosine_sim # self.corpus = self.corpus.sort_values(by=['cosine_sim'], ascending=False) # Remove tweets from the main_user
list of recommended tweets
list of recommended tweets
self
main_user
str, name of the user
str name of the user
k_best
number of results to return
number of results to return